fix: 修复富友预下单报文格式错(1014) — XML根元素、小程序tradeType、termIP三处问题
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 6m27s
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 6m27s
This commit is contained in:
@@ -46,14 +46,15 @@ func (w *wechatPaymentProvider) CreateJSAPIPayment(ctx context.Context, orderNo,
|
||||
|
||||
// fuiouPaymentProvider 富友支付适配器。
|
||||
type fuiouPaymentProvider struct {
|
||||
client *fuiou.Client
|
||||
appID string
|
||||
client *fuiou.Client
|
||||
appID string
|
||||
tradeType string
|
||||
}
|
||||
|
||||
// CreateJSAPIPayment 创建富友 JSAPI 预下单。
|
||||
func (f *fuiouPaymentProvider) CreateJSAPIPayment(ctx context.Context, orderNo, description, openID string, amount int) (*PaymentResult, error) {
|
||||
amountStr := strconv.Itoa(amount)
|
||||
resp, err := f.client.WxPreCreate(orderNo, amountStr, description, "", "JSAPI", f.appID, openID)
|
||||
resp, err := f.client.WxPreCreate(orderNo, amountStr, description, "127.0.0.1", f.tradeType, f.appID, openID)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(errors.CodeFuiouPayFailed, err, "富友预下单失败")
|
||||
}
|
||||
@@ -69,9 +70,14 @@ func (f *fuiouPaymentProvider) CreateJSAPIPayment(ctx context.Context, orderNo,
|
||||
}
|
||||
|
||||
// newPaymentProvider 根据支付配置创建支付提供者。
|
||||
func (s *Service) newPaymentProvider(config *model.WechatConfig, appID string) (PaymentProvider, error) {
|
||||
// appType: "official_account" 或 "miniapp"
|
||||
func (s *Service) newPaymentProvider(config *model.WechatConfig, appID, appType string) (PaymentProvider, error) {
|
||||
switch config.ProviderType {
|
||||
case model.ProviderTypeFuiou:
|
||||
tradeType := "JSAPI"
|
||||
if appType == "miniapp" {
|
||||
tradeType = "LETPAY"
|
||||
}
|
||||
client, err := fuiou.NewClient(
|
||||
config.FyInsCd,
|
||||
config.FyMchntCd,
|
||||
@@ -85,7 +91,7 @@ func (s *Service) newPaymentProvider(config *model.WechatConfig, appID string) (
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(errors.CodeFuiouPayFailed, err, "创建富友客户端失败")
|
||||
}
|
||||
return &fuiouPaymentProvider{client: client, appID: appID}, nil
|
||||
return &fuiouPaymentProvider{client: client, appID: appID, tradeType: tradeType}, nil
|
||||
default:
|
||||
cache := wechat.NewRedisCache(s.redis)
|
||||
paymentApp, err := wechat.NewPaymentAppFromConfig(config, appID, cache, s.logger)
|
||||
|
||||
@@ -174,7 +174,7 @@ func (s *Service) CreateOrder(ctx context.Context, customerID uint, req *dto.Cli
|
||||
}
|
||||
}()
|
||||
|
||||
paymentProvider, err := s.newPaymentProvider(activeConfig, appID)
|
||||
paymentProvider, err := s.newPaymentProvider(activeConfig, appID, req.AppType)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user