feat(支付): 添加Apple应用内支付支持
All checks were successful
Build docker and publish / build (20.15.1) (push) Successful in 6m38s
All checks were successful
Build docker and publish / build (20.15.1) (push) Successful in 6m38s
- 在CheckoutOrderResponse结构中添加product_ids字段用于存储Apple IAP产品ID - 新增AppleIAP支付平台常量及映射 - 实现Apple IAP支付处理逻辑,生成对应的产品ID
This commit is contained in:
parent
0e493caf16
commit
d7b56f3edc
@ -3,6 +3,7 @@ package portal
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
"math"
|
"math"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@ -74,6 +75,13 @@ func (l *PurchaseCheckoutLogic) PurchaseCheckout(req *types.CheckoutOrderRequest
|
|||||||
}
|
}
|
||||||
// Route to appropriate payment handler based on payment platform
|
// Route to appropriate payment handler based on payment platform
|
||||||
switch paymentPlatform.ParsePlatform(orderInfo.Method) {
|
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:
|
case paymentPlatform.EPay:
|
||||||
// Process EPay payment - generates payment URL for redirect
|
// Process EPay payment - generates payment URL for redirect
|
||||||
url, err := l.epayPayment(paymentConfig, orderInfo, req.ReturnUrl)
|
url, err := l.epayPayment(paymentConfig, orderInfo, req.ReturnUrl)
|
||||||
|
|||||||
@ -241,6 +241,7 @@ type CheckoutOrderResponse struct {
|
|||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
CheckoutUrl string `json:"checkout_url,omitempty"`
|
CheckoutUrl string `json:"checkout_url,omitempty"`
|
||||||
Stripe *StripePayment `json:"stripe,omitempty"`
|
Stripe *StripePayment `json:"stripe,omitempty"`
|
||||||
|
ProductIds []string `json:"product_ids,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type CloseOrderRequest struct {
|
type CloseOrderRequest struct {
|
||||||
|
|||||||
@ -10,6 +10,7 @@ const (
|
|||||||
EPay
|
EPay
|
||||||
Balance
|
Balance
|
||||||
CryptoSaaS
|
CryptoSaaS
|
||||||
|
AppleIAP
|
||||||
UNSUPPORTED Platform = -1
|
UNSUPPORTED Platform = -1
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -19,6 +20,8 @@ var platformNames = map[string]Platform{
|
|||||||
"AlipayF2F": AlipayF2F,
|
"AlipayF2F": AlipayF2F,
|
||||||
"EPay": EPay,
|
"EPay": EPay,
|
||||||
"balance": Balance,
|
"balance": Balance,
|
||||||
|
"AppleIAP": AppleIAP,
|
||||||
|
"apple_iap": AppleIAP,
|
||||||
"unsupported": UNSUPPORTED,
|
"unsupported": UNSUPPORTED,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,5 +83,12 @@ func GetSupportedPlatforms() []types.PlatformInfo {
|
|||||||
"secret_key": "Secret Key",
|
"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})",
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user