Create a checkout session
curl --request POST \
--url https://api.example.com/api/v1/checkout-sessions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"customer_id": "<string>",
"plan_version_id": "<string>",
"add_ons": [
{
"add_on_id": "<string>",
"customization": {
"price_entry": {
"id": "<string>"
},
"name": "<string>"
},
"quantity": 1
}
],
"auto_advance_invoices": true,
"billing_day_anchor": 123,
"billing_start_date": "2023-12-25",
"charge_automatically": true,
"components": {
"extra_components": [
{
"name": "<string>",
"price_entry": {
"id": "<string>"
},
"product_ref": {
"id": "<string>"
}
}
],
"overridden_components": [
{
"component_id": "<string>",
"name": "<string>",
"price_entry": {
"id": "<string>"
}
}
],
"parameterized_components": [
{
"component_id": "<string>",
"parameters": {
"committed_capacity": 1,
"initial_slot_count": 1
}
}
],
"remove_components": [
"<string>"
]
},
"coupon_code": "<string>",
"coupon_ids": [
"<string>"
],
"end_date": "2023-12-25",
"expires_in_hours": 1,
"invoice_memo": "<string>",
"invoice_threshold": "<string>",
"metadata": "<unknown>",
"net_terms": 123,
"payment_methods_config": {
"config": {
"card": {
"enabled": true
},
"direct_debit": {
"enabled": true
}
}
},
"purchase_order": "<string>",
"trial_duration_days": 123
}
'import requests
url = "https://api.example.com/api/v1/checkout-sessions"
payload = {
"customer_id": "<string>",
"plan_version_id": "<string>",
"add_ons": [
{
"add_on_id": "<string>",
"customization": {
"price_entry": { "id": "<string>" },
"name": "<string>"
},
"quantity": 1
}
],
"auto_advance_invoices": True,
"billing_day_anchor": 123,
"billing_start_date": "2023-12-25",
"charge_automatically": True,
"components": {
"extra_components": [
{
"name": "<string>",
"price_entry": { "id": "<string>" },
"product_ref": { "id": "<string>" }
}
],
"overridden_components": [
{
"component_id": "<string>",
"name": "<string>",
"price_entry": { "id": "<string>" }
}
],
"parameterized_components": [
{
"component_id": "<string>",
"parameters": {
"committed_capacity": 1,
"initial_slot_count": 1
}
}
],
"remove_components": ["<string>"]
},
"coupon_code": "<string>",
"coupon_ids": ["<string>"],
"end_date": "2023-12-25",
"expires_in_hours": 1,
"invoice_memo": "<string>",
"invoice_threshold": "<string>",
"metadata": "<unknown>",
"net_terms": 123,
"payment_methods_config": { "config": {
"card": { "enabled": True },
"direct_debit": { "enabled": True }
} },
"purchase_order": "<string>",
"trial_duration_days": 123
}
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({
customer_id: '<string>',
plan_version_id: '<string>',
add_ons: [
{
add_on_id: '<string>',
customization: {price_entry: {id: '<string>'}, name: '<string>'},
quantity: 1
}
],
auto_advance_invoices: true,
billing_day_anchor: 123,
billing_start_date: '2023-12-25',
charge_automatically: true,
components: {
extra_components: [
{name: '<string>', price_entry: {id: '<string>'}, product_ref: {id: '<string>'}}
],
overridden_components: [{component_id: '<string>', name: '<string>', price_entry: {id: '<string>'}}],
parameterized_components: [
{
component_id: '<string>',
parameters: {committed_capacity: 1, initial_slot_count: 1}
}
],
remove_components: ['<string>']
},
coupon_code: '<string>',
coupon_ids: ['<string>'],
end_date: '2023-12-25',
expires_in_hours: 1,
invoice_memo: '<string>',
invoice_threshold: '<string>',
metadata: '<unknown>',
net_terms: 123,
payment_methods_config: {config: {card: {enabled: true}, direct_debit: {enabled: true}}},
purchase_order: '<string>',
trial_duration_days: 123
})
};
fetch('https://api.example.com/api/v1/checkout-sessions', 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.example.com/api/v1/checkout-sessions",
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([
'customer_id' => '<string>',
'plan_version_id' => '<string>',
'add_ons' => [
[
'add_on_id' => '<string>',
'customization' => [
'price_entry' => [
'id' => '<string>'
],
'name' => '<string>'
],
'quantity' => 1
]
],
'auto_advance_invoices' => true,
'billing_day_anchor' => 123,
'billing_start_date' => '2023-12-25',
'charge_automatically' => true,
'components' => [
'extra_components' => [
[
'name' => '<string>',
'price_entry' => [
'id' => '<string>'
],
'product_ref' => [
'id' => '<string>'
]
]
],
'overridden_components' => [
[
'component_id' => '<string>',
'name' => '<string>',
'price_entry' => [
'id' => '<string>'
]
]
],
'parameterized_components' => [
[
'component_id' => '<string>',
'parameters' => [
'committed_capacity' => 1,
'initial_slot_count' => 1
]
]
],
'remove_components' => [
'<string>'
]
],
'coupon_code' => '<string>',
'coupon_ids' => [
'<string>'
],
'end_date' => '2023-12-25',
'expires_in_hours' => 1,
'invoice_memo' => '<string>',
'invoice_threshold' => '<string>',
'metadata' => '<unknown>',
'net_terms' => 123,
'payment_methods_config' => [
'config' => [
'card' => [
'enabled' => true
],
'direct_debit' => [
'enabled' => true
]
]
],
'purchase_order' => '<string>',
'trial_duration_days' => 123
]),
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.example.com/api/v1/checkout-sessions"
payload := strings.NewReader("{\n \"customer_id\": \"<string>\",\n \"plan_version_id\": \"<string>\",\n \"add_ons\": [\n {\n \"add_on_id\": \"<string>\",\n \"customization\": {\n \"price_entry\": {\n \"id\": \"<string>\"\n },\n \"name\": \"<string>\"\n },\n \"quantity\": 1\n }\n ],\n \"auto_advance_invoices\": true,\n \"billing_day_anchor\": 123,\n \"billing_start_date\": \"2023-12-25\",\n \"charge_automatically\": true,\n \"components\": {\n \"extra_components\": [\n {\n \"name\": \"<string>\",\n \"price_entry\": {\n \"id\": \"<string>\"\n },\n \"product_ref\": {\n \"id\": \"<string>\"\n }\n }\n ],\n \"overridden_components\": [\n {\n \"component_id\": \"<string>\",\n \"name\": \"<string>\",\n \"price_entry\": {\n \"id\": \"<string>\"\n }\n }\n ],\n \"parameterized_components\": [\n {\n \"component_id\": \"<string>\",\n \"parameters\": {\n \"committed_capacity\": 1,\n \"initial_slot_count\": 1\n }\n }\n ],\n \"remove_components\": [\n \"<string>\"\n ]\n },\n \"coupon_code\": \"<string>\",\n \"coupon_ids\": [\n \"<string>\"\n ],\n \"end_date\": \"2023-12-25\",\n \"expires_in_hours\": 1,\n \"invoice_memo\": \"<string>\",\n \"invoice_threshold\": \"<string>\",\n \"metadata\": \"<unknown>\",\n \"net_terms\": 123,\n \"payment_methods_config\": {\n \"config\": {\n \"card\": {\n \"enabled\": true\n },\n \"direct_debit\": {\n \"enabled\": true\n }\n }\n },\n \"purchase_order\": \"<string>\",\n \"trial_duration_days\": 123\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.example.com/api/v1/checkout-sessions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"customer_id\": \"<string>\",\n \"plan_version_id\": \"<string>\",\n \"add_ons\": [\n {\n \"add_on_id\": \"<string>\",\n \"customization\": {\n \"price_entry\": {\n \"id\": \"<string>\"\n },\n \"name\": \"<string>\"\n },\n \"quantity\": 1\n }\n ],\n \"auto_advance_invoices\": true,\n \"billing_day_anchor\": 123,\n \"billing_start_date\": \"2023-12-25\",\n \"charge_automatically\": true,\n \"components\": {\n \"extra_components\": [\n {\n \"name\": \"<string>\",\n \"price_entry\": {\n \"id\": \"<string>\"\n },\n \"product_ref\": {\n \"id\": \"<string>\"\n }\n }\n ],\n \"overridden_components\": [\n {\n \"component_id\": \"<string>\",\n \"name\": \"<string>\",\n \"price_entry\": {\n \"id\": \"<string>\"\n }\n }\n ],\n \"parameterized_components\": [\n {\n \"component_id\": \"<string>\",\n \"parameters\": {\n \"committed_capacity\": 1,\n \"initial_slot_count\": 1\n }\n }\n ],\n \"remove_components\": [\n \"<string>\"\n ]\n },\n \"coupon_code\": \"<string>\",\n \"coupon_ids\": [\n \"<string>\"\n ],\n \"end_date\": \"2023-12-25\",\n \"expires_in_hours\": 1,\n \"invoice_memo\": \"<string>\",\n \"invoice_threshold\": \"<string>\",\n \"metadata\": \"<unknown>\",\n \"net_terms\": 123,\n \"payment_methods_config\": {\n \"config\": {\n \"card\": {\n \"enabled\": true\n },\n \"direct_debit\": {\n \"enabled\": true\n }\n }\n },\n \"purchase_order\": \"<string>\",\n \"trial_duration_days\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/v1/checkout-sessions")
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 \"customer_id\": \"<string>\",\n \"plan_version_id\": \"<string>\",\n \"add_ons\": [\n {\n \"add_on_id\": \"<string>\",\n \"customization\": {\n \"price_entry\": {\n \"id\": \"<string>\"\n },\n \"name\": \"<string>\"\n },\n \"quantity\": 1\n }\n ],\n \"auto_advance_invoices\": true,\n \"billing_day_anchor\": 123,\n \"billing_start_date\": \"2023-12-25\",\n \"charge_automatically\": true,\n \"components\": {\n \"extra_components\": [\n {\n \"name\": \"<string>\",\n \"price_entry\": {\n \"id\": \"<string>\"\n },\n \"product_ref\": {\n \"id\": \"<string>\"\n }\n }\n ],\n \"overridden_components\": [\n {\n \"component_id\": \"<string>\",\n \"name\": \"<string>\",\n \"price_entry\": {\n \"id\": \"<string>\"\n }\n }\n ],\n \"parameterized_components\": [\n {\n \"component_id\": \"<string>\",\n \"parameters\": {\n \"committed_capacity\": 1,\n \"initial_slot_count\": 1\n }\n }\n ],\n \"remove_components\": [\n \"<string>\"\n ]\n },\n \"coupon_code\": \"<string>\",\n \"coupon_ids\": [\n \"<string>\"\n ],\n \"end_date\": \"2023-12-25\",\n \"expires_in_hours\": 1,\n \"invoice_memo\": \"<string>\",\n \"invoice_threshold\": \"<string>\",\n \"metadata\": \"<unknown>\",\n \"net_terms\": 123,\n \"payment_methods_config\": {\n \"config\": {\n \"card\": {\n \"enabled\": true\n },\n \"direct_debit\": {\n \"enabled\": true\n }\n }\n },\n \"purchase_order\": \"<string>\",\n \"trial_duration_days\": 123\n}"
response = http.request(request)
puts response.read_body{
"session": {
"created_at": "2023-11-07T05:31:56Z",
"customer_id": "<string>",
"id": "<string>",
"plan_version_id": "<string>",
"billing_day_anchor": 123,
"billing_start_date": "2023-12-25",
"checkout_url": "<string>",
"completed_at": "2023-11-07T05:31:56Z",
"coupon_code": "<string>",
"expires_at": "2023-11-07T05:31:56Z",
"net_terms": 123,
"payment_methods_config": {
"config": {
"card": {
"enabled": true
},
"direct_debit": {
"enabled": true
}
}
},
"subscription_id": "sub_7n42DGM5Tflk9n8mt7Fhc7",
"trial_duration_days": 123
}
}{
"message": "<string>"
}{
"message": "<string>"
}{
"message": "<string>"
}{
"message": "<string>"
}Checkout Sessions
Create a checkout session
POST
/
api
/
v1
/
checkout-sessions
Create a checkout session
curl --request POST \
--url https://api.example.com/api/v1/checkout-sessions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"customer_id": "<string>",
"plan_version_id": "<string>",
"add_ons": [
{
"add_on_id": "<string>",
"customization": {
"price_entry": {
"id": "<string>"
},
"name": "<string>"
},
"quantity": 1
}
],
"auto_advance_invoices": true,
"billing_day_anchor": 123,
"billing_start_date": "2023-12-25",
"charge_automatically": true,
"components": {
"extra_components": [
{
"name": "<string>",
"price_entry": {
"id": "<string>"
},
"product_ref": {
"id": "<string>"
}
}
],
"overridden_components": [
{
"component_id": "<string>",
"name": "<string>",
"price_entry": {
"id": "<string>"
}
}
],
"parameterized_components": [
{
"component_id": "<string>",
"parameters": {
"committed_capacity": 1,
"initial_slot_count": 1
}
}
],
"remove_components": [
"<string>"
]
},
"coupon_code": "<string>",
"coupon_ids": [
"<string>"
],
"end_date": "2023-12-25",
"expires_in_hours": 1,
"invoice_memo": "<string>",
"invoice_threshold": "<string>",
"metadata": "<unknown>",
"net_terms": 123,
"payment_methods_config": {
"config": {
"card": {
"enabled": true
},
"direct_debit": {
"enabled": true
}
}
},
"purchase_order": "<string>",
"trial_duration_days": 123
}
'import requests
url = "https://api.example.com/api/v1/checkout-sessions"
payload = {
"customer_id": "<string>",
"plan_version_id": "<string>",
"add_ons": [
{
"add_on_id": "<string>",
"customization": {
"price_entry": { "id": "<string>" },
"name": "<string>"
},
"quantity": 1
}
],
"auto_advance_invoices": True,
"billing_day_anchor": 123,
"billing_start_date": "2023-12-25",
"charge_automatically": True,
"components": {
"extra_components": [
{
"name": "<string>",
"price_entry": { "id": "<string>" },
"product_ref": { "id": "<string>" }
}
],
"overridden_components": [
{
"component_id": "<string>",
"name": "<string>",
"price_entry": { "id": "<string>" }
}
],
"parameterized_components": [
{
"component_id": "<string>",
"parameters": {
"committed_capacity": 1,
"initial_slot_count": 1
}
}
],
"remove_components": ["<string>"]
},
"coupon_code": "<string>",
"coupon_ids": ["<string>"],
"end_date": "2023-12-25",
"expires_in_hours": 1,
"invoice_memo": "<string>",
"invoice_threshold": "<string>",
"metadata": "<unknown>",
"net_terms": 123,
"payment_methods_config": { "config": {
"card": { "enabled": True },
"direct_debit": { "enabled": True }
} },
"purchase_order": "<string>",
"trial_duration_days": 123
}
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({
customer_id: '<string>',
plan_version_id: '<string>',
add_ons: [
{
add_on_id: '<string>',
customization: {price_entry: {id: '<string>'}, name: '<string>'},
quantity: 1
}
],
auto_advance_invoices: true,
billing_day_anchor: 123,
billing_start_date: '2023-12-25',
charge_automatically: true,
components: {
extra_components: [
{name: '<string>', price_entry: {id: '<string>'}, product_ref: {id: '<string>'}}
],
overridden_components: [{component_id: '<string>', name: '<string>', price_entry: {id: '<string>'}}],
parameterized_components: [
{
component_id: '<string>',
parameters: {committed_capacity: 1, initial_slot_count: 1}
}
],
remove_components: ['<string>']
},
coupon_code: '<string>',
coupon_ids: ['<string>'],
end_date: '2023-12-25',
expires_in_hours: 1,
invoice_memo: '<string>',
invoice_threshold: '<string>',
metadata: '<unknown>',
net_terms: 123,
payment_methods_config: {config: {card: {enabled: true}, direct_debit: {enabled: true}}},
purchase_order: '<string>',
trial_duration_days: 123
})
};
fetch('https://api.example.com/api/v1/checkout-sessions', 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.example.com/api/v1/checkout-sessions",
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([
'customer_id' => '<string>',
'plan_version_id' => '<string>',
'add_ons' => [
[
'add_on_id' => '<string>',
'customization' => [
'price_entry' => [
'id' => '<string>'
],
'name' => '<string>'
],
'quantity' => 1
]
],
'auto_advance_invoices' => true,
'billing_day_anchor' => 123,
'billing_start_date' => '2023-12-25',
'charge_automatically' => true,
'components' => [
'extra_components' => [
[
'name' => '<string>',
'price_entry' => [
'id' => '<string>'
],
'product_ref' => [
'id' => '<string>'
]
]
],
'overridden_components' => [
[
'component_id' => '<string>',
'name' => '<string>',
'price_entry' => [
'id' => '<string>'
]
]
],
'parameterized_components' => [
[
'component_id' => '<string>',
'parameters' => [
'committed_capacity' => 1,
'initial_slot_count' => 1
]
]
],
'remove_components' => [
'<string>'
]
],
'coupon_code' => '<string>',
'coupon_ids' => [
'<string>'
],
'end_date' => '2023-12-25',
'expires_in_hours' => 1,
'invoice_memo' => '<string>',
'invoice_threshold' => '<string>',
'metadata' => '<unknown>',
'net_terms' => 123,
'payment_methods_config' => [
'config' => [
'card' => [
'enabled' => true
],
'direct_debit' => [
'enabled' => true
]
]
],
'purchase_order' => '<string>',
'trial_duration_days' => 123
]),
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.example.com/api/v1/checkout-sessions"
payload := strings.NewReader("{\n \"customer_id\": \"<string>\",\n \"plan_version_id\": \"<string>\",\n \"add_ons\": [\n {\n \"add_on_id\": \"<string>\",\n \"customization\": {\n \"price_entry\": {\n \"id\": \"<string>\"\n },\n \"name\": \"<string>\"\n },\n \"quantity\": 1\n }\n ],\n \"auto_advance_invoices\": true,\n \"billing_day_anchor\": 123,\n \"billing_start_date\": \"2023-12-25\",\n \"charge_automatically\": true,\n \"components\": {\n \"extra_components\": [\n {\n \"name\": \"<string>\",\n \"price_entry\": {\n \"id\": \"<string>\"\n },\n \"product_ref\": {\n \"id\": \"<string>\"\n }\n }\n ],\n \"overridden_components\": [\n {\n \"component_id\": \"<string>\",\n \"name\": \"<string>\",\n \"price_entry\": {\n \"id\": \"<string>\"\n }\n }\n ],\n \"parameterized_components\": [\n {\n \"component_id\": \"<string>\",\n \"parameters\": {\n \"committed_capacity\": 1,\n \"initial_slot_count\": 1\n }\n }\n ],\n \"remove_components\": [\n \"<string>\"\n ]\n },\n \"coupon_code\": \"<string>\",\n \"coupon_ids\": [\n \"<string>\"\n ],\n \"end_date\": \"2023-12-25\",\n \"expires_in_hours\": 1,\n \"invoice_memo\": \"<string>\",\n \"invoice_threshold\": \"<string>\",\n \"metadata\": \"<unknown>\",\n \"net_terms\": 123,\n \"payment_methods_config\": {\n \"config\": {\n \"card\": {\n \"enabled\": true\n },\n \"direct_debit\": {\n \"enabled\": true\n }\n }\n },\n \"purchase_order\": \"<string>\",\n \"trial_duration_days\": 123\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.example.com/api/v1/checkout-sessions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"customer_id\": \"<string>\",\n \"plan_version_id\": \"<string>\",\n \"add_ons\": [\n {\n \"add_on_id\": \"<string>\",\n \"customization\": {\n \"price_entry\": {\n \"id\": \"<string>\"\n },\n \"name\": \"<string>\"\n },\n \"quantity\": 1\n }\n ],\n \"auto_advance_invoices\": true,\n \"billing_day_anchor\": 123,\n \"billing_start_date\": \"2023-12-25\",\n \"charge_automatically\": true,\n \"components\": {\n \"extra_components\": [\n {\n \"name\": \"<string>\",\n \"price_entry\": {\n \"id\": \"<string>\"\n },\n \"product_ref\": {\n \"id\": \"<string>\"\n }\n }\n ],\n \"overridden_components\": [\n {\n \"component_id\": \"<string>\",\n \"name\": \"<string>\",\n \"price_entry\": {\n \"id\": \"<string>\"\n }\n }\n ],\n \"parameterized_components\": [\n {\n \"component_id\": \"<string>\",\n \"parameters\": {\n \"committed_capacity\": 1,\n \"initial_slot_count\": 1\n }\n }\n ],\n \"remove_components\": [\n \"<string>\"\n ]\n },\n \"coupon_code\": \"<string>\",\n \"coupon_ids\": [\n \"<string>\"\n ],\n \"end_date\": \"2023-12-25\",\n \"expires_in_hours\": 1,\n \"invoice_memo\": \"<string>\",\n \"invoice_threshold\": \"<string>\",\n \"metadata\": \"<unknown>\",\n \"net_terms\": 123,\n \"payment_methods_config\": {\n \"config\": {\n \"card\": {\n \"enabled\": true\n },\n \"direct_debit\": {\n \"enabled\": true\n }\n }\n },\n \"purchase_order\": \"<string>\",\n \"trial_duration_days\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/v1/checkout-sessions")
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 \"customer_id\": \"<string>\",\n \"plan_version_id\": \"<string>\",\n \"add_ons\": [\n {\n \"add_on_id\": \"<string>\",\n \"customization\": {\n \"price_entry\": {\n \"id\": \"<string>\"\n },\n \"name\": \"<string>\"\n },\n \"quantity\": 1\n }\n ],\n \"auto_advance_invoices\": true,\n \"billing_day_anchor\": 123,\n \"billing_start_date\": \"2023-12-25\",\n \"charge_automatically\": true,\n \"components\": {\n \"extra_components\": [\n {\n \"name\": \"<string>\",\n \"price_entry\": {\n \"id\": \"<string>\"\n },\n \"product_ref\": {\n \"id\": \"<string>\"\n }\n }\n ],\n \"overridden_components\": [\n {\n \"component_id\": \"<string>\",\n \"name\": \"<string>\",\n \"price_entry\": {\n \"id\": \"<string>\"\n }\n }\n ],\n \"parameterized_components\": [\n {\n \"component_id\": \"<string>\",\n \"parameters\": {\n \"committed_capacity\": 1,\n \"initial_slot_count\": 1\n }\n }\n ],\n \"remove_components\": [\n \"<string>\"\n ]\n },\n \"coupon_code\": \"<string>\",\n \"coupon_ids\": [\n \"<string>\"\n ],\n \"end_date\": \"2023-12-25\",\n \"expires_in_hours\": 1,\n \"invoice_memo\": \"<string>\",\n \"invoice_threshold\": \"<string>\",\n \"metadata\": \"<unknown>\",\n \"net_terms\": 123,\n \"payment_methods_config\": {\n \"config\": {\n \"card\": {\n \"enabled\": true\n },\n \"direct_debit\": {\n \"enabled\": true\n }\n }\n },\n \"purchase_order\": \"<string>\",\n \"trial_duration_days\": 123\n}"
response = http.request(request)
puts response.read_body{
"session": {
"created_at": "2023-11-07T05:31:56Z",
"customer_id": "<string>",
"id": "<string>",
"plan_version_id": "<string>",
"billing_day_anchor": 123,
"billing_start_date": "2023-12-25",
"checkout_url": "<string>",
"completed_at": "2023-11-07T05:31:56Z",
"coupon_code": "<string>",
"expires_at": "2023-11-07T05:31:56Z",
"net_terms": 123,
"payment_methods_config": {
"config": {
"card": {
"enabled": true
},
"direct_debit": {
"enabled": true
}
}
},
"subscription_id": "sub_7n42DGM5Tflk9n8mt7Fhc7",
"trial_duration_days": 123
}
}{
"message": "<string>"
}{
"message": "<string>"
}{
"message": "<string>"
}{
"message": "<string>"
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
application/json
Customer ID or alias
Example:
"plv_7n42DGM5Tflk9n8mt7Fhc7"
Show child attributes
Show child attributes
If false, invoices will stay in Draft until manually reviewed and finalized. Default is true.
Automatically try to charge the customer's configured payment method on finalize. Default is true.
Show child attributes
Show child attributes
Session expiry time in hours. Default is 1 hour for self-serve checkout.
Required range:
x >= 0Payment methods configuration. If not specified, inherits from the invoicing entity.
- Option 1
- Option 2
- Option 3
Show child attributes
Show child attributes
Response
Checkout session created
Show child attributes
Show child attributes
⌘I