Webshop HTTP API Examples
List of HTTP API
This article provides descriptions, examples, and syntax for the webshop APIs.
Here is the full implementation overview.
When a player makes a webshop purchase, an entitlement is created with Pley.
This entitlement should be checked for when:
- The player starts the game normally (using
get-entitlements
, which returnsentitlement_id
) - The player deep links into the game with an
entitlement_id
(usingget-entitlement-info
)
Then, once the entitlements are confirmed for the user:
- Consume entitlements in the game backend (using
consume-entitlement
) - If successfully consumed, grant the products/items to the player.
POST /v3/payments-kit/get-entitlements
/v3/payments-kit/get-entitlements
Lists all entitlements and their products for the given game user. Should be called on non-deep link startup. If it returns an entitlement_id
, it should still be verified its for the right user with get-entitlement-info
before consuming.
curl "$host:$port/v3/payments-kit/get-entitlements" \
-H "Authorization: Bearer $token" \
-H "Content-Type: application/json" \
-d '{"game_user_id": "1758b2f2-XXXX-11ec-b777-2766b5c3e5f9"}' | jq .
Which returns data:
{
"data": [
{
"entitlement_id": "006552d6-XXXX-11ee-9c2e-77082f8566ae",
"products": [
{
"product_id": "135be10a-XXXX-11ec-9e98-6f7b0b63539d",
"quantity": 1
}
],
"in_sandbox": false
}
]
}
POST /v3/payments-kit/get-entitlement-info
/v3/payments-kit/get-entitlement-info
Provides detailed information about a specific entitlement and who bought it. Should always be called before consuming entitlements to verify that the user is the same user who made the purchase.
curl "$host:$port/v3/payments-kit/get-entitlement-info" \
-H "Authorization: Bearer $token" \
-H "Content-Type: application/json" \
-d '{"entitlement_id": "006552d6-XXXX-11ee-9c2e-77082f8566ae"}' | jq .
Which returns data:
{
"data": {
"entitlement_id": "006552d6-XXXX-11ee-9c2e-77082f8566ae",
"products": [
{
"product_id": "135be10a-XXXX-11ec-9e98-6f7b0b63539d",
"quantity": 1
}
],
"in_sandbox": false,
"for_pley_game_user_id": "1758b2f2-XXXX-11ec-b777-2766b5c3e5f9",
"for_pley_game_user_email": "[email protected]"
}
}
POST /v3/payments-kit/consume-entitlement
/v3/payments-kit/consume-entitlement
Called by the game backend to mark a verified entitlement as consumed. An entitlement can only be consumed once, and will return an error if called again with the same ID. When consume-entitlement
is successfully called, grant the player their products/items.
curl "$host:$port/v3/payments-kit/consume-entitlement" \
-H "Authorization: Bearer $token" \
-H "Content-Type: application/json" \
-d '{"entitlement_id": "006552d6-XXXX-11ee-9c2e-77082f8566ae", "game_user_id": "1758b2f2-XXXX-11ec-b777-2766b5c3e5f9"}' | jq .
Which returns data:
{
"data": {
"success": true
}
}
Updated 9 months ago