Closed alexisconsuegra closed 4 years ago
Hey @alexisconsuegra , yes, this plugin supports subscriptions. There is no specifics to subscriptions on the app side. The only additional thing you need to do is send the store receipt to you backend so you can validate with google/apple the subscription validity/expiration.
Thanks @PeterStaev How can the store receipt be validated? Any sample code in JavaScript is appreciated. also sorry for this question bit what the the javascript code for: import { Transaction, TransactionState } from "nativescript-purchase/transaction"; Thanks again.
@alexisconsuegra , you can search over the internet how to validate the store receipts for sample code, as this largely depends on what backend server are you using (.NET/Node.js/etc).
For the JS code it should be something like this:
var Transaction = require("nativescript-purchase/transaction").Transaction;
var TransactionState = require("nativescript-purchase/transaction").TransactionState ;
@PeterStaev, Thanks a lot. I certainly will do that although I still think something is missing. I hope you can help me understand. The workflow as I understand it goes:
Sorry I am still so new to this. Thanks for your help.
You dont store the receipt, as it changes. Every time you need to check if the user has access to your subscription content, you send the receipt to your backend and it validates it and get's all the info (if it is renewed, if it cancelled, etc.)
I must be missing something. You said in regards to validate the subscription "largely depends on what backend server are you using (.NET/Node.js/etc)." None of those backend servers communicate with Apple/Google store. Isn't the plugin the mean to interface with the store? You can store the receipt (having subscription terms/length etc) when it was purchased in some sort of backend. Then you can check if it expires. But you will never know with out asking the store if it was ever renewed.
The plugin communicates with the stores so that you receive the receipt. This receipt you must send to you backend servers to validate with the Apple/Google servers. Both Apple & Google recommend server to server validation of the store receipts as it is more secure than validating the receipt on-device.
No further response so closing this one for now.
Hello, I would like to know if the plug in already handles subscriptions. Could you provide a sample in plain JavaScript code? Thanks