append new IAP receipt fields

This commit is contained in:
Yingjie Run
2017-07-20 18:20:07 +08:00
parent c46ab73455
commit 2eb7bcf51a
2 changed files with 57 additions and 10 deletions

View File

@@ -1,10 +1,19 @@
package appstore
type (
// https://developer.apple.com/library/content/releasenotes/General/ValidateAppStoreReceipt/Chapters/ValidateRemotely.html
// The IAPRequest type has the request parameter
IAPRequest struct {
ReceiptData string `json:"receipt-data"`
Password string `json:"password,omitempty"`
ReceiptData string `json:"receipt-data"`
Password string `json:"password,omitempty"`
ExcludeOldTransactions bool `json:"exclude_old_transactions,omitempty"`
}
// The ReceiptCreationDate type indicates the date when the app receipt was created.
ReceiptCreationDate struct {
CreationDate string `json:"receipt_creation_date"`
CreationDateMS string `json:"receipt_creation_date_ms"`
CreationDatePST string `json:"receipt_creation_date_pst"`
}
// The RequestDate type indicates the date and time that the request was sent
@@ -48,14 +57,23 @@ type (
ProductID string `json:"product_id"`
TransactionID string `json:"transaction_id"`
OriginalTransactionID string `json:"original_transaction_id"`
IsTrialPeriod string `json:"is_trial_period"`
AppItemID string `json:"app_item_id"`
VersionExternalIdentifier string `json:"version_external_identifier"`
WebOrderLineItemID string `json:"web_order_line_item_id"`
IsTrialPeriod string `json:"is_trial_period"`
SubscriptionExpirationIntent string `json:"expiration_intent"`
SubscriptionRetryFlag string `json:"is_in_billing_retry_period"`
SubscriptionAutoRenewProductID string `json:"auto_renew_product_id"`
SubscriptionAutoRenewStatus string `json:"auto_renew_status"`
SubscriptionPriceConsentStatus string `json:"price_consent_status"`
ExpiresDate
PurchaseDate
OriginalPurchaseDate
ExpiresDate
CancellationDate
CancellationReason string `json:"cancellation_reason"`
}
// The Receipt type has whole data of receipt
@@ -66,22 +84,37 @@ type (
BundleID string `json:"bundle_id"`
ApplicationVersion string `json:"application_version"`
DownloadID int64 `json:"download_id"`
VersionExternalIdentifier int64 `json:"version_external_identifier"`
OriginalApplicationVersion string `json:"original_application_version"`
InApp []InApp `json:"in_app"`
ReceiptCreationDate
RequestDate
OriginalPurchaseDate
}
// A pending renewal may refer to a renewal that is scheduled in the future or a renewal that failed in the past for some reason.
PendingRenewalInfo struct {
SubscriptionExpirationIntent string `json:"expiration_intent"`
SubscriptionAutoRenewProductID string `json:"auto_renew_product_id"`
SubscriptionRetryFlag string `json:"is_in_billing_retry_period"`
SubscriptionAutoRenewStatus string `json:"auto_renew_status"`
SubscriptionPriceConsentStatus string `json:"price_consent_status"`
ProductID string `json:"product_id"`
}
// The IAPResponse type has the response properties
// We defined each field by the current IAP response, but some fields are not mentioned
// in the following Apple's document;
// https://developer.apple.com/library/ios/releasenotes/General/ValidateAppStoreReceipt/Chapters/ReceiptFields.html
// If you get other types or fileds from the IAP response, you should use the struct you defined.
IAPResponse struct {
Status int `json:"status"`
Environment string `json:"environment"`
Receipt Receipt `json:"receipt"`
LatestReceiptInfo []InApp `json:"latest_receipt_info"`
LatestReceipt string `json:"latest_receipt"`
Status int `json:"status"`
Environment string `json:"environment"`
Receipt Receipt `json:"receipt"`
LatestReceiptInfo []InApp `json:"latest_receipt_info"`
LatestReceipt string `json:"latest_receipt"`
LatestExpiredReceiptInfo InApp `json:"latest_expired_receipt_info"`
PendingRenewalInfo []PendingRenewalInfo `json:"pending_renewal_info"`
IsRetryable bool `json:"is-retryable"`
}
)