Backendless Support
 
Waiting for user's response

Is there any way to validate google play transaction with REST?

I want to make transactions and validate them through backendless. How can I do that?

Leave a Comment

Comments (6)

photo
1

I found this article but it only works with Java SDK

photo
1

Hi Timur,

I am still checking if there is REST API. Out of curiosity, could you please describe why the implementation in our SDK for Android would not work for you?

Regards,

Mark

photo
1

Hello! I don't want to implement any additional sdks in my project. They makes app bigger and slower in some way

photo
photo
1

Hi Timur,

Sure there is a REST API.

Here are the routes for v4:

  1. Validate Purchase: GET /<app_id>/<rest_api_key>/commerce/googleplay/validate/<package_name>/inapp/<product_id>/purchases/<token>
  2. Get Subscription Status: GET /<app_id>/<rest_api_key>/commerce/googleplay/<package_name>/subscription/<subscription_id>/purchases/<token>
  3. Cancel Subscription: POST /<app_id>/<rest_api_key>/commerce/googleplay/<package_name>/subscription/<subscription_id>/purchases/<token>/cancel

And for v3:

  1. Validate Purchase: GET /<version_name>/commerce/googleplay/validate/<package_name>/inapp/<product_id>/purchases/<token>
  2. Get Subscription Status: GET /<version_name>/commerce/googleplay/<package_name>/subscription/<subscription_id>/purchases/<token>
  3. Cancel Subscription: POST /<version_name>/commerce/googleplay/<package_name>/subscription/<subscription_id>/purchases/<token>/cancel

photo
1

Thanks! But where can I find the explanation of mechanism "under the hood"? For example, I want to check any in-app purchases though Backenless. After payment I want to increase some value in table. What should I do?

photo
photo
2

Hello,

call

  1. Validate Purchase: GET /<app_id>/<rest_api_key>/commerce/googleplay/validate/<package_name>/inapp/<product_id>/purchases/<token>
  2. Get Subscription Status: GET /<app_id>/<rest_api_key>/commerce/googleplay/<package_name>/subscription/<subscription_id>/purchases/<token>

the response will be:

  1. { "kind": "androidpublisher#productPurchase",
  2. "purchaseTimeMillis": long,
  3. "purchaseState": integer,
  4. "consumptionState": integer,
  5. "developerPayload": string,
  6. "orderId": string}

  1. consumptionState - integer - The consumption state of the inapp product. Possible values are:
    1. Yet to be consumed

      Consumed

    developerPayload - string - A developer-specified string that contains supplemental information about an order.

      Purchased

      Cancelled

    purchaseTimeMillis - long - The time the product was purchased, in milliseconds since the epoch (Jan 1, 1970).

  2. kind - string - This kind represents an inappPurchase object in the androidpublisher service.
  3. orderId - string - The order id associated with the purchase of the inapp product.
  4. purchaseState - integer - The purchase state of the order. Possible values are:

more details here: https://developers.google.com/android-publisher/api-ref/purchases/products

then depends on your business logic you can change your data.