curl --request POST \
--url https://api.sellauth.com/v1/shops/{shopId}/checkout \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"cart": [
{
"productId": 1,
"variantId": 1,
"quantity": 1
}
],
"currency": "USD",
"ip": "203.0.113.10",
"country_code": "US",
"user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64)",
"asn": 64496,
"email": "customer@example.com",
"discord_user_id": null,
"discord_user_username": null,
"discord_access_token": null,
"discord_refresh_token": null,
"coupon": "SAVE10",
"gateway": "STRIPE",
"payment_method_id": 1,
"newsletter": false,
"affiliate": "PARTNER10",
"billing_name": "John Doe",
"billing_address_line1": "123 Main St",
"billing_address_line2": "Apt 4",
"billing_city": "Springfield",
"billing_state": "IL",
"billing_postcode": "62701",
"billing_country": "US",
"shipping_name": "John Doe",
"shipping_address_line1": "123 Main St",
"shipping_address_line2": "Apt 4",
"shipping_city": "Springfield",
"shipping_state": "IL",
"shipping_postcode": "62701",
"shipping_country": "US",
"shipping_phone": "+1 555 0100",
"metadata": [
"pasyzwszwtxpeqq"
],
"attribution": {
"utm_source": "newsletter",
"utm_medium": "email",
"utm_campaign": "spring_sale"
}
}
'import requests
url = "https://api.sellauth.com/v1/shops/{shopId}/checkout"
payload = {
"cart": [
{
"productId": 1,
"variantId": 1,
"quantity": 1
}
],
"currency": "USD",
"ip": "203.0.113.10",
"country_code": "US",
"user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64)",
"asn": 64496,
"email": "customer@example.com",
"discord_user_id": None,
"discord_user_username": None,
"discord_access_token": None,
"discord_refresh_token": None,
"coupon": "SAVE10",
"gateway": "STRIPE",
"payment_method_id": 1,
"newsletter": False,
"affiliate": "PARTNER10",
"billing_name": "John Doe",
"billing_address_line1": "123 Main St",
"billing_address_line2": "Apt 4",
"billing_city": "Springfield",
"billing_state": "IL",
"billing_postcode": "62701",
"billing_country": "US",
"shipping_name": "John Doe",
"shipping_address_line1": "123 Main St",
"shipping_address_line2": "Apt 4",
"shipping_city": "Springfield",
"shipping_state": "IL",
"shipping_postcode": "62701",
"shipping_country": "US",
"shipping_phone": "+1 555 0100",
"metadata": ["pasyzwszwtxpeqq"],
"attribution": {
"utm_source": "newsletter",
"utm_medium": "email",
"utm_campaign": "spring_sale"
}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
cart: [{productId: 1, variantId: 1, quantity: 1}],
currency: 'USD',
ip: '203.0.113.10',
country_code: 'US',
user_agent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64)',
asn: 64496,
email: 'customer@example.com',
discord_user_id: null,
discord_user_username: null,
discord_access_token: null,
discord_refresh_token: null,
coupon: 'SAVE10',
gateway: 'STRIPE',
payment_method_id: 1,
newsletter: false,
affiliate: 'PARTNER10',
billing_name: 'John Doe',
billing_address_line1: '123 Main St',
billing_address_line2: 'Apt 4',
billing_city: 'Springfield',
billing_state: 'IL',
billing_postcode: '62701',
billing_country: 'US',
shipping_name: 'John Doe',
shipping_address_line1: '123 Main St',
shipping_address_line2: 'Apt 4',
shipping_city: 'Springfield',
shipping_state: 'IL',
shipping_postcode: '62701',
shipping_country: 'US',
shipping_phone: '+1 555 0100',
metadata: ['pasyzwszwtxpeqq'],
attribution: {utm_source: 'newsletter', utm_medium: 'email', utm_campaign: 'spring_sale'}
})
};
fetch('https://api.sellauth.com/v1/shops/{shopId}/checkout', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.sellauth.com/v1/shops/{shopId}/checkout",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'cart' => [
[
'productId' => 1,
'variantId' => 1,
'quantity' => 1
]
],
'currency' => 'USD',
'ip' => '203.0.113.10',
'country_code' => 'US',
'user_agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64)',
'asn' => 64496,
'email' => 'customer@example.com',
'discord_user_id' => null,
'discord_user_username' => null,
'discord_access_token' => null,
'discord_refresh_token' => null,
'coupon' => 'SAVE10',
'gateway' => 'STRIPE',
'payment_method_id' => 1,
'newsletter' => false,
'affiliate' => 'PARTNER10',
'billing_name' => 'John Doe',
'billing_address_line1' => '123 Main St',
'billing_address_line2' => 'Apt 4',
'billing_city' => 'Springfield',
'billing_state' => 'IL',
'billing_postcode' => '62701',
'billing_country' => 'US',
'shipping_name' => 'John Doe',
'shipping_address_line1' => '123 Main St',
'shipping_address_line2' => 'Apt 4',
'shipping_city' => 'Springfield',
'shipping_state' => 'IL',
'shipping_postcode' => '62701',
'shipping_country' => 'US',
'shipping_phone' => '+1 555 0100',
'metadata' => [
'pasyzwszwtxpeqq'
],
'attribution' => [
'utm_source' => 'newsletter',
'utm_medium' => 'email',
'utm_campaign' => 'spring_sale'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.sellauth.com/v1/shops/{shopId}/checkout"
payload := strings.NewReader("{\n \"cart\": [\n {\n \"productId\": 1,\n \"variantId\": 1,\n \"quantity\": 1\n }\n ],\n \"currency\": \"USD\",\n \"ip\": \"203.0.113.10\",\n \"country_code\": \"US\",\n \"user_agent\": \"Mozilla/5.0 (Windows NT 10.0; Win64; x64)\",\n \"asn\": 64496,\n \"email\": \"customer@example.com\",\n \"discord_user_id\": null,\n \"discord_user_username\": null,\n \"discord_access_token\": null,\n \"discord_refresh_token\": null,\n \"coupon\": \"SAVE10\",\n \"gateway\": \"STRIPE\",\n \"payment_method_id\": 1,\n \"newsletter\": false,\n \"affiliate\": \"PARTNER10\",\n \"billing_name\": \"John Doe\",\n \"billing_address_line1\": \"123 Main St\",\n \"billing_address_line2\": \"Apt 4\",\n \"billing_city\": \"Springfield\",\n \"billing_state\": \"IL\",\n \"billing_postcode\": \"62701\",\n \"billing_country\": \"US\",\n \"shipping_name\": \"John Doe\",\n \"shipping_address_line1\": \"123 Main St\",\n \"shipping_address_line2\": \"Apt 4\",\n \"shipping_city\": \"Springfield\",\n \"shipping_state\": \"IL\",\n \"shipping_postcode\": \"62701\",\n \"shipping_country\": \"US\",\n \"shipping_phone\": \"+1 555 0100\",\n \"metadata\": [\n \"pasyzwszwtxpeqq\"\n ],\n \"attribution\": {\n \"utm_source\": \"newsletter\",\n \"utm_medium\": \"email\",\n \"utm_campaign\": \"spring_sale\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.sellauth.com/v1/shops/{shopId}/checkout")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"cart\": [\n {\n \"productId\": 1,\n \"variantId\": 1,\n \"quantity\": 1\n }\n ],\n \"currency\": \"USD\",\n \"ip\": \"203.0.113.10\",\n \"country_code\": \"US\",\n \"user_agent\": \"Mozilla/5.0 (Windows NT 10.0; Win64; x64)\",\n \"asn\": 64496,\n \"email\": \"customer@example.com\",\n \"discord_user_id\": null,\n \"discord_user_username\": null,\n \"discord_access_token\": null,\n \"discord_refresh_token\": null,\n \"coupon\": \"SAVE10\",\n \"gateway\": \"STRIPE\",\n \"payment_method_id\": 1,\n \"newsletter\": false,\n \"affiliate\": \"PARTNER10\",\n \"billing_name\": \"John Doe\",\n \"billing_address_line1\": \"123 Main St\",\n \"billing_address_line2\": \"Apt 4\",\n \"billing_city\": \"Springfield\",\n \"billing_state\": \"IL\",\n \"billing_postcode\": \"62701\",\n \"billing_country\": \"US\",\n \"shipping_name\": \"John Doe\",\n \"shipping_address_line1\": \"123 Main St\",\n \"shipping_address_line2\": \"Apt 4\",\n \"shipping_city\": \"Springfield\",\n \"shipping_state\": \"IL\",\n \"shipping_postcode\": \"62701\",\n \"shipping_country\": \"US\",\n \"shipping_phone\": \"+1 555 0100\",\n \"metadata\": [\n \"pasyzwszwtxpeqq\"\n ],\n \"attribution\": {\n \"utm_source\": \"newsletter\",\n \"utm_medium\": \"email\",\n \"utm_campaign\": \"spring_sale\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sellauth.com/v1/shops/{shopId}/checkout")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"cart\": [\n {\n \"productId\": 1,\n \"variantId\": 1,\n \"quantity\": 1\n }\n ],\n \"currency\": \"USD\",\n \"ip\": \"203.0.113.10\",\n \"country_code\": \"US\",\n \"user_agent\": \"Mozilla/5.0 (Windows NT 10.0; Win64; x64)\",\n \"asn\": 64496,\n \"email\": \"customer@example.com\",\n \"discord_user_id\": null,\n \"discord_user_username\": null,\n \"discord_access_token\": null,\n \"discord_refresh_token\": null,\n \"coupon\": \"SAVE10\",\n \"gateway\": \"STRIPE\",\n \"payment_method_id\": 1,\n \"newsletter\": false,\n \"affiliate\": \"PARTNER10\",\n \"billing_name\": \"John Doe\",\n \"billing_address_line1\": \"123 Main St\",\n \"billing_address_line2\": \"Apt 4\",\n \"billing_city\": \"Springfield\",\n \"billing_state\": \"IL\",\n \"billing_postcode\": \"62701\",\n \"billing_country\": \"US\",\n \"shipping_name\": \"John Doe\",\n \"shipping_address_line1\": \"123 Main St\",\n \"shipping_address_line2\": \"Apt 4\",\n \"shipping_city\": \"Springfield\",\n \"shipping_state\": \"IL\",\n \"shipping_postcode\": \"62701\",\n \"shipping_country\": \"US\",\n \"shipping_phone\": \"+1 555 0100\",\n \"metadata\": [\n \"pasyzwszwtxpeqq\"\n ],\n \"attribution\": {\n \"utm_source\": \"newsletter\",\n \"utm_medium\": \"email\",\n \"utm_campaign\": \"spring_sale\"\n }\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"invoice_id": 3,
"invoice_url": "https://demo-shop.sellauth.com/checkout/98b3f45d848c5-0000000000003",
"url": "https://demo-shop.sellauth.com/checkout/98b3f45d848c5-0000000000003"
}{
"message": "You do not have permission to create checkouts for this shop."
}{
"message": "The cart total must be greater than 0 when all cart items are custom."
}Create Checkout Session
Creates a checkout session (invoice) server-side and returns the URL to send the buyer to. Requires an API key; call it from your backend, never from a browser. Cart items are either catalog items (productId + variantId) or custom items (name + price, for one-off charges that are not in your catalog); both kinds can be mixed. If you pass both email and a payment method, the invoice is created as pending and a payment session is started immediately, so the returned url goes straight to the payment provider; otherwise it opens the hosted checkout where the buyer completes those steps. Available on plans with the Checkout API feature.
curl --request POST \
--url https://api.sellauth.com/v1/shops/{shopId}/checkout \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"cart": [
{
"productId": 1,
"variantId": 1,
"quantity": 1
}
],
"currency": "USD",
"ip": "203.0.113.10",
"country_code": "US",
"user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64)",
"asn": 64496,
"email": "customer@example.com",
"discord_user_id": null,
"discord_user_username": null,
"discord_access_token": null,
"discord_refresh_token": null,
"coupon": "SAVE10",
"gateway": "STRIPE",
"payment_method_id": 1,
"newsletter": false,
"affiliate": "PARTNER10",
"billing_name": "John Doe",
"billing_address_line1": "123 Main St",
"billing_address_line2": "Apt 4",
"billing_city": "Springfield",
"billing_state": "IL",
"billing_postcode": "62701",
"billing_country": "US",
"shipping_name": "John Doe",
"shipping_address_line1": "123 Main St",
"shipping_address_line2": "Apt 4",
"shipping_city": "Springfield",
"shipping_state": "IL",
"shipping_postcode": "62701",
"shipping_country": "US",
"shipping_phone": "+1 555 0100",
"metadata": [
"pasyzwszwtxpeqq"
],
"attribution": {
"utm_source": "newsletter",
"utm_medium": "email",
"utm_campaign": "spring_sale"
}
}
'import requests
url = "https://api.sellauth.com/v1/shops/{shopId}/checkout"
payload = {
"cart": [
{
"productId": 1,
"variantId": 1,
"quantity": 1
}
],
"currency": "USD",
"ip": "203.0.113.10",
"country_code": "US",
"user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64)",
"asn": 64496,
"email": "customer@example.com",
"discord_user_id": None,
"discord_user_username": None,
"discord_access_token": None,
"discord_refresh_token": None,
"coupon": "SAVE10",
"gateway": "STRIPE",
"payment_method_id": 1,
"newsletter": False,
"affiliate": "PARTNER10",
"billing_name": "John Doe",
"billing_address_line1": "123 Main St",
"billing_address_line2": "Apt 4",
"billing_city": "Springfield",
"billing_state": "IL",
"billing_postcode": "62701",
"billing_country": "US",
"shipping_name": "John Doe",
"shipping_address_line1": "123 Main St",
"shipping_address_line2": "Apt 4",
"shipping_city": "Springfield",
"shipping_state": "IL",
"shipping_postcode": "62701",
"shipping_country": "US",
"shipping_phone": "+1 555 0100",
"metadata": ["pasyzwszwtxpeqq"],
"attribution": {
"utm_source": "newsletter",
"utm_medium": "email",
"utm_campaign": "spring_sale"
}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
cart: [{productId: 1, variantId: 1, quantity: 1}],
currency: 'USD',
ip: '203.0.113.10',
country_code: 'US',
user_agent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64)',
asn: 64496,
email: 'customer@example.com',
discord_user_id: null,
discord_user_username: null,
discord_access_token: null,
discord_refresh_token: null,
coupon: 'SAVE10',
gateway: 'STRIPE',
payment_method_id: 1,
newsletter: false,
affiliate: 'PARTNER10',
billing_name: 'John Doe',
billing_address_line1: '123 Main St',
billing_address_line2: 'Apt 4',
billing_city: 'Springfield',
billing_state: 'IL',
billing_postcode: '62701',
billing_country: 'US',
shipping_name: 'John Doe',
shipping_address_line1: '123 Main St',
shipping_address_line2: 'Apt 4',
shipping_city: 'Springfield',
shipping_state: 'IL',
shipping_postcode: '62701',
shipping_country: 'US',
shipping_phone: '+1 555 0100',
metadata: ['pasyzwszwtxpeqq'],
attribution: {utm_source: 'newsletter', utm_medium: 'email', utm_campaign: 'spring_sale'}
})
};
fetch('https://api.sellauth.com/v1/shops/{shopId}/checkout', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.sellauth.com/v1/shops/{shopId}/checkout",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'cart' => [
[
'productId' => 1,
'variantId' => 1,
'quantity' => 1
]
],
'currency' => 'USD',
'ip' => '203.0.113.10',
'country_code' => 'US',
'user_agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64)',
'asn' => 64496,
'email' => 'customer@example.com',
'discord_user_id' => null,
'discord_user_username' => null,
'discord_access_token' => null,
'discord_refresh_token' => null,
'coupon' => 'SAVE10',
'gateway' => 'STRIPE',
'payment_method_id' => 1,
'newsletter' => false,
'affiliate' => 'PARTNER10',
'billing_name' => 'John Doe',
'billing_address_line1' => '123 Main St',
'billing_address_line2' => 'Apt 4',
'billing_city' => 'Springfield',
'billing_state' => 'IL',
'billing_postcode' => '62701',
'billing_country' => 'US',
'shipping_name' => 'John Doe',
'shipping_address_line1' => '123 Main St',
'shipping_address_line2' => 'Apt 4',
'shipping_city' => 'Springfield',
'shipping_state' => 'IL',
'shipping_postcode' => '62701',
'shipping_country' => 'US',
'shipping_phone' => '+1 555 0100',
'metadata' => [
'pasyzwszwtxpeqq'
],
'attribution' => [
'utm_source' => 'newsletter',
'utm_medium' => 'email',
'utm_campaign' => 'spring_sale'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.sellauth.com/v1/shops/{shopId}/checkout"
payload := strings.NewReader("{\n \"cart\": [\n {\n \"productId\": 1,\n \"variantId\": 1,\n \"quantity\": 1\n }\n ],\n \"currency\": \"USD\",\n \"ip\": \"203.0.113.10\",\n \"country_code\": \"US\",\n \"user_agent\": \"Mozilla/5.0 (Windows NT 10.0; Win64; x64)\",\n \"asn\": 64496,\n \"email\": \"customer@example.com\",\n \"discord_user_id\": null,\n \"discord_user_username\": null,\n \"discord_access_token\": null,\n \"discord_refresh_token\": null,\n \"coupon\": \"SAVE10\",\n \"gateway\": \"STRIPE\",\n \"payment_method_id\": 1,\n \"newsletter\": false,\n \"affiliate\": \"PARTNER10\",\n \"billing_name\": \"John Doe\",\n \"billing_address_line1\": \"123 Main St\",\n \"billing_address_line2\": \"Apt 4\",\n \"billing_city\": \"Springfield\",\n \"billing_state\": \"IL\",\n \"billing_postcode\": \"62701\",\n \"billing_country\": \"US\",\n \"shipping_name\": \"John Doe\",\n \"shipping_address_line1\": \"123 Main St\",\n \"shipping_address_line2\": \"Apt 4\",\n \"shipping_city\": \"Springfield\",\n \"shipping_state\": \"IL\",\n \"shipping_postcode\": \"62701\",\n \"shipping_country\": \"US\",\n \"shipping_phone\": \"+1 555 0100\",\n \"metadata\": [\n \"pasyzwszwtxpeqq\"\n ],\n \"attribution\": {\n \"utm_source\": \"newsletter\",\n \"utm_medium\": \"email\",\n \"utm_campaign\": \"spring_sale\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.sellauth.com/v1/shops/{shopId}/checkout")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"cart\": [\n {\n \"productId\": 1,\n \"variantId\": 1,\n \"quantity\": 1\n }\n ],\n \"currency\": \"USD\",\n \"ip\": \"203.0.113.10\",\n \"country_code\": \"US\",\n \"user_agent\": \"Mozilla/5.0 (Windows NT 10.0; Win64; x64)\",\n \"asn\": 64496,\n \"email\": \"customer@example.com\",\n \"discord_user_id\": null,\n \"discord_user_username\": null,\n \"discord_access_token\": null,\n \"discord_refresh_token\": null,\n \"coupon\": \"SAVE10\",\n \"gateway\": \"STRIPE\",\n \"payment_method_id\": 1,\n \"newsletter\": false,\n \"affiliate\": \"PARTNER10\",\n \"billing_name\": \"John Doe\",\n \"billing_address_line1\": \"123 Main St\",\n \"billing_address_line2\": \"Apt 4\",\n \"billing_city\": \"Springfield\",\n \"billing_state\": \"IL\",\n \"billing_postcode\": \"62701\",\n \"billing_country\": \"US\",\n \"shipping_name\": \"John Doe\",\n \"shipping_address_line1\": \"123 Main St\",\n \"shipping_address_line2\": \"Apt 4\",\n \"shipping_city\": \"Springfield\",\n \"shipping_state\": \"IL\",\n \"shipping_postcode\": \"62701\",\n \"shipping_country\": \"US\",\n \"shipping_phone\": \"+1 555 0100\",\n \"metadata\": [\n \"pasyzwszwtxpeqq\"\n ],\n \"attribution\": {\n \"utm_source\": \"newsletter\",\n \"utm_medium\": \"email\",\n \"utm_campaign\": \"spring_sale\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sellauth.com/v1/shops/{shopId}/checkout")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"cart\": [\n {\n \"productId\": 1,\n \"variantId\": 1,\n \"quantity\": 1\n }\n ],\n \"currency\": \"USD\",\n \"ip\": \"203.0.113.10\",\n \"country_code\": \"US\",\n \"user_agent\": \"Mozilla/5.0 (Windows NT 10.0; Win64; x64)\",\n \"asn\": 64496,\n \"email\": \"customer@example.com\",\n \"discord_user_id\": null,\n \"discord_user_username\": null,\n \"discord_access_token\": null,\n \"discord_refresh_token\": null,\n \"coupon\": \"SAVE10\",\n \"gateway\": \"STRIPE\",\n \"payment_method_id\": 1,\n \"newsletter\": false,\n \"affiliate\": \"PARTNER10\",\n \"billing_name\": \"John Doe\",\n \"billing_address_line1\": \"123 Main St\",\n \"billing_address_line2\": \"Apt 4\",\n \"billing_city\": \"Springfield\",\n \"billing_state\": \"IL\",\n \"billing_postcode\": \"62701\",\n \"billing_country\": \"US\",\n \"shipping_name\": \"John Doe\",\n \"shipping_address_line1\": \"123 Main St\",\n \"shipping_address_line2\": \"Apt 4\",\n \"shipping_city\": \"Springfield\",\n \"shipping_state\": \"IL\",\n \"shipping_postcode\": \"62701\",\n \"shipping_country\": \"US\",\n \"shipping_phone\": \"+1 555 0100\",\n \"metadata\": [\n \"pasyzwszwtxpeqq\"\n ],\n \"attribution\": {\n \"utm_source\": \"newsletter\",\n \"utm_medium\": \"email\",\n \"utm_campaign\": \"spring_sale\"\n }\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"invoice_id": 3,
"invoice_url": "https://demo-shop.sellauth.com/checkout/98b3f45d848c5-0000000000003",
"url": "https://demo-shop.sellauth.com/checkout/98b3f45d848c5-0000000000003"
}{
"message": "You do not have permission to create checkouts for this shop."
}{
"message": "The cart total must be greater than 0 when all cart items are custom."
}Authorizations
You can retrieve your API key from your dashboard under Account > Developers.
Path Parameters
The shop ID.
Body
The cart items. Each item is either a catalog item (productId + variantId) or a custom item (name + price). Both kinds can be mixed in one cart.
Show child attributes
Show child attributes
[
{
"productId": 1,
"variantId": 1,
"quantity": 1
}
]
ISO 4217 currency code. Required when every cart item is a custom item; otherwise inferred from the products. Must be 3 characters.
"USD"
The end buyer's IP address. Defaults to the caller's IP; forward the buyer's IP when calling from your backend so fraud checks and analytics see the real buyer. Must be a valid IP address.
"203.0.113.10"
The end buyer's ISO 3166-1 alpha-2 country code. Must contain only letters. Must be 2 characters.
"US"
The end buyer's user agent. Defaults to the caller's user agent.
"Mozilla/5.0 (Windows NT 10.0; Win64; x64)"
The end buyer's autonomous system number, if you have it.
64496
Prefill the customer email. When both email and a payment method are provided, the invoice is created as pending and a payment session is started immediately.
"customer@example.com"
Internal: link the customer's Discord account.
null
Internal: link the customer's Discord account.
null
Internal: link the customer's Discord account.
null
Internal: link the customer's Discord account.
null
A coupon code to apply.
"SAVE10"
DEPRECATED, use payment_method_id. The payment gateway type to preselect. One of STRIPE, SQUARE, SUMUP, MOLLIE, SKRILL, AUTHORIZENET, REVOLUTBUSINESS, LEMONSQUEEZY, NMI, OVERPAY, MONEI, RAZORPAY, PANDABASE, VENPAYR, OVGC, DODOPAYMENTS, PAYMONGO, ADYEN, SHOPIFY, AMAZONPS, PAYCEK, PAYPAL, PAYPALFF, CASHAPP, VENMO, ZELLE, SKRILLP2P, REWARBLE, BTC, LTC. CUSTOMERBALANCE is not allowed on this endpoint.
"STRIPE"
The payment method to preselect. Shown in the URL when editing a payment method in the dashboard. When set together with email, a payment session is started immediately and the response url points to the payment page.
1
Subscribe the customer to the shop newsletter. Only send true if the customer actually consented; false or omitted leaves their current subscription untouched, and a customer who unsubscribed themselves stays unsubscribed.
false
An affiliate code to credit for this sale. Must not be greater than 16 characters.
"PARTNER10"
Prefill: billing name. Must not be greater than 100 characters.
"John Doe"
Prefill: billing address line 1. Must not be greater than 150 characters.
"123 Main St"
Prefill: billing address line 2. Must not be greater than 150 characters.
"Apt 4"
Prefill: billing city. Must not be greater than 100 characters.
"Springfield"
Prefill: billing state or region. Must not be greater than 100 characters.
"IL"
Prefill: billing postcode. Must not be greater than 20 characters.
"62701"
Prefill: billing country (ISO 3166-1 alpha-2). Must be 2 characters.
"US"
Prefill: shipping name. Must not be greater than 100 characters.
"John Doe"
Prefill: shipping address line 1. Must not be greater than 150 characters.
"123 Main St"
Prefill: shipping address line 2. Must not be greater than 150 characters.
"Apt 4"
Prefill: shipping city. Must not be greater than 100 characters.
"Springfield"
Prefill: shipping state or region. Must not be greater than 100 characters.
"IL"
Prefill: shipping postcode. Must not be greater than 20 characters.
"62701"
Prefill: shipping country (ISO 3166-1 alpha-2). Must be 2 characters.
"US"
Prefill: shipping phone number. Must not be greater than 20 characters.
"+1 555 0100"
Must not be greater than 255 characters.
["pasyzwszwtxpeqq"]
Your server's view of how the buyer arrived: utm_source, utm_medium, utm_campaign, utm_term, utm_content, referrer_host (host only). Each max 100 chars; stored on the invoice for filtering and reporting.
Show child attributes
Show child attributes
{
"utm_source": "newsletter",
"utm_medium": "email",
"utm_campaign": "spring_sale"
}
Response
Without a preselected payment method: url opens the hosted checkout