go-iap 通过 AppStore、GooglePlayStore、AmazonAppStore 和 Huawei HMS 验证购买凭证。
go-iap 通过 AppStore、GooglePlayStore、AmazonAppStore 和 Huawei HMS 验证购买凭证。
go-iap 通过 AppStore、GooglePlayStore、Amazon AppStore、HMS 或 MicrosoftStore 验证购买凭证。 当前的 API 文档:
go get github.com/awa/go-iap/appstore
go get github.com/awa/go-iap/playstore
go get github.com/awa/go-iap/amazon
go get github.com/awa/go-iap/hms
go get github.com/awa/go-iap/microsoftstoreimport(
"github.com/awa/go-iap/appstore"
)
func main() {
client := appstore.New()
req := appstore.IAPRequest{
ReceiptData: "your receipt data encoded by base64",
}
resp := &appstore.IAPResponse{}
ctx := context.Background()
err := client.Verify(ctx, req, resp)
}注意: 自 2023 年 6 月 5 日起, verifyReceipt API 已被淘汰。请使用 App Store 服务器 API 代替。
import(
"github.com/awa/go-iap/playstore"
)
func main() {
// You need to prepare a public key for your Android app's in app billing
// at https://console.developers.google.com.
jsonKey, err := ioutil.ReadFile("jsonKey.json")
if err != nil {
log.Fatal(err)
}
client := playstore.New(jsonKey)
ctx := context.Background()
resp, err := client.VerifySubscription(ctx, "package", "subscriptionID", "purchaseToken")
}import(
"github.com/awa/go-iap/amazon"
)
func main() {
client := amazon.New("developerSecret")
ctx := context.Background()
resp, err := client.Verify(ctx, "userID", "receiptID")
}暂无开放 Issues,或尚未同步最近议题。