From d7b56f3edc91446998df52fb0f6f2d0b5ba6cd3f Mon Sep 17 00:00:00 2001 From: shanshanzhong Date: Sun, 14 Dec 2025 18:56:56 -0800 Subject: [PATCH] =?UTF-8?q?feat(=E6=94=AF=E4=BB=98):=20=E6=B7=BB=E5=8A=A0A?= =?UTF-8?q?pple=E5=BA=94=E7=94=A8=E5=86=85=E6=94=AF=E4=BB=98=E6=94=AF?= =?UTF-8?q?=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在CheckoutOrderResponse结构中添加product_ids字段用于存储Apple IAP产品ID - 新增AppleIAP支付平台常量及映射 - 实现Apple IAP支付处理逻辑,生成对应的产品ID --- internal/logic/public/portal/purchaseCheckoutLogic.go | 8 ++++++++ internal/types/types.go | 1 + pkg/payment/platform.go | 10 ++++++++++ 3 files changed, 19 insertions(+) diff --git a/internal/logic/public/portal/purchaseCheckoutLogic.go b/internal/logic/public/portal/purchaseCheckoutLogic.go index 6b114dc..2775547 100644 --- a/internal/logic/public/portal/purchaseCheckoutLogic.go +++ b/internal/logic/public/portal/purchaseCheckoutLogic.go @@ -3,6 +3,7 @@ package portal import ( "context" "encoding/json" + "fmt" "math" "strconv" "strings" @@ -74,6 +75,13 @@ func (l *PurchaseCheckoutLogic) PurchaseCheckout(req *types.CheckoutOrderRequest } // Route to appropriate payment handler based on payment platform switch paymentPlatform.ParsePlatform(orderInfo.Method) { + case paymentPlatform.AppleIAP: + productId := fmt.Sprintf("merchant.hifastvpn.day%d", orderInfo.Quantity) + resp = &types.CheckoutOrderResponse{ + Type: "apple_iap", + ProductIds: []string{productId}, + } + return resp, nil case paymentPlatform.EPay: // Process EPay payment - generates payment URL for redirect url, err := l.epayPayment(paymentConfig, orderInfo, req.ReturnUrl) diff --git a/internal/types/types.go b/internal/types/types.go index 94692a1..d5c71dd 100644 --- a/internal/types/types.go +++ b/internal/types/types.go @@ -241,6 +241,7 @@ type CheckoutOrderResponse struct { Type string `json:"type"` CheckoutUrl string `json:"checkout_url,omitempty"` Stripe *StripePayment `json:"stripe,omitempty"` + ProductIds []string `json:"product_ids,omitempty"` } type CloseOrderRequest struct { diff --git a/pkg/payment/platform.go b/pkg/payment/platform.go index 7ad12ea..a9f8494 100644 --- a/pkg/payment/platform.go +++ b/pkg/payment/platform.go @@ -10,6 +10,7 @@ const ( EPay Balance CryptoSaaS + AppleIAP UNSUPPORTED Platform = -1 ) @@ -19,6 +20,8 @@ var platformNames = map[string]Platform{ "AlipayF2F": AlipayF2F, "EPay": EPay, "balance": Balance, + "AppleIAP": AppleIAP, + "apple_iap": AppleIAP, "unsupported": UNSUPPORTED, } @@ -80,5 +83,12 @@ func GetSupportedPlatforms() []types.PlatformInfo { "secret_key": "Secret Key", }, }, + { + Platform: AppleIAP.String(), + PlatformUrl: "https://developer.apple.com/in-app-purchase/", + PlatformFieldDescription: map[string]string{ + "product_ids": "Apple In-App Purchase product ids (merchant.hifastvpn.day${quantity})", + }, + }, } }