Use new struct to check status & Remove IAP_ENVIRONMENT

Use a new struct called `HttpStatusResponse` to check the status code returned in the receipt. This is ios-type independent and will redirect the receipt to sandbox if needed.

Following Apple's recommendation, always hit production and then sandbox. There is no more need to specify which environment to hit.
This commit is contained in:
Timothy Lock
2018-01-17 16:02:52 -05:00
parent 12a6e01874
commit 132768c0fe
3 changed files with 38 additions and 45 deletions

View File

@@ -102,7 +102,7 @@ type (
// 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.
// If you get other types or fields from the IAP response, you should use the struct you defined.
IAPResponse struct {
Status int `json:"status"`
Environment string `json:"environment"`
@@ -112,4 +112,10 @@ type (
PendingRenewalInfo []PendingRenewalInfo `json:"pending_renewal_info"`
IsRetryable bool `json:"is-retryable"`
}
// The HttpStatusResponse struct contains the status code returned by the store
// Used as a workaround to detect when to hit the production appstore or sandbox appstore regardless of receipt type
HttpStatusResponse struct {
Status int `json:"status"`
}
)