GithubHelp home page GithubHelp logo

apple's Introduction

苹果支付

鸣谢

jetbrains.svg

安装

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)
}

其它接口

以上接口需要先初始化 apple.Client

var client, _ = apple.New(keyfile, keyId, issuer, bundleId, isProduction)

关于 keyfile, keyId, issuer 如何获取?

Creating API Keys to Use With the App Store Server API

License

This project is licensed under the MIT License.

apple's People

Contributors

smartwalle avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.