Create a checkout session
curl --request POST \
--url https://dash.getopenrails.com/api/gateway/sessions \
--header 'Content-Type: application/json' \
--data '
{
"product": "<string>",
"amount": 123,
"customer": "jsmith@example.com",
"redirectUrl": "<string>",
"metadata": {},
"environment": "sandbox",
"idempotencyKey": "<string>",
"clientReferenceId": "<string>"
}
'import requests
url = "https://dash.getopenrails.com/api/gateway/sessions"
payload = {
"product": "<string>",
"amount": 123,
"customer": "jsmith@example.com",
"redirectUrl": "<string>",
"metadata": {},
"environment": "sandbox",
"idempotencyKey": "<string>",
"clientReferenceId": "<string>"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
product: '<string>',
amount: 123,
customer: 'jsmith@example.com',
redirectUrl: '<string>',
metadata: {},
environment: 'sandbox',
idempotencyKey: '<string>',
clientReferenceId: '<string>'
})
};
fetch('https://dash.getopenrails.com/api/gateway/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://dash.getopenrails.com/api/gateway/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([
'product' => '<string>',
'amount' => 123,
'customer' => 'jsmith@example.com',
'redirectUrl' => '<string>',
'metadata' => [
],
'environment' => 'sandbox',
'idempotencyKey' => '<string>',
'clientReferenceId' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"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://dash.getopenrails.com/api/gateway/sessions"
payload := strings.NewReader("{\n \"product\": \"<string>\",\n \"amount\": 123,\n \"customer\": \"jsmith@example.com\",\n \"redirectUrl\": \"<string>\",\n \"metadata\": {},\n \"environment\": \"sandbox\",\n \"idempotencyKey\": \"<string>\",\n \"clientReferenceId\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
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://dash.getopenrails.com/api/gateway/sessions")
.header("Content-Type", "application/json")
.body("{\n \"product\": \"<string>\",\n \"amount\": 123,\n \"customer\": \"jsmith@example.com\",\n \"redirectUrl\": \"<string>\",\n \"metadata\": {},\n \"environment\": \"sandbox\",\n \"idempotencyKey\": \"<string>\",\n \"clientReferenceId\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://dash.getopenrails.com/api/gateway/sessions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"product\": \"<string>\",\n \"amount\": 123,\n \"customer\": \"jsmith@example.com\",\n \"redirectUrl\": \"<string>\",\n \"metadata\": {},\n \"environment\": \"sandbox\",\n \"idempotencyKey\": \"<string>\",\n \"clientReferenceId\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"object": "checkout_session",
"checkoutUrl": "<string>",
"amount": 123,
"currency": "<string>",
"redirectUrl": "<string>",
"customer": "jsmith@example.com",
"metadata": {},
"environment": "sandbox"
}{
"ok": false,
"error": {
"code": "<string>",
"message": "<string>",
"field": "<string>",
"suggestion": "<string>",
"issues": [
{
"path": "<string>",
"code": "<string>",
"message": "<string>"
}
]
}
}Reference
Create a checkout session
Creates a hosted checkout session and returns a checkoutUrl to redirect the buyer to.
POST
/
api
/
gateway
/
sessions
Create a checkout session
curl --request POST \
--url https://dash.getopenrails.com/api/gateway/sessions \
--header 'Content-Type: application/json' \
--data '
{
"product": "<string>",
"amount": 123,
"customer": "jsmith@example.com",
"redirectUrl": "<string>",
"metadata": {},
"environment": "sandbox",
"idempotencyKey": "<string>",
"clientReferenceId": "<string>"
}
'import requests
url = "https://dash.getopenrails.com/api/gateway/sessions"
payload = {
"product": "<string>",
"amount": 123,
"customer": "jsmith@example.com",
"redirectUrl": "<string>",
"metadata": {},
"environment": "sandbox",
"idempotencyKey": "<string>",
"clientReferenceId": "<string>"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
product: '<string>',
amount: 123,
customer: 'jsmith@example.com',
redirectUrl: '<string>',
metadata: {},
environment: 'sandbox',
idempotencyKey: '<string>',
clientReferenceId: '<string>'
})
};
fetch('https://dash.getopenrails.com/api/gateway/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://dash.getopenrails.com/api/gateway/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([
'product' => '<string>',
'amount' => 123,
'customer' => 'jsmith@example.com',
'redirectUrl' => '<string>',
'metadata' => [
],
'environment' => 'sandbox',
'idempotencyKey' => '<string>',
'clientReferenceId' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"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://dash.getopenrails.com/api/gateway/sessions"
payload := strings.NewReader("{\n \"product\": \"<string>\",\n \"amount\": 123,\n \"customer\": \"jsmith@example.com\",\n \"redirectUrl\": \"<string>\",\n \"metadata\": {},\n \"environment\": \"sandbox\",\n \"idempotencyKey\": \"<string>\",\n \"clientReferenceId\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
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://dash.getopenrails.com/api/gateway/sessions")
.header("Content-Type", "application/json")
.body("{\n \"product\": \"<string>\",\n \"amount\": 123,\n \"customer\": \"jsmith@example.com\",\n \"redirectUrl\": \"<string>\",\n \"metadata\": {},\n \"environment\": \"sandbox\",\n \"idempotencyKey\": \"<string>\",\n \"clientReferenceId\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://dash.getopenrails.com/api/gateway/sessions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"product\": \"<string>\",\n \"amount\": 123,\n \"customer\": \"jsmith@example.com\",\n \"redirectUrl\": \"<string>\",\n \"metadata\": {},\n \"environment\": \"sandbox\",\n \"idempotencyKey\": \"<string>\",\n \"clientReferenceId\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"object": "checkout_session",
"checkoutUrl": "<string>",
"amount": 123,
"currency": "<string>",
"redirectUrl": "<string>",
"customer": "jsmith@example.com",
"metadata": {},
"environment": "sandbox"
}{
"ok": false,
"error": {
"code": "<string>",
"message": "<string>",
"field": "<string>",
"suggestion": "<string>",
"issues": [
{
"path": "<string>",
"code": "<string>",
"message": "<string>"
}
]
}
}Body
application/json
Required string length:
1 - 120Required range:
x <= 10000Available options:
card, wallet, local Show child attributes
Show child attributes
Available options:
sandbox, production Required string length:
8 - 120Required string length:
3 - 120Response
Checkout session created
Checkout session ID with chk_* prefix.
Available options:
checkout_session Available options:
routed, pending, paid, failed, expired Show child attributes
Show child attributes
Available options:
sandbox, production ⌘I