curl --request POST \
--url https://api.cope.com/v1/commerce/checkouts \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'Idempotency-Key: <idempotency-key>' \
--data '
{
"buyer_identity": {
"country": "<string>",
"email": "<string>",
"postal_code": "<string>",
"billing_address": {
"city": "<string>",
"country": "<string>",
"line1": "<string>",
"line2": "<string>",
"postal_code": "<string>",
"region": "<string>"
},
"buyer_type": "<string>",
"company": "<string>",
"first_name": "<string>",
"last_name": "<string>",
"phone": "<string>",
"shipping_address": {
"city": "<string>",
"country": "<string>",
"line1": "<string>",
"line2": "<string>",
"postal_code": "<string>",
"region": "<string>"
},
"vat_id": "<string>"
},
"currency": "<string>",
"external_reference": "<string>",
"lines": [
{
"product_id": "prod_A1b2C3d4",
"plan_id": "<string>",
"quantity": 500
}
],
"checkout": {
"cancel_url": "<string>",
"embed_origin": "<string>",
"success_url": "<string>"
},
"locale": "<string>",
"metadata": {}
}
'import requests
url = "https://api.cope.com/v1/commerce/checkouts"
payload = {
"buyer_identity": {
"country": "<string>",
"email": "<string>",
"postal_code": "<string>",
"billing_address": {
"city": "<string>",
"country": "<string>",
"line1": "<string>",
"line2": "<string>",
"postal_code": "<string>",
"region": "<string>"
},
"buyer_type": "<string>",
"company": "<string>",
"first_name": "<string>",
"last_name": "<string>",
"phone": "<string>",
"shipping_address": {
"city": "<string>",
"country": "<string>",
"line1": "<string>",
"line2": "<string>",
"postal_code": "<string>",
"region": "<string>"
},
"vat_id": "<string>"
},
"currency": "<string>",
"external_reference": "<string>",
"lines": [
{
"product_id": "prod_A1b2C3d4",
"plan_id": "<string>",
"quantity": 500
}
],
"checkout": {
"cancel_url": "<string>",
"embed_origin": "<string>",
"success_url": "<string>"
},
"locale": "<string>",
"metadata": {}
}
headers = {
"Idempotency-Key": "<idempotency-key>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'Idempotency-Key': '<idempotency-key>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
buyer_identity: {
country: '<string>',
email: '<string>',
postal_code: '<string>',
billing_address: {
city: '<string>',
country: '<string>',
line1: '<string>',
line2: '<string>',
postal_code: '<string>',
region: '<string>'
},
buyer_type: '<string>',
company: '<string>',
first_name: '<string>',
last_name: '<string>',
phone: '<string>',
shipping_address: {
city: '<string>',
country: '<string>',
line1: '<string>',
line2: '<string>',
postal_code: '<string>',
region: '<string>'
},
vat_id: '<string>'
},
currency: '<string>',
external_reference: '<string>',
lines: [{product_id: 'prod_A1b2C3d4', plan_id: '<string>', quantity: 500}],
checkout: {cancel_url: '<string>', embed_origin: '<string>', success_url: '<string>'},
locale: '<string>',
metadata: {}
})
};
fetch('https://api.cope.com/v1/commerce/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.cope.com/v1/commerce/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([
'buyer_identity' => [
'country' => '<string>',
'email' => '<string>',
'postal_code' => '<string>',
'billing_address' => [
'city' => '<string>',
'country' => '<string>',
'line1' => '<string>',
'line2' => '<string>',
'postal_code' => '<string>',
'region' => '<string>'
],
'buyer_type' => '<string>',
'company' => '<string>',
'first_name' => '<string>',
'last_name' => '<string>',
'phone' => '<string>',
'shipping_address' => [
'city' => '<string>',
'country' => '<string>',
'line1' => '<string>',
'line2' => '<string>',
'postal_code' => '<string>',
'region' => '<string>'
],
'vat_id' => '<string>'
],
'currency' => '<string>',
'external_reference' => '<string>',
'lines' => [
[
'product_id' => 'prod_A1b2C3d4',
'plan_id' => '<string>',
'quantity' => 500
]
],
'checkout' => [
'cancel_url' => '<string>',
'embed_origin' => '<string>',
'success_url' => '<string>'
],
'locale' => '<string>',
'metadata' => [
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"Idempotency-Key: <idempotency-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.cope.com/v1/commerce/checkouts"
payload := strings.NewReader("{\n \"buyer_identity\": {\n \"country\": \"<string>\",\n \"email\": \"<string>\",\n \"postal_code\": \"<string>\",\n \"billing_address\": {\n \"city\": \"<string>\",\n \"country\": \"<string>\",\n \"line1\": \"<string>\",\n \"line2\": \"<string>\",\n \"postal_code\": \"<string>\",\n \"region\": \"<string>\"\n },\n \"buyer_type\": \"<string>\",\n \"company\": \"<string>\",\n \"first_name\": \"<string>\",\n \"last_name\": \"<string>\",\n \"phone\": \"<string>\",\n \"shipping_address\": {\n \"city\": \"<string>\",\n \"country\": \"<string>\",\n \"line1\": \"<string>\",\n \"line2\": \"<string>\",\n \"postal_code\": \"<string>\",\n \"region\": \"<string>\"\n },\n \"vat_id\": \"<string>\"\n },\n \"currency\": \"<string>\",\n \"external_reference\": \"<string>\",\n \"lines\": [\n {\n \"product_id\": \"prod_A1b2C3d4\",\n \"plan_id\": \"<string>\",\n \"quantity\": 500\n }\n ],\n \"checkout\": {\n \"cancel_url\": \"<string>\",\n \"embed_origin\": \"<string>\",\n \"success_url\": \"<string>\"\n },\n \"locale\": \"<string>\",\n \"metadata\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Idempotency-Key", "<idempotency-key>")
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.cope.com/v1/commerce/checkouts")
.header("Idempotency-Key", "<idempotency-key>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"buyer_identity\": {\n \"country\": \"<string>\",\n \"email\": \"<string>\",\n \"postal_code\": \"<string>\",\n \"billing_address\": {\n \"city\": \"<string>\",\n \"country\": \"<string>\",\n \"line1\": \"<string>\",\n \"line2\": \"<string>\",\n \"postal_code\": \"<string>\",\n \"region\": \"<string>\"\n },\n \"buyer_type\": \"<string>\",\n \"company\": \"<string>\",\n \"first_name\": \"<string>\",\n \"last_name\": \"<string>\",\n \"phone\": \"<string>\",\n \"shipping_address\": {\n \"city\": \"<string>\",\n \"country\": \"<string>\",\n \"line1\": \"<string>\",\n \"line2\": \"<string>\",\n \"postal_code\": \"<string>\",\n \"region\": \"<string>\"\n },\n \"vat_id\": \"<string>\"\n },\n \"currency\": \"<string>\",\n \"external_reference\": \"<string>\",\n \"lines\": [\n {\n \"product_id\": \"prod_A1b2C3d4\",\n \"plan_id\": \"<string>\",\n \"quantity\": 500\n }\n ],\n \"checkout\": {\n \"cancel_url\": \"<string>\",\n \"embed_origin\": \"<string>\",\n \"success_url\": \"<string>\"\n },\n \"locale\": \"<string>\",\n \"metadata\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cope.com/v1/commerce/checkouts")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Idempotency-Key"] = '<idempotency-key>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"buyer_identity\": {\n \"country\": \"<string>\",\n \"email\": \"<string>\",\n \"postal_code\": \"<string>\",\n \"billing_address\": {\n \"city\": \"<string>\",\n \"country\": \"<string>\",\n \"line1\": \"<string>\",\n \"line2\": \"<string>\",\n \"postal_code\": \"<string>\",\n \"region\": \"<string>\"\n },\n \"buyer_type\": \"<string>\",\n \"company\": \"<string>\",\n \"first_name\": \"<string>\",\n \"last_name\": \"<string>\",\n \"phone\": \"<string>\",\n \"shipping_address\": {\n \"city\": \"<string>\",\n \"country\": \"<string>\",\n \"line1\": \"<string>\",\n \"line2\": \"<string>\",\n \"postal_code\": \"<string>\",\n \"region\": \"<string>\"\n },\n \"vat_id\": \"<string>\"\n },\n \"currency\": \"<string>\",\n \"external_reference\": \"<string>\",\n \"lines\": [\n {\n \"product_id\": \"prod_A1b2C3d4\",\n \"plan_id\": \"<string>\",\n \"quantity\": 500\n }\n ],\n \"checkout\": {\n \"cancel_url\": \"<string>\",\n \"embed_origin\": \"<string>\",\n \"success_url\": \"<string>\"\n },\n \"locale\": \"<string>\",\n \"metadata\": {}\n}"
response = http.request(request)
puts response.read_bodyCreate a checkout
Creates a checkout from your server with its product, plan, buyer email and your reference
fixed, and returns its checkout_url for you to send the buyer to. On that page the buyer
cannot change the email you set; the other details stay theirs to correct. Your metadata
and external_reference cannot be changed by the buyer and arrive on the order’s webhooks.
checkout_url comes only with the create response. The checkout stores a digest of its
token, so retrieving the checkout does not return it; a repeat of the create with the same
Idempotency-Key within 24 hours replays that response, link included.
Idempotency-Key is required. A repeat with the same key answers with the same checkout.
Ids are COPE’s public ids: a line’s plan_id is the plan’s plan_ id; an integer is refused
with validation_error (422). A success_url or cancel_url must be one you registered as a
redirect URL, or the request is refused with invalid_redirect_url (422). A key COPE reserves
inside metadata is refused with reserved_metadata_key (422), and a member this operation
does not take with invalid_request (400).
To confirm a payment, retrieve the checkout by its chk_ id and read order, rather than
matching on external_reference.
Requires the orders permission at write. An API key holds a permission at the lower of its own level (read for a read-only key) and its holder’s role; a key without it is refused with 403.
curl --request POST \
--url https://api.cope.com/v1/commerce/checkouts \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'Idempotency-Key: <idempotency-key>' \
--data '
{
"buyer_identity": {
"country": "<string>",
"email": "<string>",
"postal_code": "<string>",
"billing_address": {
"city": "<string>",
"country": "<string>",
"line1": "<string>",
"line2": "<string>",
"postal_code": "<string>",
"region": "<string>"
},
"buyer_type": "<string>",
"company": "<string>",
"first_name": "<string>",
"last_name": "<string>",
"phone": "<string>",
"shipping_address": {
"city": "<string>",
"country": "<string>",
"line1": "<string>",
"line2": "<string>",
"postal_code": "<string>",
"region": "<string>"
},
"vat_id": "<string>"
},
"currency": "<string>",
"external_reference": "<string>",
"lines": [
{
"product_id": "prod_A1b2C3d4",
"plan_id": "<string>",
"quantity": 500
}
],
"checkout": {
"cancel_url": "<string>",
"embed_origin": "<string>",
"success_url": "<string>"
},
"locale": "<string>",
"metadata": {}
}
'import requests
url = "https://api.cope.com/v1/commerce/checkouts"
payload = {
"buyer_identity": {
"country": "<string>",
"email": "<string>",
"postal_code": "<string>",
"billing_address": {
"city": "<string>",
"country": "<string>",
"line1": "<string>",
"line2": "<string>",
"postal_code": "<string>",
"region": "<string>"
},
"buyer_type": "<string>",
"company": "<string>",
"first_name": "<string>",
"last_name": "<string>",
"phone": "<string>",
"shipping_address": {
"city": "<string>",
"country": "<string>",
"line1": "<string>",
"line2": "<string>",
"postal_code": "<string>",
"region": "<string>"
},
"vat_id": "<string>"
},
"currency": "<string>",
"external_reference": "<string>",
"lines": [
{
"product_id": "prod_A1b2C3d4",
"plan_id": "<string>",
"quantity": 500
}
],
"checkout": {
"cancel_url": "<string>",
"embed_origin": "<string>",
"success_url": "<string>"
},
"locale": "<string>",
"metadata": {}
}
headers = {
"Idempotency-Key": "<idempotency-key>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'Idempotency-Key': '<idempotency-key>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
buyer_identity: {
country: '<string>',
email: '<string>',
postal_code: '<string>',
billing_address: {
city: '<string>',
country: '<string>',
line1: '<string>',
line2: '<string>',
postal_code: '<string>',
region: '<string>'
},
buyer_type: '<string>',
company: '<string>',
first_name: '<string>',
last_name: '<string>',
phone: '<string>',
shipping_address: {
city: '<string>',
country: '<string>',
line1: '<string>',
line2: '<string>',
postal_code: '<string>',
region: '<string>'
},
vat_id: '<string>'
},
currency: '<string>',
external_reference: '<string>',
lines: [{product_id: 'prod_A1b2C3d4', plan_id: '<string>', quantity: 500}],
checkout: {cancel_url: '<string>', embed_origin: '<string>', success_url: '<string>'},
locale: '<string>',
metadata: {}
})
};
fetch('https://api.cope.com/v1/commerce/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.cope.com/v1/commerce/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([
'buyer_identity' => [
'country' => '<string>',
'email' => '<string>',
'postal_code' => '<string>',
'billing_address' => [
'city' => '<string>',
'country' => '<string>',
'line1' => '<string>',
'line2' => '<string>',
'postal_code' => '<string>',
'region' => '<string>'
],
'buyer_type' => '<string>',
'company' => '<string>',
'first_name' => '<string>',
'last_name' => '<string>',
'phone' => '<string>',
'shipping_address' => [
'city' => '<string>',
'country' => '<string>',
'line1' => '<string>',
'line2' => '<string>',
'postal_code' => '<string>',
'region' => '<string>'
],
'vat_id' => '<string>'
],
'currency' => '<string>',
'external_reference' => '<string>',
'lines' => [
[
'product_id' => 'prod_A1b2C3d4',
'plan_id' => '<string>',
'quantity' => 500
]
],
'checkout' => [
'cancel_url' => '<string>',
'embed_origin' => '<string>',
'success_url' => '<string>'
],
'locale' => '<string>',
'metadata' => [
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"Idempotency-Key: <idempotency-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.cope.com/v1/commerce/checkouts"
payload := strings.NewReader("{\n \"buyer_identity\": {\n \"country\": \"<string>\",\n \"email\": \"<string>\",\n \"postal_code\": \"<string>\",\n \"billing_address\": {\n \"city\": \"<string>\",\n \"country\": \"<string>\",\n \"line1\": \"<string>\",\n \"line2\": \"<string>\",\n \"postal_code\": \"<string>\",\n \"region\": \"<string>\"\n },\n \"buyer_type\": \"<string>\",\n \"company\": \"<string>\",\n \"first_name\": \"<string>\",\n \"last_name\": \"<string>\",\n \"phone\": \"<string>\",\n \"shipping_address\": {\n \"city\": \"<string>\",\n \"country\": \"<string>\",\n \"line1\": \"<string>\",\n \"line2\": \"<string>\",\n \"postal_code\": \"<string>\",\n \"region\": \"<string>\"\n },\n \"vat_id\": \"<string>\"\n },\n \"currency\": \"<string>\",\n \"external_reference\": \"<string>\",\n \"lines\": [\n {\n \"product_id\": \"prod_A1b2C3d4\",\n \"plan_id\": \"<string>\",\n \"quantity\": 500\n }\n ],\n \"checkout\": {\n \"cancel_url\": \"<string>\",\n \"embed_origin\": \"<string>\",\n \"success_url\": \"<string>\"\n },\n \"locale\": \"<string>\",\n \"metadata\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Idempotency-Key", "<idempotency-key>")
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.cope.com/v1/commerce/checkouts")
.header("Idempotency-Key", "<idempotency-key>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"buyer_identity\": {\n \"country\": \"<string>\",\n \"email\": \"<string>\",\n \"postal_code\": \"<string>\",\n \"billing_address\": {\n \"city\": \"<string>\",\n \"country\": \"<string>\",\n \"line1\": \"<string>\",\n \"line2\": \"<string>\",\n \"postal_code\": \"<string>\",\n \"region\": \"<string>\"\n },\n \"buyer_type\": \"<string>\",\n \"company\": \"<string>\",\n \"first_name\": \"<string>\",\n \"last_name\": \"<string>\",\n \"phone\": \"<string>\",\n \"shipping_address\": {\n \"city\": \"<string>\",\n \"country\": \"<string>\",\n \"line1\": \"<string>\",\n \"line2\": \"<string>\",\n \"postal_code\": \"<string>\",\n \"region\": \"<string>\"\n },\n \"vat_id\": \"<string>\"\n },\n \"currency\": \"<string>\",\n \"external_reference\": \"<string>\",\n \"lines\": [\n {\n \"product_id\": \"prod_A1b2C3d4\",\n \"plan_id\": \"<string>\",\n \"quantity\": 500\n }\n ],\n \"checkout\": {\n \"cancel_url\": \"<string>\",\n \"embed_origin\": \"<string>\",\n \"success_url\": \"<string>\"\n },\n \"locale\": \"<string>\",\n \"metadata\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cope.com/v1/commerce/checkouts")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Idempotency-Key"] = '<idempotency-key>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"buyer_identity\": {\n \"country\": \"<string>\",\n \"email\": \"<string>\",\n \"postal_code\": \"<string>\",\n \"billing_address\": {\n \"city\": \"<string>\",\n \"country\": \"<string>\",\n \"line1\": \"<string>\",\n \"line2\": \"<string>\",\n \"postal_code\": \"<string>\",\n \"region\": \"<string>\"\n },\n \"buyer_type\": \"<string>\",\n \"company\": \"<string>\",\n \"first_name\": \"<string>\",\n \"last_name\": \"<string>\",\n \"phone\": \"<string>\",\n \"shipping_address\": {\n \"city\": \"<string>\",\n \"country\": \"<string>\",\n \"line1\": \"<string>\",\n \"line2\": \"<string>\",\n \"postal_code\": \"<string>\",\n \"region\": \"<string>\"\n },\n \"vat_id\": \"<string>\"\n },\n \"currency\": \"<string>\",\n \"external_reference\": \"<string>\",\n \"lines\": [\n {\n \"product_id\": \"prod_A1b2C3d4\",\n \"plan_id\": \"<string>\",\n \"quantity\": 500\n }\n ],\n \"checkout\": {\n \"cancel_url\": \"<string>\",\n \"embed_origin\": \"<string>\",\n \"success_url\": \"<string>\"\n },\n \"locale\": \"<string>\",\n \"metadata\": {}\n}"
response = http.request(request)
puts response.read_bodyAuthorizations
Bearer credential for the public API: a live COPE API key (ck_live_*; keys issued earlier as cope_sk_live_* keep working). Dashboard sign-in tokens are not accepted.
Headers
Required. At most 255 characters of valid UTF-8 with no NUL byte. A retry that carries the same key and the same body returns the original response instead of performing the write a second time. The same key with a different body is refused with 409 idempotency_conflict. Keys are remembered for 24 hours. A returned original response carries the header Idempotent-Replayed: true.
255Body
Show child attributes
Show child attributes
1 - 2551Show child attributes
Show child attributes
Show child attributes
Show child attributes
Your own keys. external_reference, intended_payment_method and the keys COPE reserves are refused inside it with reserved_metadata_key.
Response
Successful response
Show child attributes
Show child attributes
Was this page helpful?