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

Checking if auto renewable subscription is valid.. #80

Open
Abdullah-Shamhan opened this issue Aug 30, 2020 · 1 comment
Open

Checking if auto renewable subscription is valid.. #80

Abdullah-Shamhan opened this issue Aug 30, 2020 · 1 comment

Comments

@Abdullah-Shamhan
Copy link

Abdullah-Shamhan commented Aug 30, 2020

Thank you for this library, but i would like to ask something since it's my first time implementing auto renewable subscription..

So now after the user purchase the subscription i should send the receipt to my backend and validate it, and then if it's valid i should store the receipt and the expiration date in my db, and since i have a corn job that runs daily i can check if the subscription is expired, and if it's i can send the receipt again to check if it's renewed or not, is that right? and if it returns an error meaning that it's not valid anymore?

app.post('/receipt-validation' , (request , response) => {

  const platform = request.body.platform;
  const userId = request.body.userId;
  const receipt = request.body.platform;

  const payment = {
    receipt: receipt, // always required
    productId: 'com.shamhandev.snaplearn',
    packageName: 'com.shamhandev.snaplearn',
    excludeOldTransactions: true, // ios
    secret: 'password',      
    subscription: true,	// optional, if google play subscription
    keyObject: {}, // required, if google
  };


  iap.verifyPayment(platform, payment)
  .then(
    res => {	
       //Updating subscription status in db
    },
    err => {
        /* your code */ 
    }
)



});

@justinpage
Copy link
Contributor

@Abdullah-Shamhan You have the right idea. Our service followed much of what you proposed.

The only improvement I would suggest is to look into real-time notifications from app stores that offer it. Cancellations, renewals, or even upgrades/downgrades, are all events you'll want to capture in real-time. The reason for this is keeping your service up-to-date with the app store.

Let me know if you have any questions since in-app purchases is a world in itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants