Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

validateReceiptIos always returns false #237

Closed
fabianunger opened this issue Aug 15, 2018 · 11 comments
Closed

validateReceiptIos always returns false #237

fabianunger opened this issue Aug 15, 2018 · 11 comments
Labels
1️⃣ good first issue Good for newcomers 🙏 help wanted Extra attention is needed 📱 iOS Related to iOS

Comments

@fabianunger
Copy link

Version of react-native-iap

2.0.0-alpha3
(I tried 1.1.5 as well, same issue)

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

iOS

Expected behavior

validateReceiptIos returns 0/1/true for valid receipts

Actual behavior

validateReceiptIos always returns false

Tested environment (Emulator? Real Device?)

Real device, sandbox app store

Steps to reproduce the behavior

I am able to make auto renewable subscription purchases successfully, and receive a transaction receipt. When I try to validate this on iOS using validateReceiptIos(receiptBody, true, 55) I always get returned false.

If I log JSON.stringify(res) I get:
{"status":21004, "environment":"Sandbox"}

There was a similar issue at #190

@LinusU
Copy link
Member

LinusU commented Aug 15, 2018

At which line are you inserting the log at? 🤔

also, what version of React Native are you running?

@hyochan hyochan added 🐛 bug Something isn't working 🙏 help wanted Extra attention is needed 📱 iOS Related to iOS labels Aug 15, 2018
@hyochan
Copy link
Member

hyochan commented Aug 15, 2018

@fabianunger Strange. Should be fixed in #190. Could you share some codes?

@fabianunger
Copy link
Author

fabianunger commented Aug 16, 2018

"react": "^16.3.2"
"react-native": "^0.55.3"

validate = async (product) => {
   try {
     console.log(product);

     const receiptBody = {
       'receipt-data': product.transactionReceipt,
     };
     console.log(receiptBody);

     const result = await RNIap.validateReceiptIos(receiptBody, true, 55);
     console.log(result);

   } catch(err) {
     console.warn(err.code, err.message);
     Alert.alert(err.message);
   }

 };

@LinusU
Copy link
Member

LinusU commented Aug 16, 2018

@fabianunger Could you try out this version and see if it gives you a more detailed error message?

npm install LinusU/react-native-iap#ios-validate

@fabianunger
Copy link
Author

fabianunger commented Aug 16, 2018

@LinusU @dooboolab
I just added the shared secret in the receiptBody and now it seams to work out.
Maybe I just missed it somewhere in the docs? Or is that not the way it is supposed to happen?

  const receiptBody = {
        'receipt-data': product.transactionReceipt,
        'password': '*********'
      };

(still using version 2.0.0-alpha3)

@fabianunger
Copy link
Author

@LinusU
I tested it also with your version: Same outcome.
As a response I get {"status":21004, "environment":"Sandbox"}.

Works by adding the shared secret as the 'password' within the receiptBody. In general: Is this the regular way anyway?

@hyochan
Copy link
Member

hyochan commented Aug 16, 2018

@fabianunger You've done it right. For more information ref here. Will be good to update the doc tough.

@venku122
Copy link

What is the shared secret and where can I find it?

@khorark
Copy link
Contributor

khorark commented Aug 26, 2019

What is the shared secret and where can I find it?

https://www.appypie.com/faqs/how-can-i-get-shared-secret-key-for-in-app-purchase

@imanshu1
Copy link

Validate Reciept in Production Mode returning {status: 21007} , can anyone help mw with this.

Thanks in advance

@mrcwerfar
Copy link

Look here:

https://developer.apple.com/library/archive/releasenotes/General/ValidateAppStoreReceipt/Chapters/ValidateRemotely.html

"21007: This receipt is from the test environment, but it was sent to the production environment for verification. Send it to the test environment instead."

use this address for test environment verification: https://sandbox.itunes.apple.com/verifyReceipt
 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1️⃣ good first issue Good for newcomers 🙏 help wanted Extra attention is needed 📱 iOS Related to iOS
Projects
None yet
Development

No branches or pull requests

7 participants