fix:支付

This commit is contained in:
momo
2023-09-26 10:56:57 +08:00
parent 95cbaea69a
commit 6c2fba2b3a
3 changed files with 93 additions and 55 deletions

View File

@@ -219,26 +219,26 @@ func (l *StripeWebhookLogic) HandleChargeRefunded(chargeRefunded *stripe.Charge)
}
// session完成
func (l *StripeWebhookLogic) handlePaymentSessionCompleted(sessionId string, tradeNo string) (err error) {
// 查询支付记录
payModel := gmodel.NewFsPayModel(l.svcCtx.MysqlConn)
rsbPay := payModel.RowSelectBuilder(nil)
rsbPay = rsbPay.Where("session_id = ?", sessionId)
payInfo, err := payModel.FindOneByQuery(l.ctx, rsbPay, nil)
if err != nil {
return err
}
if *payInfo.PayStatus == 0 {
*payInfo.TradeNo = tradeNo
_, err = payModel.CreateOrUpdate(l.ctx, payInfo)
if err != nil {
return err
}
} else {
return errors.New("pay status 1")
}
return err
}
// func (l *StripeWebhookLogic) handlePaymentSessionCompleted(sessionId string, tradeNo string) (err error) {
// // 查询支付记录
// payModel := gmodel.NewFsPayModel(l.svcCtx.MysqlConn)
// rsbPay := payModel.RowSelectBuilder(nil)
// rsbPay = rsbPay.Where("session_id = ?", sessionId)
// payInfo, err := payModel.FindOneByQuery(l.ctx, rsbPay, nil)
// if err != nil {
// return err
// }
// if *payInfo.PayStatus == 0 {
// *payInfo.TradeNo = tradeNo
// _, err = payModel.CreateOrUpdate(l.ctx, payInfo)
// if err != nil {
// return err
// }
// } else {
// return errors.New("pay status 1")
// }
// return err
// }
// 付款成功
func (l *StripeWebhookLogic) HandleChargeSucceeded(charge *stripe.Charge, eventId string) error {
@@ -254,7 +254,7 @@ func (l *StripeWebhookLogic) HandleChargeSucceeded(charge *stripe.Charge, eventI
case "product_order":
res, err := l.svcCtx.Repositories.NewOrder.PaymentSuccessful(l.ctx, &repositories.PaymentSuccessfulReq{
EventId: eventId,
PaymentMethod: 1,
PaymentMethod: "stripe",
Charge: charge,
})
if err != nil {