feat: add Airwallex payments and multi-currency support
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
dbent "github.com/Wei-Shaw/sub2api/ent"
|
||||
"github.com/Wei-Shaw/sub2api/internal/payment"
|
||||
)
|
||||
|
||||
func paymentProviderConfigCurrency(providerKey string, cfg map[string]string) string {
|
||||
switch strings.TrimSpace(providerKey) {
|
||||
case payment.TypeStripe, payment.TypeAirwallex:
|
||||
currency, err := payment.NormalizePaymentCurrency(cfg["currency"])
|
||||
if err == nil {
|
||||
return currency
|
||||
}
|
||||
}
|
||||
return payment.DefaultPaymentCurrency
|
||||
}
|
||||
|
||||
func PaymentOrderCurrency(order *dbent.PaymentOrder) string {
|
||||
if snapshot := psOrderProviderSnapshot(order); snapshot != nil {
|
||||
if currency, err := payment.NormalizePaymentCurrency(snapshot.Currency); err == nil {
|
||||
return currency
|
||||
}
|
||||
}
|
||||
return payment.DefaultPaymentCurrency
|
||||
}
|
||||
Reference in New Issue
Block a user