dooboolab-community / react-native-iap

In App Purchase module for React Native!
https://react-native-iap.dooboolab.com
MIT License
2.78k stars 637 forks source link

Getting 21002 at time of verifyReceipt of iOS #2805

Closed ViralGroovy closed 1 month ago

ViralGroovy commented 1 month ago

Hello Dev, Hope you are doing well

Description

When I try to verify the Receipt, I get a 21002 error code. Error about The data in the receipt-data property was malformed or the service experienced a temporary issue.

Expected Behavior

Below response get from request subscription and then I am trying to verify receipt Screenshots image

Environment:

ibraheem88 commented 1 month ago

Which Url you are trying to verify receipts? Also your receipts are from sandbox environment or storekit receipts?

ViralGroovy commented 1 month ago

@ibraheem88 I am using RNIap.validateReceiptIos() for verification of storekit receipts.

ibraheem88 commented 1 month ago

Local storekit receipts cannot be verified by sandbox servers. You need to use sandbox receipt to be able to get a valid response from apple server. validateReceiptIos() uses sandbox servers to validate receipt if you pass second argument as true. Sandbox url is: 'https://sandbox.itunes.apple.com/verifyReceipt'

ViralGroovy commented 1 month ago

image

@ibraheem88 I used now sandbox receipts but still getting same response at a time of verification.

ibraheem88 commented 1 month ago

Are you passing true to validateReceiptIos like this: validateReceiptIos( { receiptBody : receiptBody, isTest: true } ) otherwise it will try to use production servers to validate receipt. Which of course will not work with sandbox receipts.

ViralGroovy commented 1 month ago

image image

@ibraheem88 check this now, Now i am getting internal data access error

ibraheem88 commented 1 month ago

receiptBody should be of this format: const receiptBody = { "receipt-data": receipt, "password": "##applesecret", }

ViralGroovy commented 1 month ago

image image

@ibraheem88 Already try this one but still getting 21002

ibraheem88 commented 1 month ago

Confirm that your receipt is from sandbox environment and also check apple secret. You can verify receipt here: Revenue Cat

ViralGroovy commented 1 month ago

@ibraheem88 check image

ibraheem88 commented 1 month ago

You are not getting the receipt the right way I think which method you are using to get receipt. Send the whole snippet

ViralGroovy commented 1 month ago

image image image

@ibraheem88 Check the above snippet

ibraheem88 commented 1 month ago

All I can say is this status code normally shows when you are trying to validate local storekit receipts.

ibraheem88 commented 1 month ago

As far as I know you can only verify sandbox and production receipts.

ViralGroovy commented 1 month ago

@ibraheem88 Now I remove the store kit file from the root file and try to purchase using the sandbox account now the issue is when I try to get a subscription list of products time get an empty array of the subscription list.

This is my integration steps

ibraheem88 commented 1 month ago

This issue is different. You can follow this issue here: getProducts and getSubscriptions returns empty array There can be a number of things that can go wrong.