Open Twansparant opened 7 years ago
receiptData
contains information for your purchase from what I understand. You'd want to verify the information contained in receiptData
before enabling premium content.
Receipt validations are ideally performed on a server. This allows you to protect your API keys that something like in-app-purchase
would require. Any on-device validation would require you to embed your API keys in your app which is insecure.
I'd highly encourage you to look into a node.js
server. It isn't hard to setup and you can get by with a small free AWS EC2 instance running a daily job to check all your receipts.
rn-nodify
looks interesting but now sure how compatible it is with something as complex as in-app-purchase
.
Hope this helps.
@Twansparant afaik, there is no way of knowing if the user is logged is to the App store. The best option and what I'm doing atm is to verify if the receipt exists before requesting.
You can see my pull request for that: #126
You then check if the receipts exists first, if not: Tell the user that you need to verify the existence of the purchase. Proceed to verify the receipt. If receipt is found, grant access and continue. If receiptData fails, you can then ask the user to purchase/subscribe or restore purchases to continue
@Twansparant you could easily setup an AWS Lambda + API GateWay endpoint that validates the purchases and subscriptions.
You would just call InAppUtils.receiptData
and then call your validation endpoint with receipt data. In your lambda function you can use in-app-purchase
to validate the receipts and tell your app if they are valid, expired, canceled, etc.
This way the user won't get prompted to login all the time if you use InAppUtils.restorePurchases
. You also don't need to manage a server and it will be cheaper.
Hi there,
I'm a bit lost on how to achieve the following workflow:
[ ] When opening my app, check if the currently logged in user (in App Store) has already purchased my in-app purchase by either checking a local storage item and if not present, checking existing receiptData using the
InAppUtils.receiptData
function.[x] Add Get Full App button for purchasing in-app premium content using the
InAppUtils.loadProducts
&InAppUtils.purchaseProduct
functions.[x] Add Restore Purchase button for manually restoring previous in-app purchase using the
InAppUtils.restorePurchases
function.I'm confused what the
receiptData
actually contains? Does it contain ALL receipts from ALL the apps from the logged-in user? Or just the receipts from my app?If I would just use this as a check for the in-app purchase, it will always enable the premium content:
With the
InAppUtils.restorePurchases
function you CAN check if the current purchases contain your in-app purchase, but that requires logging in to your AppStore account everytime/most of the time, so not ideal for step 1 of my workflow.So my question is, how should I validate the receiptData? I don't have a server for my app. I found this module for validating receipts, but I can't get it working yet with
rn-nodify
.Any help is appreciated. Thanks!