Consume an In-App Purchase with the API
This API is intended for exceptional support scenarios—for example, when a user completed a purchase but did not receive the product, and support delivers it manually. After delivering the product, you can consume the purchase for that user from your server.
Note
You generally do not need this API when the app's purchase and delivery flow is implemented correctly. Use it only for consumable products and support scenarios. Do not consume non-consumable products.
Security
This API is for server-to-server calls only. Do not put the X-Access-Token in a client app.
Request
- cURL
- Python
curl --request PUT \
'https://developer.myket.ir/api/partners/applications/{PACKAGE_NAME}/purchases/products/{SKU_ID}/tokens/{TOKEN}/consume' \
--header 'X-Access-Token: {ACCESS_TOKEN}'
import requests
package_name = "org.example.app"
sku_id = "GEM2"
purchase_token = "PURCHASE_TOKEN"
url = (
f"https://developer.myket.ir/api/partners/applications/{package_name}"
f"/purchases/products/{sku_id}/tokens/{purchase_token}/consume"
)
headers = {"X-Access-Token": "YOUR_ACCESS_TOKEN"}
response = requests.put(url, headers=headers)
print(response.status_code, response.json())
| Parameter | Description |
|---|---|
PACKAGE_NAME | App package name |
SKU_ID | ID of the consumable product |
TOKEN | In-app purchase token |
ACCESS_TOKEN | App access token from the Developer Panel |
Successful response
On success, the API returns HTTP 200 and a body similar to:
{
"code": 200,
"messageCode": "Successful",
"translatedMessage": "The operation completed successfully"
}
Error responses
| Status | Message code | Description |
|---|---|---|
400 | SkuAlreadyConsumed | The product has already been consumed |
404 | PurchasedSkuNotFound | The purchase or token was not found |
404 | SkuIdNotFound | The in-app product was not found |
500 | InternalError | Internal server error |