From 9a0e9c6e3e1e849e59450548144eaf492b5a0a0d Mon Sep 17 00:00:00 2001 From: Wei Zang Date: Sat, 1 Jul 2023 09:59:18 +0800 Subject: [PATCH 1/2] docs(readme): add GetTransactionInfo sample --- README.md | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/README.md b/README.md index 88f0416..5d300c2 100644 --- a/README.md +++ b/README.md @@ -106,6 +106,38 @@ import( "github.com/awa/go-iap/appstore/api" ) +// For generate key file and download it, please refer to https://developer.apple.com/documentation/appstoreserverapi/creating_api_keys_to_use_with_the_app_store_server_api +const ACCOUNTPRIVATEKEY = ` + -----BEGIN PRIVATE KEY----- + FAKEACCOUNTKEYBASE64FORMAT + -----END PRIVATE KEY----- + ` +func main() { + c := &api.StoreConfig{ + KeyContent: []byte(ACCOUNTPRIVATEKEY), // Loads a .p8 certificate + KeyID: "FAKEKEYID", // Your private key ID from App Store Connect (Ex: 2X9R4HXF34) + BundleID: "fake.bundle.id", // Your app’s bundle ID + Issuer: "xxxxx-xx-xx-xx-xxxxxxxxxx",// Your issuer ID from the Keys page in App Store Connect (Ex: "57246542-96fe-1a63-e053-0824d011072a") + Sandbox: false, // default is Production + } + transactionId := "FAKETRANSACTIONID" + a := api.NewStoreClient(c) + ctx := context.Background() + response, err := a.GetTransactionInfo(ctx, transactionId) + + transantion, err := a.ParseSignedTransaction(response.SignedTransactionInfo) + + if transaction.TransactionId == transactionId { + // the transaction is valid + } +} +``` + +```go +import( + "github.com/awa/go-iap/appstore/api" +) + // For generate key file and download it, please refer to https://developer.apple.com/documentation/appstoreserverapi/creating_api_keys_to_use_with_the_app_store_server_api const ACCOUNTPRIVATEKEY = ` -----BEGIN PRIVATE KEY----- From 17b86f2218f02d6c6b06cc6c7f6718dbe7af0361 Mon Sep 17 00:00:00 2001 From: Wei Zang Date: Sat, 1 Jul 2023 10:06:01 +0800 Subject: [PATCH 2/2] docs(readme): update app store server api to readme --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 5d300c2..7ab748c 100644 --- a/README.md +++ b/README.md @@ -101,6 +101,8 @@ func main() { ### In App Store Server API +- GetTransactionInfo + ```go import( "github.com/awa/go-iap/appstore/api" @@ -133,6 +135,8 @@ func main() { } ``` +- GetTransactionHistory + ```go import( "github.com/awa/go-iap/appstore/api"