curl --request POST \
--url https://api.kyrenpay.com/v1/checkouts \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"productId": "prod_abc123",
"successUrl": "https://example.com/success",
"cancelUrl": "https://example.com/cancel",
"customerEmail": "customer@example.com",
"displayMerchantName": "Campaign Store",
"metadata": {
"userId": "user_456"
}
}
'import requests
url = "https://api.kyrenpay.com/v1/checkouts"
payload = {
"productId": "prod_abc123",
"successUrl": "https://example.com/success",
"cancelUrl": "https://example.com/cancel",
"customerEmail": "customer@example.com",
"displayMerchantName": "Campaign Store",
"metadata": { "userId": "user_456" }
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
productId: 'prod_abc123',
successUrl: 'https://example.com/success',
cancelUrl: 'https://example.com/cancel',
customerEmail: 'customer@example.com',
displayMerchantName: 'Campaign Store',
metadata: {userId: 'user_456'}
})
};
fetch('https://api.kyrenpay.com/v1/checkouts', 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.kyrenpay.com/v1/checkouts",
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([
'productId' => 'prod_abc123',
'successUrl' => 'https://example.com/success',
'cancelUrl' => 'https://example.com/cancel',
'customerEmail' => 'customer@example.com',
'displayMerchantName' => 'Campaign Store',
'metadata' => [
'userId' => 'user_456'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$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.kyrenpay.com/v1/checkouts"
payload := strings.NewReader("{\n \"productId\": \"prod_abc123\",\n \"successUrl\": \"https://example.com/success\",\n \"cancelUrl\": \"https://example.com/cancel\",\n \"customerEmail\": \"customer@example.com\",\n \"displayMerchantName\": \"Campaign Store\",\n \"metadata\": {\n \"userId\": \"user_456\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
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.kyrenpay.com/v1/checkouts")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"productId\": \"prod_abc123\",\n \"successUrl\": \"https://example.com/success\",\n \"cancelUrl\": \"https://example.com/cancel\",\n \"customerEmail\": \"customer@example.com\",\n \"displayMerchantName\": \"Campaign Store\",\n \"metadata\": {\n \"userId\": \"user_456\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.kyrenpay.com/v1/checkouts")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"productId\": \"prod_abc123\",\n \"successUrl\": \"https://example.com/success\",\n \"cancelUrl\": \"https://example.com/cancel\",\n \"customerEmail\": \"customer@example.com\",\n \"displayMerchantName\": \"Campaign Store\",\n \"metadata\": {\n \"userId\": \"user_456\"\n }\n}"
response = http.request(request)
puts response.read_body{
"code": 0,
"message": "success",
"data": {
"id": "cs_xyz789",
"productId": "prod_abc123",
"amount": "9.99",
"currency": "USD",
"status": "OPEN",
"url": "https://payment.kyren.io/checkout/cs_xyz789",
"expiresAt": 1736934000000,
"createdAt": 1736932200000
}
}{
"code": 400,
"message": "Bad Request",
"error": {
"field": "productId",
"reason": "Product ID is required"
}
}{
"code": 401,
"message": "Unauthorized"
}Create a checkout session
Creates a new checkout session for a product. Returns a URL where you can redirect your customer to complete the payment. Checkout sessions expire after 24 hours.
curl --request POST \
--url https://api.kyrenpay.com/v1/checkouts \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"productId": "prod_abc123",
"successUrl": "https://example.com/success",
"cancelUrl": "https://example.com/cancel",
"customerEmail": "customer@example.com",
"displayMerchantName": "Campaign Store",
"metadata": {
"userId": "user_456"
}
}
'import requests
url = "https://api.kyrenpay.com/v1/checkouts"
payload = {
"productId": "prod_abc123",
"successUrl": "https://example.com/success",
"cancelUrl": "https://example.com/cancel",
"customerEmail": "customer@example.com",
"displayMerchantName": "Campaign Store",
"metadata": { "userId": "user_456" }
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
productId: 'prod_abc123',
successUrl: 'https://example.com/success',
cancelUrl: 'https://example.com/cancel',
customerEmail: 'customer@example.com',
displayMerchantName: 'Campaign Store',
metadata: {userId: 'user_456'}
})
};
fetch('https://api.kyrenpay.com/v1/checkouts', 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.kyrenpay.com/v1/checkouts",
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([
'productId' => 'prod_abc123',
'successUrl' => 'https://example.com/success',
'cancelUrl' => 'https://example.com/cancel',
'customerEmail' => 'customer@example.com',
'displayMerchantName' => 'Campaign Store',
'metadata' => [
'userId' => 'user_456'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$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.kyrenpay.com/v1/checkouts"
payload := strings.NewReader("{\n \"productId\": \"prod_abc123\",\n \"successUrl\": \"https://example.com/success\",\n \"cancelUrl\": \"https://example.com/cancel\",\n \"customerEmail\": \"customer@example.com\",\n \"displayMerchantName\": \"Campaign Store\",\n \"metadata\": {\n \"userId\": \"user_456\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
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.kyrenpay.com/v1/checkouts")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"productId\": \"prod_abc123\",\n \"successUrl\": \"https://example.com/success\",\n \"cancelUrl\": \"https://example.com/cancel\",\n \"customerEmail\": \"customer@example.com\",\n \"displayMerchantName\": \"Campaign Store\",\n \"metadata\": {\n \"userId\": \"user_456\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.kyrenpay.com/v1/checkouts")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"productId\": \"prod_abc123\",\n \"successUrl\": \"https://example.com/success\",\n \"cancelUrl\": \"https://example.com/cancel\",\n \"customerEmail\": \"customer@example.com\",\n \"displayMerchantName\": \"Campaign Store\",\n \"metadata\": {\n \"userId\": \"user_456\"\n }\n}"
response = http.request(request)
puts response.read_body{
"code": 0,
"message": "success",
"data": {
"id": "cs_xyz789",
"productId": "prod_abc123",
"amount": "9.99",
"currency": "USD",
"status": "OPEN",
"url": "https://payment.kyren.io/checkout/cs_xyz789",
"expiresAt": 1736934000000,
"createdAt": 1736932200000
}
}{
"code": 400,
"message": "Bad Request",
"error": {
"field": "productId",
"reason": "Product ID is required"
}
}{
"code": 401,
"message": "Unauthorized"
}Authorizations
Your API key. Public production API-key endpoints accept kyren_live_* keys. Staging credentials are environment-specific and must be used only with the staging environment for which Kyren issued them.
Body
The ID of the product to create a checkout for
URL to redirect the customer to after successful payment
URL to redirect the customer to if they cancel the payment
Pre-fill the customer's email on the checkout page
Pre-fill the customer's name on the checkout page
Optional per-checkout merchant display name shown on the hosted checkout page. Also accepted as display_merchant_name.
80Arbitrary key-value pairs attached to the checkout and resulting order
Show child attributes
Show child attributes