Skip to content

Commit

Permalink
Merge pull request #223 from richzw/master
Browse files Browse the repository at this point in the history
docs(readme): add GetTransactionInfo sample
  • Loading branch information
takecy authored Jul 1, 2023
2 parents 34a4299 + 17b86f2 commit 321f62e
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,42 @@ func main() {

### In App Store Server API

- GetTransactionInfo

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

- GetTransactionHistory

```go
import(
"github.com/awa/go-iap/appstore/api"
Expand Down

0 comments on commit 321f62e

Please sign in to comment.