Some checks failed
Build docker and publish / build (20.15.1) (push) Has been cancelled
31 lines
629 B
Go
31 lines
629 B
Go
package order
|
|
|
|
import (
|
|
"strings"
|
|
|
|
paymentPlatform "github.com/perfect-panel/server/pkg/payment"
|
|
)
|
|
|
|
func canonicalOrderMethod(method string) string {
|
|
method = strings.TrimSpace(method)
|
|
if method == "" {
|
|
return ""
|
|
}
|
|
|
|
platform := paymentPlatform.ParsePlatform(method)
|
|
if platform == paymentPlatform.UNSUPPORTED {
|
|
return ""
|
|
}
|
|
return platform.String()
|
|
}
|
|
|
|
func normalizeOrderMethod(orderMethod string, paymentMethod string) string {
|
|
if method := canonicalOrderMethod(paymentMethod); method != "" {
|
|
return method
|
|
}
|
|
if method := canonicalOrderMethod(orderMethod); method != "" {
|
|
return method
|
|
}
|
|
return "unknown"
|
|
}
|