Skip to content

Checking if auto renewable subscription is valid.. #80

Description

@Abdullah-Shamhan

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 */ 
    }
)



});

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions