43 lines
1.3 KiB
Go
43 lines
1.3 KiB
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,
|
|
common.PAY_CHANNEL_ALIPAY_PC: AlipayWeb,
|
|
common.PAY_CHANNEL_WECHAT_JSAPI: WechatJSAPI,
|
|
}
|
|
|
|
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
|
|
}
|
|
func WechatJSAPI(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
|
|
}
|