Payments allow charges to be made to users’ credit cards. let you charge your players with a credit card charge. You can use payments to either request one-off charges, or to enable your players to purchase assets.

Charging for an Asset

You’ll first need to create an asset template (see “Creating an Asset with Templates”). Once you have an asset template created, you can use the template to generate a checkout.

Create a checkout by making a POST http request to https://api.gameshift.dev/asset-templates/{the-id-of-the-template}/checkout.

curl --request POST \
     --url https://api.gameshift.dev/asset-templates/6ba6e801-258c-4d5d-86b9-4f65c522bb1c/checkout \
     --header 'accept: application/json' \
     --header 'content-type: application/json' \
     --header 'x-api-key: <your api key>' \
     --data '
{
  "amountCents": 1000,
  "quantity": 1,
  "buyerId": "exampleId"
}
'

You must provide the following fields:

  • amountsCents - In USD, the number of cents to charge for
  • quantity - The number of assets to grant once the purchase is complete
  • buyerId - 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.

{
  "url": "https://app.gamehshift.dev/checkout?payment=3adb12a6-53ed-4091-8edc-966a307430cd",
  "id": "3adb12a6-53ed-4091-8edc-966a307430cd"
}

Creating One Off Charges

You can create an arbitrary one-off charge for your users. To create the charge, make a POST http request to https://api.gameshift.dev/payments/checkout:

curl --request POST \
     --url https://api.gameshift.dev/payments/checkout \
     --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",
  "amountCents": 1000,
  "quantity": 1,
  "buyerId": "exampleId"
}
'

You must provide the following fields:

  • title: The name of the charge
  • description: An explanation for the charge
  • amountCents: In USD, the number of cents to charge for
  • quantity: The number of units included in the charge
  • buyerId: 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.

{
  "url": "https://app.gameshift.dev/checkout?payment=3adb12a6-53ed-4091-8edc-966a307430cd",
  "id": "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/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",
  "env": "Development",
  "status": "Pending",
  "paymentUrl": "https://app.gameshift.dev/checkout?payment=3adb12a6-53ed-4091-8edc-966a307430cd",
  "amountCents": 1000,
  "userEmail": "[email protected]",
  "userWallet": "exampleUserWallet",
  "title": "Amazing new item",
  "description": "This item grants the user amazing skills"
}