实现Apple应用内购支付功能,包括: 1. 新增AppleIAP和ApplePay支付平台枚举 2. 添加IAP验证接口/v1/public/iap/verify处理初购验证 3. 实现Apple服务器通知处理逻辑/v1/iap/notifications 4. 新增JWS验签和JWKS公钥缓存功能 5. 复用现有订单系统处理IAP支付订单 相关文档已更新,包含接入方案和实现细节
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
package notify
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/perfect-panel/server/internal/logic/notify"
|
||||
"github.com/perfect-panel/server/internal/svc"
|
||||
"github.com/perfect-panel/server/pkg/result"
|
||||
)
|
||||
|
||||
// AppleIAPNotifyHandler 处理 Apple Server Notifications v2
|
||||
// 参数: 原始 HTTP 请求体
|
||||
// 返回: 处理结果(空体 200)
|
||||
func AppleIAPNotifyHandler(svcCtx *svc.ServiceContext) func(c *gin.Context) {
|
||||
return func(c *gin.Context) {
|
||||
l := notify.NewAppleIAPNotifyLogic(c.Request.Context(), svcCtx)
|
||||
err := l.Handle(c.Request)
|
||||
result.HttpResult(c, gin.H{"success": err == nil}, err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ func PaymentNotifyHandler(svcCtx *svc.ServiceContext) func(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
c.String(http.StatusOK, "%s", "success")
|
||||
case payment.Stripe:
|
||||
case payment.Stripe, payment.ApplePay:
|
||||
l := notify.NewStripeNotifyLogic(c.Request.Context(), svcCtx)
|
||||
if err := l.StripeNotify(c.Request, c.Writer); err != nil {
|
||||
result.HttpResult(c, nil, err)
|
||||
|
||||
Reference in New Issue
Block a user