Craig-Ronald / capacitor-subscriptions

11 stars 3 forks source link

server verification example #7

Closed ahoyahoy closed 6 months ago

ahoyahoy commented 6 months ago

Hi, thanks for the plugin I'm missing a description or a small example of how to make server side verification.

CraigRonald555 commented 6 months ago

Server side verification is kind of out-of-scope for this project however there should be resources available across the internet on best practices for server side verification.

As automatic verification is already set up for Apple devices, you just have to make a server-side call to the Google Billing API with your packageName, productId and purchaseToken.

You'll find information on how to setup a service account to use for server-side calls to the Billing API here: https://developers.google.com/android-publisher/getting_started

Once you've done that, you'll have to set up a endpoint on a server which receives the necessary parameters and makes a call to:

https://androidpublisher.googleapis.com/androidpublisher/v3/applications/{packageName}/purchases/products/{productId}/tokens/{token}

For more infomation on the Billing call, please see here: https://developers.google.com/android-publisher/api-ref/rest/v3/purchases.products/get

I would recommend making an invocable lambda endpoint and directly calling it from your app with the required parameters then returning the result to your app.

Hopefully this helps. Thanks.