Create a Terminal Payment Session
curl --request POST \
--url https://terminal-dev.xendit.co/v1/terminal/sessions \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--header 'idempotency-key: <idempotency-key>' \
--data '
{
"amount": 2,
"session_type": "PAY",
"mode": "TERMINAL",
"channel_properties": {
"terminal_id": "abcd-3254fsd-3242",
"order_id": "order-12345",
"payment_methods": []
},
"reference_id": "ref_123456789",
"customer_id": "cus_123456789",
"customer": {
"type": "INDIVIDUAL",
"reference_id": "cus_123456789",
"email": "test@xendit.co",
"mobile_number": "+62123456789",
"phone_number": "+62123456789",
"individual_detail": {
"given_names": "John Doe",
"surname": "Doe"
},
"business_detail": {
"business_name": "<string>"
}
},
"description": "Payment for order #123",
"metadata": {}
}
'<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://terminal-dev.xendit.co/v1/terminal/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' => 2,
'session_type' => 'PAY',
'mode' => 'TERMINAL',
'channel_properties' => [
'terminal_id' => 'abcd-3254fsd-3242',
'order_id' => 'order-12345',
'payment_methods' => [
]
],
'reference_id' => 'ref_123456789',
'customer_id' => 'cus_123456789',
'customer' => [
'type' => 'INDIVIDUAL',
'reference_id' => 'cus_123456789',
'email' => 'test@xendit.co',
'mobile_number' => '+62123456789',
'phone_number' => '+62123456789',
'individual_detail' => [
'given_names' => 'John Doe',
'surname' => 'Doe'
],
'business_detail' => [
'business_name' => '<string>'
]
],
'description' => 'Payment for order #123',
'metadata' => [
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>",
"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;
}HttpResponse<String> response = Unirest.post("https://terminal-dev.xendit.co/v1/terminal/sessions")
.header("idempotency-key", "<idempotency-key>")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/json")
.body("{\n \"amount\": 2,\n \"session_type\": \"PAY\",\n \"mode\": \"TERMINAL\",\n \"channel_properties\": {\n \"terminal_id\": \"abcd-3254fsd-3242\",\n \"order_id\": \"order-12345\",\n \"payment_methods\": []\n },\n \"reference_id\": \"ref_123456789\",\n \"customer_id\": \"cus_123456789\",\n \"customer\": {\n \"type\": \"INDIVIDUAL\",\n \"reference_id\": \"cus_123456789\",\n \"email\": \"test@xendit.co\",\n \"mobile_number\": \"+62123456789\",\n \"phone_number\": \"+62123456789\",\n \"individual_detail\": {\n \"given_names\": \"John Doe\",\n \"surname\": \"Doe\"\n },\n \"business_detail\": {\n \"business_name\": \"<string>\"\n }\n },\n \"description\": \"Payment for order #123\",\n \"metadata\": {}\n}")
.asString();package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://terminal-dev.xendit.co/v1/terminal/sessions"
payload := strings.NewReader("{\n \"amount\": 2,\n \"session_type\": \"PAY\",\n \"mode\": \"TERMINAL\",\n \"channel_properties\": {\n \"terminal_id\": \"abcd-3254fsd-3242\",\n \"order_id\": \"order-12345\",\n \"payment_methods\": []\n },\n \"reference_id\": \"ref_123456789\",\n \"customer_id\": \"cus_123456789\",\n \"customer\": {\n \"type\": \"INDIVIDUAL\",\n \"reference_id\": \"cus_123456789\",\n \"email\": \"test@xendit.co\",\n \"mobile_number\": \"+62123456789\",\n \"phone_number\": \"+62123456789\",\n \"individual_detail\": {\n \"given_names\": \"John Doe\",\n \"surname\": \"Doe\"\n },\n \"business_detail\": {\n \"business_name\": \"<string>\"\n }\n },\n \"description\": \"Payment for order #123\",\n \"metadata\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("idempotency-key", "<idempotency-key>")
req.Header.Add("Authorization", "Basic <encoded-value>")
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))
}import requests
url = "https://terminal-dev.xendit.co/v1/terminal/sessions"
payload = {
"amount": 2,
"session_type": "PAY",
"mode": "TERMINAL",
"channel_properties": {
"terminal_id": "abcd-3254fsd-3242",
"order_id": "order-12345",
"payment_methods": []
},
"reference_id": "ref_123456789",
"customer_id": "cus_123456789",
"customer": {
"type": "INDIVIDUAL",
"reference_id": "cus_123456789",
"email": "test@xendit.co",
"mobile_number": "+62123456789",
"phone_number": "+62123456789",
"individual_detail": {
"given_names": "John Doe",
"surname": "Doe"
},
"business_detail": { "business_name": "<string>" }
},
"description": "Payment for order #123",
"metadata": {}
}
headers = {
"idempotency-key": "<idempotency-key>",
"Authorization": "Basic <encoded-value>",
"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: 'Basic <encoded-value>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
amount: 2,
session_type: 'PAY',
mode: 'TERMINAL',
channel_properties: {terminal_id: 'abcd-3254fsd-3242', order_id: 'order-12345', payment_methods: []},
reference_id: 'ref_123456789',
customer_id: 'cus_123456789',
customer: {
type: 'INDIVIDUAL',
reference_id: 'cus_123456789',
email: 'test@xendit.co',
mobile_number: '+62123456789',
phone_number: '+62123456789',
individual_detail: {given_names: 'John Doe', surname: 'Doe'},
business_detail: {business_name: '<string>'}
},
description: 'Payment for order #123',
metadata: {}
})
};
fetch('https://terminal-dev.xendit.co/v1/terminal/sessions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));require 'uri'
require 'net/http'
url = URI("https://terminal-dev.xendit.co/v1/terminal/sessions")
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"] = 'Basic <encoded-value>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"amount\": 2,\n \"session_type\": \"PAY\",\n \"mode\": \"TERMINAL\",\n \"channel_properties\": {\n \"terminal_id\": \"abcd-3254fsd-3242\",\n \"order_id\": \"order-12345\",\n \"payment_methods\": []\n },\n \"reference_id\": \"ref_123456789\",\n \"customer_id\": \"cus_123456789\",\n \"customer\": {\n \"type\": \"INDIVIDUAL\",\n \"reference_id\": \"cus_123456789\",\n \"email\": \"test@xendit.co\",\n \"mobile_number\": \"+62123456789\",\n \"phone_number\": \"+62123456789\",\n \"individual_detail\": {\n \"given_names\": \"John Doe\",\n \"surname\": \"Doe\"\n },\n \"business_detail\": {\n \"business_name\": \"<string>\"\n }\n },\n \"description\": \"Payment for order #123\",\n \"metadata\": {}\n}"
response = http.request(request)
puts response.read_body{
"payment_session_id": "<string>",
"latest_payment_id": "<string>",
"business_id": "<string>",
"reference_id": "ref_123456789",
"session_type": "PAY",
"amount": 2,
"mode": "TERMINAL",
"channel_properties": {
"terminal_id": "abcd-3254fsd-3242",
"order_id": "order-12345",
"payment_methods": []
},
"created": "2024-11-06T15:32:42Z",
"updated": "2024-11-06T15:32:42Z",
"customer_id": "cus_123456789",
"description": "Payment for order #123",
"metadata": {},
"canceled_at": "2023-11-07T05:31:56Z"
}{
"error_code": "INVALID_REQUEST",
"message": "Missing required parameter: terminal_id"
}{
"error_code": "INVALID_REQUEST",
"message": "Missing required parameter: terminal_id"
}Terminal API (H2H)
Create a Terminal Payment Session
POST
/
v1
/
terminal
/
sessions
Create a Terminal Payment Session
curl --request POST \
--url https://terminal-dev.xendit.co/v1/terminal/sessions \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--header 'idempotency-key: <idempotency-key>' \
--data '
{
"amount": 2,
"session_type": "PAY",
"mode": "TERMINAL",
"channel_properties": {
"terminal_id": "abcd-3254fsd-3242",
"order_id": "order-12345",
"payment_methods": []
},
"reference_id": "ref_123456789",
"customer_id": "cus_123456789",
"customer": {
"type": "INDIVIDUAL",
"reference_id": "cus_123456789",
"email": "test@xendit.co",
"mobile_number": "+62123456789",
"phone_number": "+62123456789",
"individual_detail": {
"given_names": "John Doe",
"surname": "Doe"
},
"business_detail": {
"business_name": "<string>"
}
},
"description": "Payment for order #123",
"metadata": {}
}
'<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://terminal-dev.xendit.co/v1/terminal/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' => 2,
'session_type' => 'PAY',
'mode' => 'TERMINAL',
'channel_properties' => [
'terminal_id' => 'abcd-3254fsd-3242',
'order_id' => 'order-12345',
'payment_methods' => [
]
],
'reference_id' => 'ref_123456789',
'customer_id' => 'cus_123456789',
'customer' => [
'type' => 'INDIVIDUAL',
'reference_id' => 'cus_123456789',
'email' => 'test@xendit.co',
'mobile_number' => '+62123456789',
'phone_number' => '+62123456789',
'individual_detail' => [
'given_names' => 'John Doe',
'surname' => 'Doe'
],
'business_detail' => [
'business_name' => '<string>'
]
],
'description' => 'Payment for order #123',
'metadata' => [
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>",
"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;
}HttpResponse<String> response = Unirest.post("https://terminal-dev.xendit.co/v1/terminal/sessions")
.header("idempotency-key", "<idempotency-key>")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/json")
.body("{\n \"amount\": 2,\n \"session_type\": \"PAY\",\n \"mode\": \"TERMINAL\",\n \"channel_properties\": {\n \"terminal_id\": \"abcd-3254fsd-3242\",\n \"order_id\": \"order-12345\",\n \"payment_methods\": []\n },\n \"reference_id\": \"ref_123456789\",\n \"customer_id\": \"cus_123456789\",\n \"customer\": {\n \"type\": \"INDIVIDUAL\",\n \"reference_id\": \"cus_123456789\",\n \"email\": \"test@xendit.co\",\n \"mobile_number\": \"+62123456789\",\n \"phone_number\": \"+62123456789\",\n \"individual_detail\": {\n \"given_names\": \"John Doe\",\n \"surname\": \"Doe\"\n },\n \"business_detail\": {\n \"business_name\": \"<string>\"\n }\n },\n \"description\": \"Payment for order #123\",\n \"metadata\": {}\n}")
.asString();package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://terminal-dev.xendit.co/v1/terminal/sessions"
payload := strings.NewReader("{\n \"amount\": 2,\n \"session_type\": \"PAY\",\n \"mode\": \"TERMINAL\",\n \"channel_properties\": {\n \"terminal_id\": \"abcd-3254fsd-3242\",\n \"order_id\": \"order-12345\",\n \"payment_methods\": []\n },\n \"reference_id\": \"ref_123456789\",\n \"customer_id\": \"cus_123456789\",\n \"customer\": {\n \"type\": \"INDIVIDUAL\",\n \"reference_id\": \"cus_123456789\",\n \"email\": \"test@xendit.co\",\n \"mobile_number\": \"+62123456789\",\n \"phone_number\": \"+62123456789\",\n \"individual_detail\": {\n \"given_names\": \"John Doe\",\n \"surname\": \"Doe\"\n },\n \"business_detail\": {\n \"business_name\": \"<string>\"\n }\n },\n \"description\": \"Payment for order #123\",\n \"metadata\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("idempotency-key", "<idempotency-key>")
req.Header.Add("Authorization", "Basic <encoded-value>")
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))
}import requests
url = "https://terminal-dev.xendit.co/v1/terminal/sessions"
payload = {
"amount": 2,
"session_type": "PAY",
"mode": "TERMINAL",
"channel_properties": {
"terminal_id": "abcd-3254fsd-3242",
"order_id": "order-12345",
"payment_methods": []
},
"reference_id": "ref_123456789",
"customer_id": "cus_123456789",
"customer": {
"type": "INDIVIDUAL",
"reference_id": "cus_123456789",
"email": "test@xendit.co",
"mobile_number": "+62123456789",
"phone_number": "+62123456789",
"individual_detail": {
"given_names": "John Doe",
"surname": "Doe"
},
"business_detail": { "business_name": "<string>" }
},
"description": "Payment for order #123",
"metadata": {}
}
headers = {
"idempotency-key": "<idempotency-key>",
"Authorization": "Basic <encoded-value>",
"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: 'Basic <encoded-value>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
amount: 2,
session_type: 'PAY',
mode: 'TERMINAL',
channel_properties: {terminal_id: 'abcd-3254fsd-3242', order_id: 'order-12345', payment_methods: []},
reference_id: 'ref_123456789',
customer_id: 'cus_123456789',
customer: {
type: 'INDIVIDUAL',
reference_id: 'cus_123456789',
email: 'test@xendit.co',
mobile_number: '+62123456789',
phone_number: '+62123456789',
individual_detail: {given_names: 'John Doe', surname: 'Doe'},
business_detail: {business_name: '<string>'}
},
description: 'Payment for order #123',
metadata: {}
})
};
fetch('https://terminal-dev.xendit.co/v1/terminal/sessions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));require 'uri'
require 'net/http'
url = URI("https://terminal-dev.xendit.co/v1/terminal/sessions")
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"] = 'Basic <encoded-value>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"amount\": 2,\n \"session_type\": \"PAY\",\n \"mode\": \"TERMINAL\",\n \"channel_properties\": {\n \"terminal_id\": \"abcd-3254fsd-3242\",\n \"order_id\": \"order-12345\",\n \"payment_methods\": []\n },\n \"reference_id\": \"ref_123456789\",\n \"customer_id\": \"cus_123456789\",\n \"customer\": {\n \"type\": \"INDIVIDUAL\",\n \"reference_id\": \"cus_123456789\",\n \"email\": \"test@xendit.co\",\n \"mobile_number\": \"+62123456789\",\n \"phone_number\": \"+62123456789\",\n \"individual_detail\": {\n \"given_names\": \"John Doe\",\n \"surname\": \"Doe\"\n },\n \"business_detail\": {\n \"business_name\": \"<string>\"\n }\n },\n \"description\": \"Payment for order #123\",\n \"metadata\": {}\n}"
response = http.request(request)
puts response.read_body{
"payment_session_id": "<string>",
"latest_payment_id": "<string>",
"business_id": "<string>",
"reference_id": "ref_123456789",
"session_type": "PAY",
"amount": 2,
"mode": "TERMINAL",
"channel_properties": {
"terminal_id": "abcd-3254fsd-3242",
"order_id": "order-12345",
"payment_methods": []
},
"created": "2024-11-06T15:32:42Z",
"updated": "2024-11-06T15:32:42Z",
"customer_id": "cus_123456789",
"description": "Payment for order #123",
"metadata": {},
"canceled_at": "2023-11-07T05:31:56Z"
}{
"error_code": "INVALID_REQUEST",
"message": "Missing required parameter: terminal_id"
}{
"error_code": "INVALID_REQUEST",
"message": "Missing required parameter: terminal_id"
}Authorizations
Basic authentication header of the form Basic <encoded-value>, where <encoded-value> is the base64-encoded string username:password.
Headers
Idempotency key to ensure the request is not processed multiple times
The sub-account user-id to make this transaction for. This header is only used if you have access to xenPlatform. See xenPlatform for more information.
The XenPlatform split rule ID that will be applied to this transaction. This header is only used if you have access to xenPlatform.
Body
application/json
Available options:
IDR, VND, THB, MYR Required range:
x >= 1Available options:
ID, VN, TH, MY Available options:
PAY Available options:
TERMINAL Show child attributes
Show child attributes
Example:
"ref_123456789"
Example:
"cus_123456789"
Show child attributes
Show child attributes
Example:
"Payment for order #123"
Response
Terminal Payment Session created successfully
Pattern:
^[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}$Pattern:
^[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}$Example:
"ref_123456789"
Available options:
PAY Available options:
IDR, VND, THB, MYR Required range:
x >= 1Available options:
ID, VN, TH, MY Available options:
TERMINAL Available options:
ACTIVE, COMPLETED, FAILED, CANCELED Show child attributes
Show child attributes
Example:
"2024-11-06T15:32:42Z"
Example:
"2024-11-06T15:32:42Z"
Example:
"cus_123456789"
Example:
"Payment for order #123"
⌘I