question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Apple verify receipt still returns 21002

See original GitHub issue

Version of react-native-iap

4.6.1

Version of react-native

0.63.2

Platforms you faced the error (IOS or Android or both?)

iOS

Expected behavior

Getting the JSON response from Apple VerifyReceipt service

Actual behavior

Getting a status 21002 error

Tested environment (Emulator? Real Device?)

Both

Steps to reproduce the behavior

Here’s my React Native code :

if (Platform.OS === 'ios') {
  console.log('PURCHASE IOS IS DONE');
  console.log('Transaction Receipt', JSON.stringify({ transaction: purchase }));
  RNIap.getReceiptIOS().then(async result => {
    console.log('Purchase Receipt', result);
  });
}

It returns me this purchaseReceipt :

MIAGCSqGSIb3DQEHAqCAMIACAQExDzANBglghkgBZQMEAgEFADCABgkqhkiG9w0BBwGggCSABIIBbTGCAWkwDwIBAAIBAQQHDAVYY29kZTALAgEBAgEBBAMCAQAwFQIBAgIBAQQNDAtuZWFydHJpcC5pbzAPAgEDAgEBBAcMBTIuMS4yMBACAQQCAQEECOG5uScNAAAAMBwCAQUCAQEEFELyZOL0JTlhofkxQmPT76dFJFO6MAoCAQgCAQEEAhYAMCICAQwCAQEEGhYYMjAyMC0wOS0yM1QxNjowNzozOCswMjAwMIGcAgERAgEBBIGTMYGQMAwCAgalAgEBBAMCAQEwGgICBqYCAQEEEQwPcHJlbWl1bV9tZW5zdWVsMAwCAganAgEBBAMMATAwIwICBqgCAQEEGhYYMjAyMC0wOS0yMlQxMTo0NTo0OSswMjAwMCMCAgasAgEBBBoWGDIwMjAtMTAtMjJUMTE6NDU6NDkrMDIwMDAMAgIGtwIBAQQDAgEAMCICARUCAQEEGhYYNDAwMS0wMS0wMVQwMTowMDowMCswMTAwAAAAAAAAoIIDeDCCA3QwggJcoAMCAQICAQEwDQYJKoZIhvcNAQELBQAwXzERMA8GA1UEAwwIU3RvcmVLaXQxETAPBgN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BldDBUvig/1icjXKx0e7CuRBac9TzGCAY8wggGLAgEBMGQwXzERMA8GA1UEAwwIU3RvcmVLaXQxETAPBgNVBAoMCFN0b3JlS2l0MREwDwYDVQQLDAhTdG9yZUtpdDELMAkGA1UEBhMCVVMxFzAVBgkqhkiG9w0BCQEWCFN0b3JlS2l0AgEBMA0GCWCGSAFlAwQCAQUAMA0GCSqGSIb3DQEBCwUABIIBAGWKp8uaHfNBrVrXEqxS3fjsskoTHPKdTi3bXsGg1X4xEeSh5HWuYTeQ9wZMjq/qJwVz4rtJUGP6Cmk7wvPwNWAM772O+D8PeRjVGAwmzRyllslzDh/m05eTNSKBRLT/cKLs+ygU441L12Nh8JG19YB4HCoE6ccrqh+TBKIcu+StapzqUy/RRpTTcLIQjtAzm90Fr7/Ku1ZSqbkHSMNG5UoqTSOgx8YGYWOObM+BDWY55xcLUKYY7IuhUyu5LzjL6zcPjrTulIWPWtU14Id8aDx91dqriT1bQycqKJ1YlcpIjF7JdtQul35IWBErzQ1Hp01rWkvDKNOTWqIo60SVUysAAAAAAAA=

When I’m trying to send it through postman or any other way, the Apple response is forever :

{ "status": 21002 }

And yes I add the password field with my shared secret key to the request.

I know it means that the current receipt is mal-formatted or something but I don’t know what do to with it as it seems already to be base64 encoded.

Any idea ?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:4
  • Comments:15 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
borealescommented, Dec 14, 2020

The validation of receipt doesn’t work on Simulator and EITHER on real device. You must test it with a download from Testflight and then running your app on a real device. This is how I finally achieved this.

1reaction
Kladislavcommented, Nov 11, 2020

fixed by replace axios to native fetch

Read more comments on GitHub >

github_iconTop Results From Across the Web

Status code 21002 whenever I try t… | Apple Developer Forums
Hello, I'm working on non-consumable IAP's and when I try to validate a receipt, I always get this status code 21002, which means...
Read more >
IOS receipt validation error 21002 - Stack Overflow
Code 21002 means that the JSON you are sending to apple which has your shared secret and your receipt data is "misformed" or...
Read more >
iOS : Apple IAP receipt verification returns code 21002
iOS : Apple IAP receipt verification returns code 21002 [ Beautify Your Computer : https://www.hows.tech/p/recommended.html ] iOS : Apple ...
Read more >
[Solved]-Apple verify receipt still returns 21002 - appsloveworld
Related Query · Apple IAP receipt verification returns code 21002 · How to verify Apple IAP receipt using php? · Validating receipt for...
Read more >
The Ultimate Handbook On App-Store Receipt Validation
status ; 200, 21000, The App Store request was not made using the HTTP POST method ; 200, 21001, No longer sent by...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found