This document focuses on the consumePurchase
API used for server-side purchase consumption.
After you have verified the purchase, you should mark it as consumed.
Purchase consumption involves:
https://payments-api.now.gg/
v2/order/consumePurchase
POST
'Authorization': '<payment_api_key_here>', 'Content-Type': 'application/x-www-form-urlencoded'
The following should be included within the request body with consumePurchase
API:
"purchaseToken": "<purchase_token_here>", "productId": "<product_id_here>", // Required only for multi-store "developerPayload": developerPayload // Optional. // Required only for multi-store "currency": "<currency>", // Required only for multi-store "type": "<store>" // xiaomi | onestore. If not present, fallback value will be nowgg.
Note: If type
is not present, the fallback value will be nowgg.
The following sample code illustrates the associated request using the consumePurchase
API.
import requests url = "https://payments-api.now.gg/v2/order/consumePurchase" 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 "developerPayload": "developerPayload", // Optional // Required only for multi-store "currency": "<currency>", // Required only for multi-store "type": "<store>" // xiaomi, onestore. If not present, the fallback will be nowgg } response = requests.post(url, headers=headers, data=data) print("Response Status Code:", response.status_code) print("Response Body:", response.text)
curl --location --request POST 'https://payments-api.now.gg/v2/order/consumePurchase' \ --header 'Authorization: <payment_api_key_here>' \ --header 'Content-Type': 'application/x-www-form-urlencoded' \ --data '{ "purchaseToken": "<purchase_token_here>", "productId": "<product_id_here>", // Required only for multi-store "developerPayload" : developerPayload, //Optional, // Required only for multi-store "currency": "<currency>", // Required only for multi-store "type": "<store>" // xiaomi | onestore // If not present, fallback value will be nowgg }'
Payments API Key
can be found within the credentials section of nowStudio. More information.The following is a sample response from the consumePurchase
API.
{ "success": true, "code": 0, "codeMsg": "success", "data": {} }
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. |
data | object | Data returned as a response. |
Error Code | Message | Description |
---|---|---|
3800 | ERROR_CONSUMING_PRODUCT | There was an error consuming the product. |
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