苹果支付
go get github.com/smartwalle/apple
import github.com/smartwalle/apple
在集成的过程中有遇到问题,欢迎加 QQ 群 564704807 讨论。
支付宝 https://github.com/smartwalle/alipay
PayPal https://github.com/smartwalle/paypal
var summary, info, err = apple.VerifyReceipt(transactionId, receipt)
苹果内购验证支持生产环境和沙箱环境,VerifyReceipt() 函数内部会优先向苹果生产环境进行验证,然后根据获取到的数据判断是否要向沙箱环境进行验证。
可以从 VerifyReceipt() 函数返回的数据中判断该支付所属的环境信息。
var client = apple.NewIdentityClient()
var user, err = client.DecodeToken("从客户端获取到的 IdentityToken")
DecodeToken() 方法只负责对数据进行解析,验证是否为当前应用的用户,需要自行验证该方法返回值 User 对象的 BundleId 属性。
var notification, err = apple.DecodeNotification([]byte(data))
业务服务器提供一个请求方法为 POST 的 HTTP 接口给苹果,苹果会在需要的时候推送一些通知消息到该接口。
var s = gin.Default()
s.POST("/apple", apple)
func apple(c *gin.Context) {
var data, _ = io.ReadAll(c.Request.Body)
var notification, err = apple.DecodeNotification([]byte(data))
// 关于这里如何返回数据参考 https://developer.apple.com/documentation/appstoreservernotifications/responding_to_app_store_server_notifications
// 简单来讲,返回 HTTP Status Code 200 表示我们成功处理该通知
// 如:c.Status(http.StatusOK)
// 返回 HTTP Status Code 50x 或者 40x 表示我们没有成功处理该通知,苹果会在一定时间后重新推送该通知
// 如:c.Status(http.StatusBadRequest)
}
- Look Up Order ID
- Get Refund History
- Get All Subscription Statuses
- Extend a Subscription Renewal Date
- Get Transaction History
- Send Consumption Information
以上接口需要先初始化 apple.Client
var client, _ = apple.New(keyfile, keyId, issuer, bundleId, isProduction)
Creating API Keys to Use With the App Store Server API
This project is licensed under the MIT License.