Payments
Charge users for game items.
Payments allow charges to be made to users’ credit or debit cards.
Creating a Charge
You can create an arbitrary one-off charge for your users, such as to sell them items available only off-chain. You are responsible for monitoring the status of the payment, and making delivery of the goods purchased by the user. To create a charge, make a POST http request to https://api.gameshift.dev/nx/payments
:
curl --request POST \
--url https://api.gameshift.dev/nx/payments \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--header 'x-api-key: <your api key>' \
--data '
{
"title": "Amazing new item",
"description": "This item grants the user amazing skills",
"price": {
"currencyId": "USDC",
"naturalAmount": "100"
},
"quantity": 1,
"buyerId": "exampleId"
}
'
You must provide the following fields:
title
: The name of the chargedescription
: An explanation for the chargeprice.currencyId
: Must provide "USDC" for nowprice.naturalAmount
: The amount to chargequantity
: The number of units of goods that you are selling to the userbuyerId
: The reference id of the user making the purchase
All requests return a “payment URL” and a “payment ID”. You must then navigate the buyer to the “payment URL” to complete the purchase.
{
"consentUrl": "https://app.gameshift.dev/checkout?payment=3adb12a6-53ed-4091-8edc-966a307430cd",
"transactionId": "3adb12a6-53ed-4091-8edc-966a307430cd"
}
Payment Status
You can check on the status of the payment by making a GET http request to https://api.gameshift.dev/nx/payments/{id-of-the-payment}
. The request will return the current status of the payment as well as other details.
{
"id": "3adb12a6-53ed-4091-8edc-966a307430cd",
"environment": "Development",
"purchaser": {
"referenceId": "exampleUserId",
"email": "[email protected]"
},
"price": {
"currencyId": "USDC",
"naturalAmount": "100"
},
"sku": {
"type": "Generic",
},
"status": "Pending"
}
Updated 6 months ago