PaymentCenter/app/services/thirdpay/pay.go

48 lines
989 B
Go

package thirdpay
import (
"PaymentCenter/app/constants/errorcode"
"PaymentCenter/app/http/entities/front"
"PaymentCenter/app/services"
thirdpay "PaymentCenter/app/services/thirdpay/do"
"context"
)
func ThirdPayWeb(check *thirdpay.PayCheck) *thirdpay.Pay {
pay := thirdpay.NewPay(check)
// 创建订单
if &check.OldOrder != nil {
pay.CreateOrder()
if pay.PayCode != errorcode.Success {
return pay
}
} else {
pay.Order = check.OldOrder
}
// 支付
pay.PayUrl()
return pay
}
func ThirdPayInfoCheck(ctx context.Context, req *front.PayReqs, appCheck *services.AppCheck, ip string) (check *thirdpay.PayCheck) {
check = thirdpay.NewPayCheck(&ctx, req, appCheck, ip)
// 校验表单
check.CheckForm()
if check.CheckCode != errorcode.Success {
return
}
// 校验商户
check.CheckMerchant()
if check.CheckCode != errorcode.Success {
return
}
// 校验支付通道
check.CheckPayChannel()
if check.CheckCode != errorcode.Success {
return
}
return
}