Documentation ¶
Index ¶
- Constants
- Variables
- type Cert
- type HistoryResponse
- type JWSDecodedHeader
- type JWSRenewalInfoDecodedPayload
- type JWSTransaction
- type LastTransactionsItem
- type OrderLookupResponse
- type RefundLookupResponse
- type StatusResponse
- type StoreClient
- func (a *StoreClient) Do(method string, url string, body io.Reader) (int, []byte, error)
- func (a *StoreClient) GetALLSubscriptionStatuses(originalTransactionId string) (rsp *StatusResponse, err error)
- func (a *StoreClient) GetRefundHistory(originalTransactionId string) (responses []*RefundLookupResponse, err error)
- func (a *StoreClient) GetTransactionHistory(originalTransactionId string) (responses []*HistoryResponse, err error)
- func (a *StoreClient) LookupOrderID(invoiceOrderId string) (rsp *OrderLookupResponse, err error)
- func (a *StoreClient) ParseSignedTransactions(transactions []string) ([]*JWSTransaction, error)
- type SubscriptionGroupIdentifierItem
- type Token
Constants ¶
const ( HostSandBox = "https://api.storekit-sandbox.itunes.apple.com" HostProduction = "https://api.storekit.itunes.apple.com" PathLookUp = "/inApps/v1/lookup/{orderId}" PathTransactionHistory = "/inApps/v1/history/{originalTransactionId}" PathRefundHistory = "/inApps/v2/refund/lookup/{originalTransactionId}" PathGetALLSubscriptionStatus = "/inApps/v1/subscriptions/{originalTransactionId}" )
Variables ¶
var ( ErrAuthKeyInvalidPem = errors.New("token: AuthKey must be a valid .p8 PEM file") ErrAuthKeyInvalidType = errors.New("token: AuthKey must be of type ecdsa.PrivateKey") )
Authorize Tokens For App Store Server API Request Doc: https://developer.apple.com/documentation/appstoreserverapi/generating_tokens_for_api_requests
Functions ¶
This section is empty.
Types ¶
type HistoryResponse ¶
type HistoryResponse struct { AppAppleId int `json:"appAppleId"` BundleId string `json:"bundleId"` Environment string `json:"environment"` HasMore bool `json:"hasMore"` Revision string `json:"revision"` SignedTransactions []string `json:"signedTransactions"` }
HistoryResponse https://developer.apple.com/documentation/appstoreserverapi/historyresponse
type JWSDecodedHeader ¶
type JWSDecodedHeader struct { Alg string `json:"alg,omitempty"` Kid string `json:"kid,omitempty"` X5C []string `json:"x5c,omitempty"` }
JWSDecodedHeader https://developer.apple.com/documentation/appstoreserverapi/jwsdecodedheader
type JWSRenewalInfoDecodedPayload ¶
type JWSRenewalInfoDecodedPayload struct { }
type JWSTransaction ¶
type JWSTransaction struct { TransactionID string `json:"transactionId,omitempty"` OriginalTransactionId string `json:"originalTransactionId,omitempty"` WebOrderLineItemId string `json:"webOrderLineItemId,omitempty"` BundleID string `json:"bundleId,omitempty"` ProductID string `json:"productId,omitempty"` SubscriptionGroupIdentifier string `json:"subscriptionGroupIdentifier,omitempty"` PurchaseDate int64 `json:"purchaseDate,omitempty"` OriginalPurchaseDate int64 `json:"originalPurchaseDate,omitempty"` ExpiresDate int64 `json:"expiresDate,omitempty"` Quantity int64 `json:"quantity,omitempty"` Type string `json:"type,omitempty"` AppAccountToken string `json:"appAccountToken,omitempty"` InAppOwnershipType string `json:"inAppOwnershipType,omitempty"` SignedDate int64 `json:"signedDate,omitempty"` OfferType int64 `json:"offerType,omitempty"` OfferIdentifier string `json:"offerIdentifier,omitempty"` }
JWSTransaction https://developer.apple.com/documentation/appstoreserverapi/jwstransaction
func (JWSTransaction) Valid ¶
func (J JWSTransaction) Valid() error
type LastTransactionsItem ¶
type OrderLookupResponse ¶
type OrderLookupResponse struct { Status int `json:"status"` SignedTransactions []string `json:"signedTransactions"` }
OrderLookupResponse https://developer.apple.com/documentation/appstoreserverapi/orderlookupresponse
type RefundLookupResponse ¶
type RefundLookupResponse struct { HasMore bool `json:"hasMore"` Revision string `json:"revision"` SignedTransactions []string `json:"signedTransactions"` }
RefundLookupResponse https://developer.apple.com/documentation/appstoreserverapi/refundlookupresponse
type StatusResponse ¶
type StatusResponse struct { Environment string `json:"environment"` AppAppleId int `json:"appAppleId"` BundleId string `json:"bundleId"` Data []SubscriptionGroupIdentifierItem `json:"data"` }
StatusResponse https://developer.apple.com/documentation/appstoreserverapi/get_all_subscription_statuses
type StoreClient ¶
type StoreClient struct { Token *Token // contains filtered or unexported fields }
func NewStoreClient ¶
func NewStoreClient(token *Token) *StoreClient
NewStoreClient create appstore server api client
func (*StoreClient) Do ¶
Per doc: https://developer.apple.com/documentation/appstoreserverapi#topics
func (*StoreClient) GetALLSubscriptionStatuses ¶
func (a *StoreClient) GetALLSubscriptionStatuses(originalTransactionId string) (rsp *StatusResponse, err error)
GetALLSubscriptionStatuses https://developer.apple.com/documentation/appstoreserverapi/get_all_subscription_statuses
func (*StoreClient) GetRefundHistory ¶
func (a *StoreClient) GetRefundHistory(originalTransactionId string) (responses []*RefundLookupResponse, err error)
GetRefundHistory https://developer.apple.com/documentation/appstoreserverapi/get_refund_history
func (*StoreClient) GetTransactionHistory ¶
func (a *StoreClient) GetTransactionHistory(originalTransactionId string) (responses []*HistoryResponse, err error)
GetTransactionHistory https://developer.apple.com/documentation/appstoreserverapi/get_transaction_history
func (*StoreClient) LookupOrderID ¶
func (a *StoreClient) LookupOrderID(invoiceOrderId string) (rsp *OrderLookupResponse, err error)
LookupOrderID https://developer.apple.com/documentation/appstoreserverapi/look_up_order_id
func (*StoreClient) ParseSignedTransactions ¶
func (a *StoreClient) ParseSignedTransactions(transactions []string) ([]*JWSTransaction, error)
type SubscriptionGroupIdentifierItem ¶
type SubscriptionGroupIdentifierItem struct { SubscriptionGroupIdentifier string `json:"subscriptionGroupIdentifier"` LastTransactions []LastTransactionsItem `json:"lastTransactions"` }
type Token ¶
type Token struct { sync.Mutex KeyContent []byte // Loads a .p8 certificate KeyID string // Your private key ID from App Store Connect (Ex: 2X9R4HXF34) BundleID string // Your app’s bundle ID Issuer string // Your issuer ID from the Keys page in App Store Connect (Ex: "57246542-96fe-1a63-e053-0824d011072a") Sandbox bool // default is Production // internal variables AuthKey *ecdsa.PrivateKey // .p8 private key ExpiredAt int64 // The token’s expiration time, in UNIX time. Tokens that expire more than 60 minutes after the time in iat are not valid (Ex: 1623086400) Bearer string // Authorized bearer token }
Token represents an Apple Provider Authentication Token (JSON Web Token).
func (*Token) GenerateIfExpired ¶
GenerateIfExpired checks to see if the token is about to expire and generates a new token.