Validate a Myket Purchase
To confirm purchase status and reduce fraud, verify purchases with Myket from your app's server. This API is for server-to-server calls only; never put the access token in a client app.
Security
X-Access-Token is confidential. Store it only on a secure server. Never include it in client code, a released app, or a public repository.
Request
- cURL
- Python
curl --request POST \
'https://developer.myket.ir/api/partners/applications/{PACKAGE_NAME}/purchases/products/{SKU_ID}/verify' \
--header 'X-Access-Token: {ACCESS_TOKEN}' \
--header 'Content-Type: application/json' \
--data '{
"tokenId": "{TOKEN_ID}"
}'
import requests
package_name = "org.example.app"
sku_id = "GEM2"
access_token = "YOUR_ACCESS_TOKEN"
purchase_token = "PURCHASE_TOKEN"
url = (
f"https://developer.myket.ir/api/partners/applications/{package_name}"
f"/purchases/products/{sku_id}/verify"
)
headers = {"X-Access-Token": access_token}
payload = {"tokenId": purchase_token}
response = requests.post(url, headers=headers, json=payload)
print(response.status_code, response.json())
Replace the path and request-body values with the purchase information:
| Parameter | Description |
|---|---|
PACKAGE_NAME | App package name, for example, org.example.app |
SKU_ID | In-app product ID, for example, GEM2 |
ACCESS_TOKEN | App access token obtained from the Developer Panel |
TOKEN_ID | Purchase token for the transaction |
Successful purchase response
{
"kind": "androidpublisher#productPurchase",
"purchaseTime": 1492839267000,
"developerPayload": "",
"purchaseState": 0,
"consumptionState": 1
}
purchaseState: Purchase status;0means successful and1means unsuccessful.purchaseTime: Transaction time as a Unix timestamp in milliseconds.kind: Purchase type.developerPayload: Value supplied by the app when the purchase was started.consumptionState: Consumption status;0means not consumed and1means consumed.
Error response
For example, a server-side error may return a response similar to:
{
"code": 500,
"messageCode": "InternalError",
"translatedMessage": "An error occurred."
}