Creating a Basket
Depending on the type of Tebex store you are integrating, additional parameters may be necessary before the basket can be successfully created.
Authorizing Baskets
For most stores, the user must authorize their account before checkout is completed. This is done via the /auth endpoint where we will return the authentication options available for your store.
Provide a returnUrl , and after successful authentication the user will be directed back to your site.
Fetches a basket's auth URL.
The webstore identifier.
t66x-7cd928b1e9312709e6810edac6dc1fd1eefc57cbThe basket identifier.
c00244-d2ac2e77418a55b25292a6bc7a719ad9c529ba2cThe URL you would like to redirect the user to after successful basket authentication.
https://example.tebex.io/Successful response returns the basket auth information.
The provided webstore ID or basket ID is invalid.
GET /api/accounts/{token}/baskets/{basketIdent}/auth?returnUrl={returnUrl} HTTP/1.1
Host: headless.tebex.io
Accept: */*
[
{
"name": "FiveM",
"url": "https://ident.tebex.io/"
}
]Minecraft and Overwolf Stores
You must provide the username parameter as part of the basket creation request so that the basket is attributed to the correct user:
If you are creating a basket on your backend server, you will need to provide us the ip_address of the customer.
Currently we are unable to support IPv6 addresses being provided in the ip_address property. While we work on enabling IPv6 support, please provide an IPv4 address for the customer.
If you are creating a basket from the user's browser, we will automatically determine the IP from the requesting device.
{
"complete_url": "https://example.tebex.io/thank-you",
"cancel_url": "https://tebex.io/",
"custom": {
"foo": "bar"
},
"complete_auto_redirect": true,
"username": "TebexDev",
}The Basket which is returned will include the username_id which may be required for certain endpoints.
You should save the username_id as part of the user's session for use later.
Universal Stores
No username is required, but depending on your package Deliverables you may need to provide variable_data so that the package is attributed to the correct user. See Adding Packages.
Creates a new basket for use during checkout.
The webstore identifier.
t66x-7cd928b1e9312709e6810edac6dc1fd1eefc57cbA URL the user can return to when checkout is completed.
https://example.tebex.io/thank-youA URL the user can return to when cancelling checkout.
https://tebex.io/Custom data you wish to associate with the basket. This data will be included with webhook responses and GET requests associated with the Basket.
{"foo":"bar"}True if the user should automatically be redirected to the relevant complete/cancel URL
trueSuccessful response returns the basket information.
The provided webstore ID is invalid.
POST /api/accounts/{token}/baskets HTTP/1.1
Host: headless.tebex.io
Content-Type: application/json
Accept: */*
Content-Length: 139
{
"complete_url": "https://example.tebex.io/thank-you",
"cancel_url": "https://tebex.io/",
"custom": {
"foo": "bar"
},
"complete_auto_redirect": true
}{
"data": {
"id": 244127617,
"ident": "1a-55fff4107740a1f40d844ff89607557f45bfafb3",
"complete": false,
"email": "[email protected]",
"username": null,
"coupons": [
{
"coupon_code": "Academy10"
}
],
"giftcards": [
{
"card_number": "0127 0244 7210 1111"
}
],
"creator_code": "text",
"cancel_url": "https://tebex.io",
"complete_url": null,
"complete_auto_redirect": false,
"country": "US",
"ip": "127.0.0.1",
"username_id": 127244,
"base_price": 1.27,
"sales_tax": 0.11,
"total_price": 1.38,
"currency": "USD",
"packages": [
{
"qty": 2,
"type": "single",
"revenue_share": [
{
"wallet_ref": "some_wallet_reference",
"amount": 0.5,
"gateway_fee_percent": 50
}
]
}
],
"custom": {
"foo": "bar",
"ref": 1234
},
"links": {
"payment": "https://checkout.tebex.io/api/payments/tbx-12345",
"checkout": "https://checkout.tebex.io/checkout/1a-55fff4107740a1f40d844ff89607557f45bfafb3"
}
}
}Last updated
Was this helpful?

