This section contains the API reference for Verify Purchase API and the sample request code segments.
The verifyPurchase API is used to verify the in-app product purchase before assigning the IAP product to the user.
https://payments-api.now.gg/
v2/seller/order/verifyPurchase
POST
'Authorization': '<payment_api_key_here>', 'Content-Type': 'application/x-www-form-urlencoded'
The following params should be included within the request body with verifyPurchase
API:
"purchaseToken": "<purchase_token_here>", "productId": "<product_id_here>", // Required only for multi-store "currency": "<currency>", // Required only for multi-store "type": "<store>" // xiaomi | onestore | amazon | huawei // Required only for multi-store
Note: If type
is not present, fallback value will be nowgg.
The following sample code illustrates the associated request using the verifyPurchase
API.
import requests url = "https://payments-api.now.gg/v2/sellers/order/verifyPurchase" headers = { "Authorization": "<payment_api_key_here>", "Content-Type": "application/x-www-form-urlencoded" } data = { "purchaseToken": "<purchase_token_here>", "productId": "<product_id_here>", // Required only for multi-store "currency": "<currency>", // Required only for multi-store "type": "<store>" // xiaomi, onestore, amazon, huawei. If not present, the fallback value will be nowgg. } response = requests.post(url, headers=headers, data=data) print("Response Status Code:", response.status_code) print("Response Body:", response.text)
curl -X \ POST "https://payments-api.now.gg/v2/sellers/order/verifyPurchase" \ -H \ "Authorization: <payment_api_key_here>" \ -H \ "Content-Type: application/x-www-form-urlencoded" \ -d "purchaseToken=<purchase_token_here>" \ -d "productId=<product_id_here>" \ // Required only for multi-store -d "currency=<currency>" \ // Required only for multi-store -d "type=<store>"
type
– The store types include Xiaomi, Onestore, Amazon, and Huawei. If not present, the fallback value will be nowgg.Payments API Key
can be found within the credentials section of nowStudio. More information.purchaseToken
is returned after a successful purchase. You can refer to the following reference documents for more information:The following is a sample response from the verifyPurchase
API.
{ "success": true, "code": 0, "codeMsg": "success", "data": { "purchaseTimeMillis": "1630529397125", // This field has been deprecated, use purchaseTime instead. "purchaseTime": "1630529397", "purchaseState": 0, "consumptionState": 0, "developerPayload": "<developer_payload>", "orderId": "<orderId_here>", "appId": "3", "kind": "nowgg#productPurchase", "regionCode": "US", "currency": "USD", "packageName": "<package_name>", "payStatusTxt": "Paid", "orderAmount": "25.15", "isTestOrder": false, "payTimeTxt": "2024 - 10 - 3006: 08: 01", "sellerGoodsId": "11223343", "purchaseToken": "241028222221SGP61717", "productId": "11223343" } }
Params | Type | Description |
---|---|---|
success | boolean | Returns success as true or false. |
code | int | Returns 0 for success and non-zero for failure. |
codeMsg | string | Returns msg related to error code. (Provided here) |
purchaseTimeMillis (DEPRECATED) | string | The time the product was purchased, in milliseconds since the epoch. This field has been deprecated, use purchaseTime instead. |
purchaseTime | string | The time the product was purchased, in seconds since the epoch. |
purchaseState | int | The purchase state of the order. Possible values are: 0: Unpaid, 1: Paid, 2: Failed |
appId | string | Unique Identifier for your app. Same as Payment ID. |
consumptionState | int | The consumption state of the in-app product. Possible values are: 0: Yet to be consumed, 1: Consumed |
developerPayload | string | A developer-specified string containing supplemental information about an order. |
orderId | string | The order ID (Unique transaction identifier) associated with every in-app purchase product. |
kind | string | The kind of in-app product purchased with a hardcoded type nowgg#productPurchase . |
regionCode | string | ISO 3166-1 alpha-2 billing region code of the user at the time the product was granted. |
currency | string | The currency of the purchase. Examples – USD, INR, etc. |
packageName | string | The packageName associated with your app. |
payStatusTxt | string | Payment status as Paid or Unpaid. |
orderAmount | string | The orderAmount of your purchase. |
isTestOrder | boolean | Returns results as true or false if the order is generated during testing. |
payTimeTxt | string | Payment date and time associated with a purchase. |
sellerGoodsId | string | Unique identifier for the purchased product, identical to `productId`. This is provided for backward compatibility. |
productId | string | Unique identifier for the purchased product. |
purchaseToken | string | The purchaseToken associated with a purchase. |
Error Code | Message | Description |
---|---|---|
3900 | INVALID_AUTHORIZATION_KEY | The API Key provided for authorization is invalid. |
3901 | INVALID_PURCHASE_TOKEN | The provided purchase token is invalid. |
5014 | MULTISTORE_UNKNOWN_ERROR | Indicates a generic error from the Multistore API. |
5015 | MULTISTORE_AUTH_ERROR | Indicates an error while generating auth/credentials for Multistore API. |
Payments Module
Payments Module
Document Rev. 1.0