Microsoft Azure PlayFab logo
    • Multiplayer
    • LiveOps
    • Data & Analytics
    • Add-ons
    • For Any Role

      • Engineer
      • Designer
      • Executive
      • Marketer
    • For Any Stage

      • Build
      • Improve
      • Grow
    • For Any Size

      • Solo
      • Indie
      • AAA
  • Runs on PlayFab
  • Pricing
    • Blog
    • Forums
    • Contact us
  • Sign up
  • Sign in
  • Ask a question
  • Spaces
    • PlayStream
    • Feature Requests
    • Add-on Marketplace
    • Bugs
    • API and SDK Questions
    • General Discussion
    • LiveOps
    • Topics
    • Questions
    • Articles
    • Ideas
    • Users
    • Badges
  • Home /
  • Bugs /
avatar image
Question by NoBloat · Dec 12, 2021 at 03:45 PM · In-Game EconomyPartner Add-ons

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.

Comment

People who like this

0 Show 3
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Made Wang · Dec 13, 2021 at 09:56 AM 0
Share

Is there a more detailed error message?

Does PlayfabApi return an error message?

avatar image NoBloat Made Wang · Dec 13, 2021 at 02:21 PM 0
Share

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
}
avatar image NoBloat Made Wang · Dec 13, 2021 at 02:24 PM 0
Share

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

receipterrorclient.png (46.0 kB)

3 Replies

· Add your reply
  • Sort: 
avatar image
Best Answer

Answer by NoBloat · Dec 14, 2021 at 04:31 PM

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.

Comment
NoBloat

People who like this

1 Show 0 · Share
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image

Answer by Made Wang · Dec 14, 2021 at 07:16 AM

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.

Comment

People who like this

0 Show 0 · Share
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image

Answer by NoBloat · Dec 14, 2021 at 04:37 PM

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.

Comment

People who like this

0 Show 0 · Share
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Navigation

Spaces
  • General Discussion
  • API and SDK Questions
  • Feature Requests
  • PlayStream
  • Bugs
  • Add-on Marketplace
  • LiveOps
  • Follow this Question

    Answers Answers and Comments

    8 People are following this question.

    avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

    Related Questions

    PayPal Payment Redirect 1 Answer

    Steam microtransactions bug. 0 Answers

    How do I remove an add on from a project 1 Answer

    Game Manager 404 on items catalog 1 Answer

    PlayFabClientAPI.RestoreIOSPurchases restore more items than bought ones. 1 Answer

    PlayFab

    • Multiplayer
    • LiveOps
    • Data & Analytics
    • Runs on PlayFab
    • Pricing

    Solutions

    • For Any Role

      • Engineer
      • Designer
      • Executive
      • Marketer
    • For Any Stage

      • Build
      • Improve
      • Grow
    • For Any Size

      • Solo
      • Indie
      • AAA

    Engineers

    • Documentation
    • Quickstarts
    • API Reference
    • SDKs
    • Usage Limits

    Resources

    • Forums
    • Contact us
    • Blog
    • Service Health
    • Terms of Service
    • Attribution

    Follow us

    • Facebook
    • Twitter
    • LinkedIn
    • YouTube
    • Sitemap
    • Contact Microsoft
    • Privacy & cookies
    • Terms of use
    • Trademarks
    • Safety & eco
    • About our ads
    • © Microsoft 2020
    • Anonymous
    • Sign in
    • Create
    • Ask a question
    • Create an article
    • Post an idea
    • Spaces
    • PlayStream
    • Feature Requests
    • Add-on Marketplace
    • Bugs
    • API and SDK Questions
    • General Discussion
    • LiveOps
    • Explore
    • Topics
    • Questions
    • Articles
    • Ideas
    • Users
    • Badges