fix:支付
This commit is contained in:
@@ -80,7 +80,7 @@ type (
|
||||
PaymentSuccessfulReq struct {
|
||||
EventId string
|
||||
PaymentMethod int64
|
||||
PaymentIntent *stripe.PaymentIntent
|
||||
Charge *stripe.Charge
|
||||
}
|
||||
PaymentSuccessfulRes struct{}
|
||||
/* 支付成功 */
|
||||
@@ -174,43 +174,43 @@ func (d *defaultOrder) PaymentSuccessful(ctx context.Context, in *PaymentSuccess
|
||||
var payAmount int64
|
||||
var payTitle string
|
||||
var payTime time.Time
|
||||
if in.PaymentIntent != nil {
|
||||
paymentIntent := in.PaymentIntent
|
||||
orderSn, ok = paymentIntent.Metadata["order_sn"]
|
||||
if in.Charge != nil {
|
||||
charge := in.Charge
|
||||
orderSn, ok = charge.Metadata["order_sn"]
|
||||
if !ok || orderSn == "" {
|
||||
err = errors.New("order_sn is empty")
|
||||
logc.Errorf(ctx, "PaymentSuccessful failed param, eventId:%s,err:%v", in.EventId, err)
|
||||
return &PaymentSuccessfulRes{}, err
|
||||
}
|
||||
payStage, ok = paymentIntent.Metadata["pay_stage"]
|
||||
payStage, ok = charge.Metadata["pay_stage"]
|
||||
if !ok || payStage == "" {
|
||||
err = errors.New("pay_stage is empty")
|
||||
logc.Errorf(ctx, "PaymentSuccessful failed param, eventId:%s,err:%v", in.EventId, err)
|
||||
return &PaymentSuccessfulRes{}, err
|
||||
}
|
||||
country, ok = paymentIntent.Metadata["country"]
|
||||
country, ok = charge.Metadata["country"]
|
||||
if !ok || country == "" {
|
||||
err = errors.New("country is empty")
|
||||
logc.Errorf(ctx, "PaymentSuccessful failed param, eventId:%s,err:%v", in.EventId, err)
|
||||
return &PaymentSuccessfulRes{}, err
|
||||
}
|
||||
if paymentIntent.LatestCharge.PaymentMethodDetails != nil {
|
||||
if paymentIntent.LatestCharge.PaymentMethodDetails.Card != nil {
|
||||
if paymentIntent.LatestCharge.PaymentMethodDetails.Card.Last4 != "" {
|
||||
card = paymentIntent.LatestCharge.PaymentMethodDetails.Card.Last4
|
||||
if charge.PaymentMethodDetails != nil {
|
||||
if charge.PaymentMethodDetails.Card != nil {
|
||||
if charge.PaymentMethodDetails.Card.Last4 != "" {
|
||||
card = charge.PaymentMethodDetails.Card.Last4
|
||||
}
|
||||
if paymentIntent.LatestCharge.PaymentMethodDetails.Card.Brand != "" {
|
||||
brand = string(paymentIntent.LatestCharge.PaymentMethodDetails.Card.Brand)
|
||||
if charge.PaymentMethodDetails.Card.Brand != "" {
|
||||
brand = string(charge.PaymentMethodDetails.Card.Brand)
|
||||
}
|
||||
}
|
||||
}
|
||||
if paymentIntent.Currency != "" {
|
||||
currency = string(paymentIntent.Currency)
|
||||
if charge.Currency != "" {
|
||||
currency = string(charge.Currency)
|
||||
}
|
||||
tradeSn = paymentIntent.ID
|
||||
payAmount = paymentIntent.Amount
|
||||
payTitle = paymentIntent.Description
|
||||
payTime = time.Unix(paymentIntent.Created, 0)
|
||||
tradeSn = charge.ID
|
||||
payAmount = charge.Amount
|
||||
payTitle = charge.Description
|
||||
payTime = time.Unix(charge.Created, 0)
|
||||
}
|
||||
err = d.MysqlConn.WithContext(ctx).Transaction(func(tx *gorm.DB) error {
|
||||
var orderInfo gmodel.FsOrder
|
||||
|
||||
Reference in New Issue
Block a user