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>", // Deprecated "developerPayload": "developerPayload" // Optional. "type": "<store>" // Deprecated
productId and type fields have been deprecated.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>",
"developerPayload": "developerPayload" // Optional
}
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>",
"developerPayload" : "developerPayload" //Optional
}'
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