refactor(payment): 移除ApplePay支付平台支持并整合到Stripe
Some checks failed
Build docker and publish / build (20.15.1) (push) Has been cancelled
Some checks failed
Build docker and publish / build (20.15.1) (push) Has been cancelled
将ApplePay支付方式整合到Stripe平台处理,移除独立的ApplePay平台代码 简化支付逻辑,统一通过Stripe处理所有支付方式
This commit is contained in:
parent
d95911d6bd
commit
a80d6af035
@ -39,7 +39,7 @@ func PaymentNotifyHandler(svcCtx *svc.ServiceContext) func(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
c.String(http.StatusOK, "%s", "success")
|
||||
case payment.Stripe, payment.ApplePay:
|
||||
case payment.Stripe:
|
||||
l := notify.NewStripeNotifyLogic(c.Request.Context(), svcCtx)
|
||||
if err := l.StripeNotify(c.Request, c.Writer); err != nil {
|
||||
result.HttpResult(c, nil, err)
|
||||
|
||||
@ -86,18 +86,7 @@ func (l *PurchaseCheckoutLogic) PurchaseCheckout(req *types.CheckoutOrderRequest
|
||||
|
||||
case paymentPlatform.Stripe:
|
||||
// Process Stripe payment - creates payment sheet for client-side processing
|
||||
stripePayment, err := l.stripePayment(paymentConfig.Config, orderInfo, "", "")
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.ERROR), "stripePayment error: %v", err.Error())
|
||||
}
|
||||
resp = &types.CheckoutOrderResponse{
|
||||
Type: "stripe", // Client should use Stripe SDK
|
||||
Stripe: stripePayment,
|
||||
}
|
||||
|
||||
case paymentPlatform.ApplePay:
|
||||
// Process Apple Pay payment - uses Stripe with 'card' method
|
||||
stripePayment, err := l.stripePayment(paymentConfig.Config, orderInfo, "", "card")
|
||||
stripePayment, err := l.stripePayment(paymentConfig.Config, orderInfo, "")
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.ERROR), "stripePayment error: %v", err.Error())
|
||||
}
|
||||
@ -219,7 +208,7 @@ func (l *PurchaseCheckoutLogic) alipayF2fPayment(pay *payment.Payment, info *ord
|
||||
|
||||
// stripePayment processes Stripe payment by creating a payment sheet
|
||||
// It supports various payment methods including WeChat Pay and Alipay through Stripe
|
||||
func (l *PurchaseCheckoutLogic) stripePayment(config string, info *order.Order, identifier string, forceMethod string) (*types.StripePayment, error) {
|
||||
func (l *PurchaseCheckoutLogic) stripePayment(config string, info *order.Order, identifier string) (*types.StripePayment, error) {
|
||||
// Parse Stripe configuration from payment settings
|
||||
stripeConfig := &payment.StripeConfig{}
|
||||
|
||||
@ -228,10 +217,6 @@ func (l *PurchaseCheckoutLogic) stripePayment(config string, info *order.Order,
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.ERROR), "Unmarshal error: %s", err.Error())
|
||||
}
|
||||
|
||||
if forceMethod != "" {
|
||||
stripeConfig.Payment = forceMethod
|
||||
}
|
||||
|
||||
// Initialize Stripe client with API credentials
|
||||
client := stripe.NewClient(stripe.Config{
|
||||
SecretKey: stripeConfig.SecretKey,
|
||||
@ -253,12 +238,17 @@ func (l *PurchaseCheckoutLogic) stripePayment(config string, info *order.Order,
|
||||
)
|
||||
|
||||
// Create Stripe payment sheet for client-side processing
|
||||
// Map apple_pay to card for Stripe API, but keep apple_pay in config/response
|
||||
paymentMethod := stripeConfig.Payment
|
||||
if paymentMethod == "apple_pay" {
|
||||
paymentMethod = "card"
|
||||
}
|
||||
ord := &stripe.Order{
|
||||
OrderNo: info.OrderNo,
|
||||
Subscribe: strconv.FormatInt(info.SubscribeId, 10),
|
||||
Amount: convertAmount,
|
||||
Currency: "cny",
|
||||
Payment: stripeConfig.Payment,
|
||||
Payment: paymentMethod,
|
||||
}
|
||||
usr := &stripe.User{Email: identifier}
|
||||
l.Infow("stripe request", logger.Field("order", ord), logger.Field("user", usr))
|
||||
|
||||
@ -11,7 +11,6 @@ const (
|
||||
Balance
|
||||
CryptoSaaS
|
||||
AppleIAP
|
||||
ApplePay
|
||||
UNSUPPORTED Platform = -1
|
||||
)
|
||||
|
||||
@ -22,7 +21,6 @@ var platformNames = map[string]Platform{
|
||||
"EPay": EPay,
|
||||
"balance": Balance,
|
||||
"AppleIAP": AppleIAP,
|
||||
"ApplePay": ApplePay,
|
||||
"unsupported": UNSUPPORTED,
|
||||
}
|
||||
|
||||
@ -51,7 +49,7 @@ func GetSupportedPlatforms() []types.PlatformInfo {
|
||||
"public_key": "Publishable key",
|
||||
"secret_key": "Secret key",
|
||||
"webhook_secret": "Webhook secret",
|
||||
"payment": "Payment Method, only supported card/alipay/wechat_pay",
|
||||
"payment": "Payment Method, only supported card/alipay/wechat_pay/apple_pay",
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -94,14 +92,5 @@ func GetSupportedPlatforms() []types.PlatformInfo {
|
||||
"environment": "Environment: Sandbox/Production",
|
||||
},
|
||||
},
|
||||
{
|
||||
Platform: ApplePay.String(),
|
||||
PlatformUrl: "https://stripe.com",
|
||||
PlatformFieldDescription: map[string]string{
|
||||
"public_key": "Publishable key",
|
||||
"secret_key": "Secret key",
|
||||
"webhook_secret": "Webhook secret",
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user