のセクションには、consumePurchaseのAPI リファレンスとサンプルリクエスト・コードセグメントが含まれます。
購入を確認したら消費済みとして処理してください。
消費購入には以下が含まれます。:
https://payments-api.now.gg/
v2/order/consumePurchase
POST
'Authorization': '<payment_api_key_here>', 'Content-Type': 'application/x-www-form-urlencoded'
consumePurchase APIのリクエストボディには、次のパラメータを含める必要があります:
"purchaseToken": "<purchase_token_here>", "productId": "<product_id_here>", // 非推奨 "developerPayload": "developerPayload", // オプション "type": "<store>" // 非推奨
以下のサンプルコードは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" // オプション
}
response = requests.post(url, headers=headers, data=data)
print("レスポンスステータスコード:", response.status_code)
print("レスポンスボディ:", 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" // オプション
}'
Payments API Key はnowStudioのクレデンシャルセクションで確認することができます。 詳細はこちら以下はconsumePurchase APIからのレスポンスのサンプルです。
{
"success": true,
"code": 0,
"codeMsg": "success",
"data": {}
}
| パラメータ | 型 | 説明 |
|---|---|---|
| success | boolean | 処理結果をtrueまたはfalseで返します。 |
| code | int | 成功した場合は 0、失敗した場合は 0 以外のコードを返します。 |
| codeMsg | string | エラーコードに関連するメッセージを返します。 |
| data | object | デコードされたデータがレスポンスとして返されます。 |
| エラーコード | メッセージ | 説明 |
|---|---|---|
| 3800 | ERROR_CONSUMING_PRODUCT | 製品の消費処理中にエラーが発生しました。 |
| 3900 | INVALID_AUTHORIZATION_KEY | 認証のために渡されたAPI Keyが無効です。 |
| 3901 | INVALID_PURCHASE_TOKEN | 渡された購入トークンが無効です。 |
| 5014 | MULTISTORE_UNKNOWN_ERROR | Multistore APIで発生した一般的なエラーを示します。 |
| 5015 | MULTISTORE_AUTH_ERROR | Multistore APIの認証/資格情報生成中に発生したエラーを示します。 |
目次
目次
ドキュメント改訂版 1.0