Create Payment Session
curl --request POST \
--url https://api.bkey.id/v1/payment-sessions/ \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"amount": 2500000,
"lineItems": [
{
"title": "<string>",
"quantity": 2,
"price": 1
}
],
"returnUrl": "<string>",
"merchantDomain": "<string>",
"externalOrderId": "<string>",
"currency": "USD",
"notifyUrl": "<string>",
"cancelUrl": "<string>",
"customerEmail": "jsmith@example.com",
"expiresInSecs": 1800
}
'import requests
url = "https://api.bkey.id/v1/payment-sessions/"
payload = {
"amount": 2500000,
"lineItems": [
{
"title": "<string>",
"quantity": 2,
"price": 1
}
],
"returnUrl": "<string>",
"merchantDomain": "<string>",
"externalOrderId": "<string>",
"currency": "USD",
"notifyUrl": "<string>",
"cancelUrl": "<string>",
"customerEmail": "jsmith@example.com",
"expiresInSecs": 1800
}
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({
amount: 2500000,
lineItems: [{title: '<string>', quantity: 2, price: 1}],
returnUrl: '<string>',
merchantDomain: '<string>',
externalOrderId: '<string>',
currency: 'USD',
notifyUrl: '<string>',
cancelUrl: '<string>',
customerEmail: 'jsmith@example.com',
expiresInSecs: 1800
})
};
fetch('https://api.bkey.id/v1/payment-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.bkey.id/v1/payment-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([
'amount' => 2500000,
'lineItems' => [
[
'title' => '<string>',
'quantity' => 2,
'price' => 1
]
],
'returnUrl' => '<string>',
'merchantDomain' => '<string>',
'externalOrderId' => '<string>',
'currency' => 'USD',
'notifyUrl' => '<string>',
'cancelUrl' => '<string>',
'customerEmail' => 'jsmith@example.com',
'expiresInSecs' => 1800
]),
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.bkey.id/v1/payment-sessions/"
payload := strings.NewReader("{\n \"amount\": 2500000,\n \"lineItems\": [\n {\n \"title\": \"<string>\",\n \"quantity\": 2,\n \"price\": 1\n }\n ],\n \"returnUrl\": \"<string>\",\n \"merchantDomain\": \"<string>\",\n \"externalOrderId\": \"<string>\",\n \"currency\": \"USD\",\n \"notifyUrl\": \"<string>\",\n \"cancelUrl\": \"<string>\",\n \"customerEmail\": \"jsmith@example.com\",\n \"expiresInSecs\": 1800\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.bkey.id/v1/payment-sessions/")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"amount\": 2500000,\n \"lineItems\": [\n {\n \"title\": \"<string>\",\n \"quantity\": 2,\n \"price\": 1\n }\n ],\n \"returnUrl\": \"<string>\",\n \"merchantDomain\": \"<string>\",\n \"externalOrderId\": \"<string>\",\n \"currency\": \"USD\",\n \"notifyUrl\": \"<string>\",\n \"cancelUrl\": \"<string>\",\n \"customerEmail\": \"jsmith@example.com\",\n \"expiresInSecs\": 1800\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.bkey.id/v1/payment-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 \"amount\": 2500000,\n \"lineItems\": [\n {\n \"title\": \"<string>\",\n \"quantity\": 2,\n \"price\": 1\n }\n ],\n \"returnUrl\": \"<string>\",\n \"merchantDomain\": \"<string>\",\n \"externalOrderId\": \"<string>\",\n \"currency\": \"USD\",\n \"notifyUrl\": \"<string>\",\n \"cancelUrl\": \"<string>\",\n \"customerEmail\": \"jsmith@example.com\",\n \"expiresInSecs\": 1800\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"paymentSession": {
"id": "<string>",
"status": "<string>",
"approvalUrl": "<string>",
"amount": 1,
"currency": "<string>",
"expiresAt": "2023-11-07T05:31:56Z",
"merchantName": "<string>",
"lineItems": [
{
"title": "<string>",
"quantity": 1,
"price": 1
}
],
"merchantDomain": "<string>",
"createdAt": "2023-11-07T05:31:56Z",
"externalOrderId": "<string>",
"sptId": "<string>",
"paymentIntentId": "<string>",
"returnUrl": "<string>",
"cancelUrl": "<string>",
"paymentResult": {}
}
}{
"success": false,
"error": {
"code": "<string>",
"message": "<string>"
}
}{
"success": false,
"error": {
"code": "<string>",
"message": "<string>"
}
}{
"success": false,
"error": {
"code": "<string>",
"message": "<string>"
}
}Payments
Create Payment Session
Create a payment session (merchant-facing). Called by plugins (WooCommerce, Medusa, etc.) to start a BKey-approved payment flow. The merchant authenticates with a mk_live_* / mk_test_* API key. Returns an approvalUrl to redirect the shopper to.
POST
/
v1
/
payment-sessions
/
Create Payment Session
curl --request POST \
--url https://api.bkey.id/v1/payment-sessions/ \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"amount": 2500000,
"lineItems": [
{
"title": "<string>",
"quantity": 2,
"price": 1
}
],
"returnUrl": "<string>",
"merchantDomain": "<string>",
"externalOrderId": "<string>",
"currency": "USD",
"notifyUrl": "<string>",
"cancelUrl": "<string>",
"customerEmail": "jsmith@example.com",
"expiresInSecs": 1800
}
'import requests
url = "https://api.bkey.id/v1/payment-sessions/"
payload = {
"amount": 2500000,
"lineItems": [
{
"title": "<string>",
"quantity": 2,
"price": 1
}
],
"returnUrl": "<string>",
"merchantDomain": "<string>",
"externalOrderId": "<string>",
"currency": "USD",
"notifyUrl": "<string>",
"cancelUrl": "<string>",
"customerEmail": "jsmith@example.com",
"expiresInSecs": 1800
}
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({
amount: 2500000,
lineItems: [{title: '<string>', quantity: 2, price: 1}],
returnUrl: '<string>',
merchantDomain: '<string>',
externalOrderId: '<string>',
currency: 'USD',
notifyUrl: '<string>',
cancelUrl: '<string>',
customerEmail: 'jsmith@example.com',
expiresInSecs: 1800
})
};
fetch('https://api.bkey.id/v1/payment-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.bkey.id/v1/payment-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([
'amount' => 2500000,
'lineItems' => [
[
'title' => '<string>',
'quantity' => 2,
'price' => 1
]
],
'returnUrl' => '<string>',
'merchantDomain' => '<string>',
'externalOrderId' => '<string>',
'currency' => 'USD',
'notifyUrl' => '<string>',
'cancelUrl' => '<string>',
'customerEmail' => 'jsmith@example.com',
'expiresInSecs' => 1800
]),
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.bkey.id/v1/payment-sessions/"
payload := strings.NewReader("{\n \"amount\": 2500000,\n \"lineItems\": [\n {\n \"title\": \"<string>\",\n \"quantity\": 2,\n \"price\": 1\n }\n ],\n \"returnUrl\": \"<string>\",\n \"merchantDomain\": \"<string>\",\n \"externalOrderId\": \"<string>\",\n \"currency\": \"USD\",\n \"notifyUrl\": \"<string>\",\n \"cancelUrl\": \"<string>\",\n \"customerEmail\": \"jsmith@example.com\",\n \"expiresInSecs\": 1800\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.bkey.id/v1/payment-sessions/")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"amount\": 2500000,\n \"lineItems\": [\n {\n \"title\": \"<string>\",\n \"quantity\": 2,\n \"price\": 1\n }\n ],\n \"returnUrl\": \"<string>\",\n \"merchantDomain\": \"<string>\",\n \"externalOrderId\": \"<string>\",\n \"currency\": \"USD\",\n \"notifyUrl\": \"<string>\",\n \"cancelUrl\": \"<string>\",\n \"customerEmail\": \"jsmith@example.com\",\n \"expiresInSecs\": 1800\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.bkey.id/v1/payment-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 \"amount\": 2500000,\n \"lineItems\": [\n {\n \"title\": \"<string>\",\n \"quantity\": 2,\n \"price\": 1\n }\n ],\n \"returnUrl\": \"<string>\",\n \"merchantDomain\": \"<string>\",\n \"externalOrderId\": \"<string>\",\n \"currency\": \"USD\",\n \"notifyUrl\": \"<string>\",\n \"cancelUrl\": \"<string>\",\n \"customerEmail\": \"jsmith@example.com\",\n \"expiresInSecs\": 1800\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"paymentSession": {
"id": "<string>",
"status": "<string>",
"approvalUrl": "<string>",
"amount": 1,
"currency": "<string>",
"expiresAt": "2023-11-07T05:31:56Z",
"merchantName": "<string>",
"lineItems": [
{
"title": "<string>",
"quantity": 1,
"price": 1
}
],
"merchantDomain": "<string>",
"createdAt": "2023-11-07T05:31:56Z",
"externalOrderId": "<string>",
"sptId": "<string>",
"paymentIntentId": "<string>",
"returnUrl": "<string>",
"cancelUrl": "<string>",
"paymentResult": {}
}
}{
"success": false,
"error": {
"code": "<string>",
"message": "<string>"
}
}{
"success": false,
"error": {
"code": "<string>",
"message": "<string>"
}
}{
"success": false,
"error": {
"code": "<string>",
"message": "<string>"
}
}Authorizations
Merchant API key issued during merchant onboarding. Distinct from OAuth JWT.
Body
application/json
Required range:
1 <= x <= 5000000Minimum array length:
1Show child attributes
Show child attributes
Minimum string length:
1Required string length:
3Required range:
60 <= x <= 7200⌘I