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

How to revalidate android purchaseToken #206

Closed
ChrisFromCanada opened this issue Aug 23, 2018 · 2 comments
Closed

How to revalidate android purchaseToken #206

ChrisFromCanada opened this issue Aug 23, 2018 · 2 comments

Comments

@ChrisFromCanada
Copy link

ChrisFromCanada commented Aug 23, 2018

I made a routine to recheck all my user receipts so I can deactivate expired subscriptions on a schedule. If there is a better way to detect expired accounts please let me know! I'm unaware of the best practices for checking subscriptions on a schedule.

Problem is if I just send the purchaseToken in to iap.validate it thinks it's an apple receipt and fails.

Obviously I'm doing something wrong.

What I'm doing:

  • Sending android receipts to my server and validating them (data and signature).
  • Taking the purchaseToken that is returned and storing it in my database.
  • Calling iap.validate with the purchase token (probably not the correct thing to do)

I should need packageName, productId and purchaseToken but I can't figure out where/how to use them to get back the purchaseData so I can call isExpired on it.

iap.setup().then( () => {
    iap.validate( PURCHASE_TOKEN ).then( async ( validatedData ) => {
        // never gets here
    } ).catch( async ( _err ) => {
        // fails here
    } );
} ).catch( async ( _err ) => {
} );

How do I revalidate android purchaseTokens for subscriptions?

@voltrue2
Copy link
Owner

The PURCHASE_TOKEN part must be an object that holds a purchased receipt data and a signature.
The object structure is shown here: https://github.com/voltrue2/in-app-purchase#google-play

Cheers

@voltrue2
Copy link
Owner

Closing

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