question

nobloat avatar image
nobloat asked

App Store iOS Receipt Validation - Error Code 21008 (production receipt sent to sandbox URL)

Has anyone dealt with iOS App Store receipt validation status code 21008 ("This receipt is from the production environment, but it was sent to the test environment for verification")? My title went live on iOS yesterday, but receipts are incorrectly being validated against the sandbox URL instead of the production URL.

When I manually send a HTTP request with the ReceiptContent of my player_receipt_validation to the production URL, it succeeds (try here https://reqbin.com/zlfevelb), and sending to the sandbox URL returns a 21008 (try here https://reqbin.com/smabpb45). I was under the impression that PlayFab attempts to validate against both URLs (https://community.playfab.com/questions/124/205469588-Validation-problems-with-iTunes-receipts.html), am I missing something here?

The PaymentProvider of my player_receipt_validation event is also "iTunes Sandbox" even in production FYI.

In-Game EconomyPartner Add-ons
3 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Made Wang avatar image Made Wang commented ·

Is there a more detailed error message?

Does PlayfabApi return an error message?

0 Likes 0 ·
nobloat avatar image nobloat Made Wang commented ·

Here's the full player_receipt_validation event from PlayFab for the receipt used in the reqbin examples above:

{
    "PlayFabEnvironment": {
        "Application": "mainserver",
        "Vertical": "master",
        "Commit": "996e2a8",
        "Cloud": "main"
    },
    "EventNamespace": "com.playfab",
    "EntityType": "player",
    "SourceType": "BackEnd",
    "Timestamp": "2021-12-12T02:44:53.5483253Z",
    "EventName": "player_receipt_validation",
    "EntityId": "49E9C257F1782C7E",
    "EventId": "654acae7af2c4f3698fbb077bc2d6a6a",
    "TitleId": "3379A",
    "Source": "PlayFab",
    "PaymentProvider": "iTunes Sandbox",
    "Error": "InvalidEnvironmentForReceipt",
    "PaymentType": "ReceiptValidation",
    "ReceiptContent": "[see reqbin examples for ReceiptContent]",
    "Valid": false
}
0 Likes 0 ·
nobloat avatar image nobloat Made Wang commented ·

And here's the PlayFabError printed out with error.GenerateErrorReport() on the client side:

0 Likes 0 ·
nobloat avatar image
nobloat answered

Resolved this issue by removing then re-adding the Apple Partner Add-On in Game Manager.

I found that I had also recently started getting 21003 ("The receipt could not be authenticated") errors when validating sandbox receipts, while also getting 21008 errors ("This receipt is from the production environment, but it was sent to the test environment for verification") when validating production receipts. I began receiving 21003 errors soon after my iOS app went live on the App Store.

For reference, here's the Apple dev page on receipt validation status/return codes.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Made Wang avatar image
Made Wang answered

Refer to InvalidEnvironmentForReceipt error on Live iOS game - Playfab Community, as Brendan said, Apple returned that error for both sandbox and prod.

I don't know much about iOS development, maybe you can refer to objective c - iOS In-app purchase verification - Stack Overflow to manually modify the URL.

I think you should go to the iOS development community for professional support.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

nobloat avatar image
nobloat answered

Here's a transcript of the conversation I had with Brendan on the Discord. Should be helpful for anyone dealing with iOS receipt validation issues.

-----------------------------------------------------------

Me: [see my original post in this thread]

Brendan: We do try both, actually. What you're seeing happens every now and then (thankfully, occurrences have been rare, historically) - specifically, it's due to Apple's service incorrectly returning an error on the call to their production service. If you wait and re-try later, you should be fine.

Me: Good to know, thanks Brendan. In your experience, have these errors been related to titles recently going live on the App Store? All of my attempts were made within 24hrs of going live and all failed, so I disabled IAPs for the time being. Now that it's been 48hrs I'll try again and see what the success rate is.

Brendan: That doesn't sound like what we've seen in the past. And if it was failing that way for multiple titles, we'd definitely be hearing about it. What happens when you take one of the receipts and try calling the Apple verification endpoints directly?

Me: directly sending the receipts to the production endpoint is successful, you can see my HTTP reqbin requests in my post here: https://community.playfab.com/questions/58412/app-store-ios-receipt-validation-error-code-21008.html

Brendan: Then it should work when calling our endpoint. Can you try making the call using Postman?

Me: That doesn't make any sense. There's no difference between the call coming from Postman vs coming from your client. The same receipt should have the same result.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.