Create a checkout session
curl --request POST \
--url http://localhost:3001/api/v1/business/payment/session \
--header 'Content-Type: application/json' \
--header 'x-api-key: <x-api-key>' \
--data '
{
"amount": 5.99,
"currency": "<string>",
"successUrl": "<string>",
"cancelUrl": "<string>",
"description": "<string>",
"customerEmail": "jsmith@example.com",
"metadata": {},
"expiresIn": 301,
"savedTokenId": "<string>",
"customerIp": "<string>"
}
'import requests
url = "http://localhost:3001/api/v1/business/payment/session"
payload = {
"amount": 5.99,
"currency": "<string>",
"successUrl": "<string>",
"cancelUrl": "<string>",
"description": "<string>",
"customerEmail": "jsmith@example.com",
"metadata": {},
"expiresIn": 301,
"savedTokenId": "<string>",
"customerIp": "<string>"
}
headers = {
"x-api-key": "<x-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': '<x-api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
amount: 5.99,
currency: '<string>',
successUrl: '<string>',
cancelUrl: '<string>',
description: '<string>',
customerEmail: 'jsmith@example.com',
metadata: {},
expiresIn: 301,
savedTokenId: '<string>',
customerIp: '<string>'
})
};
fetch('http://localhost:3001/api/v1/business/payment/session', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "3001",
CURLOPT_URL => "http://localhost:3001/api/v1/business/payment/session",
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([
'amount' => 5.99,
'currency' => '<string>',
'successUrl' => '<string>',
'cancelUrl' => '<string>',
'description' => '<string>',
'customerEmail' => 'jsmith@example.com',
'metadata' => [
],
'expiresIn' => 301,
'savedTokenId' => '<string>',
'customerIp' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <x-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 := "http://localhost:3001/api/v1/business/payment/session"
payload := strings.NewReader("{\n \"amount\": 5.99,\n \"currency\": \"<string>\",\n \"successUrl\": \"<string>\",\n \"cancelUrl\": \"<string>\",\n \"description\": \"<string>\",\n \"customerEmail\": \"jsmith@example.com\",\n \"metadata\": {},\n \"expiresIn\": 301,\n \"savedTokenId\": \"<string>\",\n \"customerIp\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<x-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("http://localhost:3001/api/v1/business/payment/session")
.header("x-api-key", "<x-api-key>")
.header("Content-Type", "application/json")
.body("{\n \"amount\": 5.99,\n \"currency\": \"<string>\",\n \"successUrl\": \"<string>\",\n \"cancelUrl\": \"<string>\",\n \"description\": \"<string>\",\n \"customerEmail\": \"jsmith@example.com\",\n \"metadata\": {},\n \"expiresIn\": 301,\n \"savedTokenId\": \"<string>\",\n \"customerIp\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://localhost:3001/api/v1/business/payment/session")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<x-api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"amount\": 5.99,\n \"currency\": \"<string>\",\n \"successUrl\": \"<string>\",\n \"cancelUrl\": \"<string>\",\n \"description\": \"<string>\",\n \"customerEmail\": \"jsmith@example.com\",\n \"metadata\": {},\n \"expiresIn\": 301,\n \"savedTokenId\": \"<string>\",\n \"customerIp\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"data": {
"sessionId": "<string>",
"status": "<string>",
"checkoutUrl": "<string>",
"threeDsUrl": "<string>",
"paymentId": "<string>",
"transactionId": "<string>",
"error": "<string>",
"expiresAt": "2023-11-07T05:31:56Z",
"amount": 123,
"currency": "<string>",
"availableMethods": [
{
"provider": "<string>",
"isActive": true,
"supportedCurrencies": [
"<string>"
]
}
],
"pspPublicKeys": {
"breeze": "<string>"
},
"localRailCorridors": [
{
"country": "SN",
"currency": "xof",
"rails": [
"bank",
"momo"
],
"minAmount": 1000,
"maxAmount": 200000
}
],
"billingFieldsRequired": true,
"cardFields": {
"kind": "acquirer_elements",
"accountId": "<string>",
"environment": "sandbox",
"amount": 25.5,
"currency": "usd"
}
}
}{
"success": false,
"error": {
"code": "VALIDATION_ERROR",
"message": "email must be an email",
"statusCode": 400,
"errors": {}
}
}{
"success": false,
"error": {
"code": "VALIDATION_ERROR",
"message": "email must be an email",
"statusCode": 400,
"errors": {}
}
}{
"success": false,
"error": {
"code": "VALIDATION_ERROR",
"message": "email must be an email",
"statusCode": 400,
"errors": {}
}
}{
"success": false,
"error": {
"code": "VALIDATION_ERROR",
"message": "email must be an email",
"statusCode": 400,
"errors": {}
}
}{
"success": false,
"error": {
"code": "VALIDATION_ERROR",
"message": "email must be an email",
"statusCode": 400,
"errors": {}
}
}{
"success": false,
"error": {
"code": "VALIDATION_ERROR",
"message": "email must be an email",
"statusCode": 400,
"errors": {}
}
}{
"success": false,
"error": {
"code": "VALIDATION_ERROR",
"message": "email must be an email",
"statusCode": 400,
"errors": {}
}
}{
"success": false,
"error": {
"code": "VALIDATION_ERROR",
"message": "email must be an email",
"statusCode": 400,
"errors": {}
}
}Payments
Create a checkout session
Creates a hosted checkout session for one amount and returns checkoutUrl to send the payer to, valid for expiresIn seconds (one hour by default). If you include card or savedTokenId in the body the session is charged immediately instead and no checkoutUrl comes back — the response then reports processing, 3ds_required with a threeDsUrl, or failed.
POST
/
api
/
v1
/
business
/
payment
/
session
Create a checkout session
curl --request POST \
--url http://localhost:3001/api/v1/business/payment/session \
--header 'Content-Type: application/json' \
--header 'x-api-key: <x-api-key>' \
--data '
{
"amount": 5.99,
"currency": "<string>",
"successUrl": "<string>",
"cancelUrl": "<string>",
"description": "<string>",
"customerEmail": "jsmith@example.com",
"metadata": {},
"expiresIn": 301,
"savedTokenId": "<string>",
"customerIp": "<string>"
}
'import requests
url = "http://localhost:3001/api/v1/business/payment/session"
payload = {
"amount": 5.99,
"currency": "<string>",
"successUrl": "<string>",
"cancelUrl": "<string>",
"description": "<string>",
"customerEmail": "jsmith@example.com",
"metadata": {},
"expiresIn": 301,
"savedTokenId": "<string>",
"customerIp": "<string>"
}
headers = {
"x-api-key": "<x-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': '<x-api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
amount: 5.99,
currency: '<string>',
successUrl: '<string>',
cancelUrl: '<string>',
description: '<string>',
customerEmail: 'jsmith@example.com',
metadata: {},
expiresIn: 301,
savedTokenId: '<string>',
customerIp: '<string>'
})
};
fetch('http://localhost:3001/api/v1/business/payment/session', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "3001",
CURLOPT_URL => "http://localhost:3001/api/v1/business/payment/session",
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([
'amount' => 5.99,
'currency' => '<string>',
'successUrl' => '<string>',
'cancelUrl' => '<string>',
'description' => '<string>',
'customerEmail' => 'jsmith@example.com',
'metadata' => [
],
'expiresIn' => 301,
'savedTokenId' => '<string>',
'customerIp' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <x-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 := "http://localhost:3001/api/v1/business/payment/session"
payload := strings.NewReader("{\n \"amount\": 5.99,\n \"currency\": \"<string>\",\n \"successUrl\": \"<string>\",\n \"cancelUrl\": \"<string>\",\n \"description\": \"<string>\",\n \"customerEmail\": \"jsmith@example.com\",\n \"metadata\": {},\n \"expiresIn\": 301,\n \"savedTokenId\": \"<string>\",\n \"customerIp\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<x-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("http://localhost:3001/api/v1/business/payment/session")
.header("x-api-key", "<x-api-key>")
.header("Content-Type", "application/json")
.body("{\n \"amount\": 5.99,\n \"currency\": \"<string>\",\n \"successUrl\": \"<string>\",\n \"cancelUrl\": \"<string>\",\n \"description\": \"<string>\",\n \"customerEmail\": \"jsmith@example.com\",\n \"metadata\": {},\n \"expiresIn\": 301,\n \"savedTokenId\": \"<string>\",\n \"customerIp\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://localhost:3001/api/v1/business/payment/session")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<x-api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"amount\": 5.99,\n \"currency\": \"<string>\",\n \"successUrl\": \"<string>\",\n \"cancelUrl\": \"<string>\",\n \"description\": \"<string>\",\n \"customerEmail\": \"jsmith@example.com\",\n \"metadata\": {},\n \"expiresIn\": 301,\n \"savedTokenId\": \"<string>\",\n \"customerIp\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"data": {
"sessionId": "<string>",
"status": "<string>",
"checkoutUrl": "<string>",
"threeDsUrl": "<string>",
"paymentId": "<string>",
"transactionId": "<string>",
"error": "<string>",
"expiresAt": "2023-11-07T05:31:56Z",
"amount": 123,
"currency": "<string>",
"availableMethods": [
{
"provider": "<string>",
"isActive": true,
"supportedCurrencies": [
"<string>"
]
}
],
"pspPublicKeys": {
"breeze": "<string>"
},
"localRailCorridors": [
{
"country": "SN",
"currency": "xof",
"rails": [
"bank",
"momo"
],
"minAmount": 1000,
"maxAmount": 200000
}
],
"billingFieldsRequired": true,
"cardFields": {
"kind": "acquirer_elements",
"accountId": "<string>",
"environment": "sandbox",
"amount": 25.5,
"currency": "usd"
}
}
}{
"success": false,
"error": {
"code": "VALIDATION_ERROR",
"message": "email must be an email",
"statusCode": 400,
"errors": {}
}
}{
"success": false,
"error": {
"code": "VALIDATION_ERROR",
"message": "email must be an email",
"statusCode": 400,
"errors": {}
}
}{
"success": false,
"error": {
"code": "VALIDATION_ERROR",
"message": "email must be an email",
"statusCode": 400,
"errors": {}
}
}{
"success": false,
"error": {
"code": "VALIDATION_ERROR",
"message": "email must be an email",
"statusCode": 400,
"errors": {}
}
}{
"success": false,
"error": {
"code": "VALIDATION_ERROR",
"message": "email must be an email",
"statusCode": 400,
"errors": {}
}
}{
"success": false,
"error": {
"code": "VALIDATION_ERROR",
"message": "email must be an email",
"statusCode": 400,
"errors": {}
}
}{
"success": false,
"error": {
"code": "VALIDATION_ERROR",
"message": "email must be an email",
"statusCode": 400,
"errors": {}
}
}{
"success": false,
"error": {
"code": "VALIDATION_ERROR",
"message": "email must be an email",
"statusCode": 400,
"errors": {}
}
}Body
application/json
