PaymentCenter/app/services/thirdpay/do/pay_way.go

32 lines
913 B
Go

package do
import (
"PaymentCenter/app/constants/common"
"PaymentCenter/app/models/paychannelmodel"
"PaymentCenter/app/third/paymentService"
"github.com/bytedance/sonic"
)
var PayWayList = map[int]func(commonPayInfo *paymentService.PayOrderRequest, channel *paychannelmodel.PayChannel) error{
common.PAY_CHANNEL_WECHAT_H5: WechatH5,
common.PAY_CHANNEL_ALIPAY_WEB: AlipayWeb,
}
func WechatH5(commonPayInfo *paymentService.PayOrderRequest, channel *paychannelmodel.PayChannel) error {
err := sonic.Unmarshal([]byte(channel.ExtJson), &commonPayInfo.Wx)
if err != nil {
return err
}
commonPayInfo.Wx.AppId = channel.AppId
return nil
}
func AlipayWeb(commonPayInfo *paymentService.PayOrderRequest, channel *paychannelmodel.PayChannel) error {
err := sonic.Unmarshal([]byte(channel.ExtJson), &commonPayInfo.Ali)
if err != nil {
return err
}
commonPayInfo.Ali.AppId = channel.AppId
return nil
}