> For the complete documentation index, see [llms.txt](https://tip4serv.gitbook.io/tip4serv-api/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://tip4serv.gitbook.io/tip4serv-api/checkout.md).

# Checkout

Operations related to checkout

## Get necessary identifiers for basket

> Get all the necessary user identifiers to purchase the requested basket.\
> Some products require specific user identifiers in order to be purchased.\
> For example, a product that grants a Discord role will require a discord\_id, and a product that provides perks in Ark: Survival Ascended will require an eos\_id.\
> This route returns all the necessary information before proceeding with a purchase.\
> \
> No API key is required.<br>

```json
{"openapi":"3.0.4","info":{"title":"Tip4Serv API","version":"1.0.12"},"tags":[{"name":"Checkout","description":"Operations related to checkout"}],"servers":[{"url":"https://api.tip4serv.com/v1"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT or Partner API key","description":"Use a Tip4Serv JWT for standard store access, or a Partner API key as a Bearer token for Partner Connect. Partner Connect operations also require the `store_id` and `integration_key` query parameters and the relevant seller-approved permission."}}},"paths":{"/store/checkout/identifiers":{"get":{"tags":["Checkout"],"summary":"Get necessary identifiers for basket","description":"Get all the necessary user identifiers to purchase the requested basket.\nSome products require specific user identifiers in order to be purchased.\nFor example, a product that grants a Discord role will require a discord_id, and a product that provides perks in Ark: Survival Ascended will require an eos_id.\nThis route returns all the necessary information before proceeding with a purchase.\n\nNo API key is required.\n","operationId":"checkoutAuth","parameters":[{"name":"store","in":"query","required":true,"description":"Store ID. This ID is required in order to identify to which store you want to checkout. If you have an API key, you can request the /whoami route in order to figure out your store ID.","schema":{"type":"integer"}},{"name":"products","in":"query","required":true,"description":"An array of product id to be purchased.","schema":{"type":"array","items":{"type":"integer"}}}],"responses":{"200":{"description":"Array of required user identifiers.","content":{"application/json":{"schema":{"type":"array","items":{"type":"string"}}}}},"400":{"description":"Error in your request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"status":{"type":"integer"}}}}}},"500":{"description":"Internal Server Error","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"status":{"type":"integer"}}}}}}}}}}}
```

## Generate a checkout link

> Generate an checkout link, provide a basket of what you want to checkout,\
> and the endpoint will return you an URL to which to redirect.\
> \
> No API key is required.<br>

```json
{"openapi":"3.0.4","info":{"title":"Tip4Serv API","version":"1.0.12"},"tags":[{"name":"Checkout","description":"Operations related to checkout"}],"servers":[{"url":"https://api.tip4serv.com/v1"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT or Partner API key","description":"Use a Tip4Serv JWT for standard store access, or a Partner API key as a Bearer token for Partner Connect. Partner Connect operations also require the `store_id` and `integration_key` query parameters and the relevant seller-approved permission."}},"schemas":{"CheckoutRequest":{"type":"object","required":["products"],"properties":{"products":{"type":"array","description":"The list of products to purchase.","items":{"$ref":"#/components/schemas/CheckoutProduct"}},"currency":{"type":"string","description":"Display currency code (optional). Supported currencies: GBP, USD, EUR, CAD, AUD, CHF. If omitted, prices are displayed in store currency. Converts all product prices (price, old_price, min_donation) and custom field prices."},"user":{"$ref":"#/components/schemas/CheckoutUser"},"redirect_success_checkout":{"type":"string","description":"This optional parameter allows you to redirect your users to a specific URL after the payment was processed successfully.\n"},"redirect_canceled_checkout":{"type":"string","description":"This optional parameter allows you to redirect your users to a specific URL if the user want to return back.\n"},"redirect_pending_checkout":{"type":"string","description":"This optional parameter allows you to redirect your users to a specific URL after the payment was processed successfully but is still being verified.\n"}}},"CheckoutProduct":{"type":"object","properties":{"product_id":{"type":"integer","description":"The product ID. Make sure that at least `product_id` is defined or `product_slug`."},"product_slug":{"type":"string","description":"Slug of the product. Make sure that at least `product_id` is defined or `product_slug`."},"type":{"type":"string","description":"The product purchase type. Can take the following values: `addtocart`, `subscribe`.\n(If you specify `addtocart` for a subscription-based product, the subscription will be bought as a one-time payment instead of a recurring subscription).\n\nIf no type is specified, here are the default values:\n- Simple products: `addtocart`\n- Subscriptions: `subscribe`\n"},"quantity":{"type":"integer","description":"The quantity to purchase.","default":1},"donation_amount":{"type":"number","description":"The donation amount for \"free_price\" products, expressed in the store currency."},"server_selection":{"type":"integer","description":"The selected server ID (if required by the product)."},"custom_fields":{"type":"object","description":"The custom fields values.\nFormat: custom_field_id: selected_value.\n","additionalProperties":true}}},"CheckoutUser":{"type":"object","description":"This parameter is optional, if you wish to handle User authentication you must submit this parameter. Otherwise we'll handle it for you.\n\n\nUser identifiers used to validate the purchase.\nIf a field is required for a product, the API will return an error.\nRequired fields can be found using the /checkout/identifiers route.\n","properties":{"email":{"type":"string","description":"The customer email."},"minecraft_username":{"type":"string","description":"The Minecraft username."},"steam_id":{"type":"string","description":"The SteamID64 (17 digits)."},"discord_id":{"type":"string","description":"The Discord ID of the user."},"epic_id":{"type":"string","description":"The Epic ID."},"player_id":{"type":"string","description":"Raw generic player identifier."},"eos_id":{"type":"string","description":"The EOSID."},"fivem_citizen_id":{"type":"string","description":"The FiveM citizen id."},"ingame_username":{"type":"string","description":"The in-game username."},"rust_username":{"type":"string","description":"The Rust username."}},"required":["email"]}}},"paths":{"/store/checkout":{"post":{"tags":["Checkout"],"summary":"Generate a checkout link","description":"Generate an checkout link, provide a basket of what you want to checkout,\nand the endpoint will return you an URL to which to redirect.\n\nNo API key is required.\n","operationId":"checkout","parameters":[{"name":"store","in":"query","required":true,"description":"Store ID. This ID is required in order to identify to which store you want to checkout. If you have an API key, you can request the /whoami route in order to figure out your store ID.","schema":{"type":"integer"}},{"name":"currency","in":"query","description":"Display currency code (optional). Supported currencies: GBP, USD, EUR, CAD, AUD, CHF. If omitted, prices are displayed in store currency. Converts all product prices (price, old_price, min_donation) and custom field prices.","required":false,"schema":{"type":"string"}},{"name":"redirect","in":"query","required":false,"description":"If enabled, the endpoint will send a 302 Redirection instead of an JSON.","schema":{"type":"boolean","default":false}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CheckoutRequest"}}}},"responses":{"200":{"description":"Checkout link generated successfully.","content":{"application/json":{"schema":{"type":"object","properties":{"url":{"type":"string"}}}}}},"302":{"description":"Checkout link generated successfully."},"400":{"description":"Error in your request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"status":{"type":"integer"}}}}}},"404":{"description":"User not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"status":{"type":"integer"}}}}}},"500":{"description":"Internal Server Error","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"status":{"type":"integer"}}}}}}}}}}}
```
