Create a Payment Intent
curl --request POST \
--url https://api.sbx.moduluslabs.io/ecom/v1/payment-intents \
--header 'Content-Type: application/json' \
--header 'Idempotency-Key: <idempotency-key>' \
--header 'X-API-Key: <api-key>' \
--data '
{
"merchant_branch_reference_number": "SH-ANG-001",
"amount": 86500,
"currency": "PHP",
"description": "Order #1234",
"order_reference": "ORD-2026-1234",
"expires_at": "2030-01-01T10:00:00Z",
"metadata": {
"order_id": "1234"
}
}
'import requests
url = "https://api.sbx.moduluslabs.io/ecom/v1/payment-intents"
payload = {
"merchant_branch_reference_number": "SH-ANG-001",
"amount": 86500,
"currency": "PHP",
"description": "Order #1234",
"order_reference": "ORD-2026-1234",
"expires_at": "2030-01-01T10:00:00Z",
"metadata": { "order_id": "1234" }
}
headers = {
"Idempotency-Key": "<idempotency-key>",
"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: {
'Idempotency-Key': '<idempotency-key>',
'X-API-Key': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
merchant_branch_reference_number: 'SH-ANG-001',
amount: 86500,
currency: 'PHP',
description: 'Order #1234',
order_reference: 'ORD-2026-1234',
expires_at: '2030-01-01T10:00:00Z',
metadata: {order_id: '1234'}
})
};
fetch('https://api.sbx.moduluslabs.io/ecom/v1/payment-intents', 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.sbx.moduluslabs.io/ecom/v1/payment-intents",
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([
'merchant_branch_reference_number' => 'SH-ANG-001',
'amount' => 86500,
'currency' => 'PHP',
'description' => 'Order #1234',
'order_reference' => 'ORD-2026-1234',
'expires_at' => '2030-01-01T10:00:00Z',
'metadata' => [
'order_id' => '1234'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"Idempotency-Key: <idempotency-key>",
"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.sbx.moduluslabs.io/ecom/v1/payment-intents"
payload := strings.NewReader("{\n \"merchant_branch_reference_number\": \"SH-ANG-001\",\n \"amount\": 86500,\n \"currency\": \"PHP\",\n \"description\": \"Order #1234\",\n \"order_reference\": \"ORD-2026-1234\",\n \"expires_at\": \"2030-01-01T10:00:00Z\",\n \"metadata\": {\n \"order_id\": \"1234\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Idempotency-Key", "<idempotency-key>")
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.sbx.moduluslabs.io/ecom/v1/payment-intents")
.header("Idempotency-Key", "<idempotency-key>")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"merchant_branch_reference_number\": \"SH-ANG-001\",\n \"amount\": 86500,\n \"currency\": \"PHP\",\n \"description\": \"Order #1234\",\n \"order_reference\": \"ORD-2026-1234\",\n \"expires_at\": \"2030-01-01T10:00:00Z\",\n \"metadata\": {\n \"order_id\": \"1234\"\n }\n}")
.asString();using RestSharp;
var options = new RestClientOptions("https://api.sbx.moduluslabs.io/ecom/v1/payment-intents");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddHeader("Idempotency-Key", "<idempotency-key>");
request.AddHeader("X-API-Key", "<api-key>");
request.AddJsonBody("{\n \"merchant_branch_reference_number\": \"SH-ANG-001\",\n \"amount\": 86500,\n \"currency\": \"PHP\",\n \"description\": \"Order #1234\",\n \"order_reference\": \"ORD-2026-1234\",\n \"expires_at\": \"2030-01-01T10:00:00Z\",\n \"metadata\": {\n \"order_id\": \"1234\"\n }\n}", false);
var response = await client.PostAsync(request);
Console.WriteLine("{0}", response.Content);
{
"id": "b7e2c1a4-9f3d-4c6b-8a21-5e0f7d9c3b18",
"client_secret": "3f9a6d2e-7c14-4b8f-a5d0-1e6c2b9f4a73",
"amount": 86500,
"currency": "PHP",
"order_reference": "ORD-2026-1234",
"status": "ACTIVE",
"expires_at": "2030-01-01T10:00:00Z"
}{
"error": {
"code": "BAD_REQUEST",
"message": "<string>",
"correlation_id": "<string>",
"details": {
"field": "description",
"rule": "non_blank"
}
}
}{
"error": {
"code": "BAD_REQUEST",
"message": "<string>",
"correlation_id": "<string>",
"details": {
"field": "description",
"rule": "non_blank"
}
}
}{
"error": {
"code": "BAD_REQUEST",
"message": "<string>",
"correlation_id": "<string>",
"details": {
"field": "description",
"rule": "non_blank"
}
}
}{
"error": {
"code": "BAD_REQUEST",
"message": "<string>",
"correlation_id": "<string>",
"details": {
"field": "description",
"rule": "non_blank"
}
}
}{
"error": {
"code": "BAD_REQUEST",
"message": "<string>",
"correlation_id": "<string>",
"details": {
"field": "description",
"rule": "non_blank"
}
}
}{
"error": {
"code": "BAD_REQUEST",
"message": "<string>",
"correlation_id": "<string>",
"details": {
"field": "description",
"rule": "non_blank"
}
}
}{
"error": {
"code": "BAD_REQUEST",
"message": "<string>",
"correlation_id": "<string>",
"details": {
"field": "description",
"rule": "non_blank"
}
}
}{
"error": {
"code": "BAD_REQUEST",
"message": "<string>",
"correlation_id": "<string>",
"details": {
"field": "description",
"rule": "non_blank"
}
}
}{
"error": {
"code": "BAD_REQUEST",
"message": "<string>",
"correlation_id": "<string>",
"details": {
"field": "description",
"rule": "non_blank"
}
}
}JavaScript SDK
Create Payment Intent
Create a payment intent on your server, then confirm it in the browser with the JavaScript SDK
POST
/
payment-intents
Create a Payment Intent
curl --request POST \
--url https://api.sbx.moduluslabs.io/ecom/v1/payment-intents \
--header 'Content-Type: application/json' \
--header 'Idempotency-Key: <idempotency-key>' \
--header 'X-API-Key: <api-key>' \
--data '
{
"merchant_branch_reference_number": "SH-ANG-001",
"amount": 86500,
"currency": "PHP",
"description": "Order #1234",
"order_reference": "ORD-2026-1234",
"expires_at": "2030-01-01T10:00:00Z",
"metadata": {
"order_id": "1234"
}
}
'import requests
url = "https://api.sbx.moduluslabs.io/ecom/v1/payment-intents"
payload = {
"merchant_branch_reference_number": "SH-ANG-001",
"amount": 86500,
"currency": "PHP",
"description": "Order #1234",
"order_reference": "ORD-2026-1234",
"expires_at": "2030-01-01T10:00:00Z",
"metadata": { "order_id": "1234" }
}
headers = {
"Idempotency-Key": "<idempotency-key>",
"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: {
'Idempotency-Key': '<idempotency-key>',
'X-API-Key': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
merchant_branch_reference_number: 'SH-ANG-001',
amount: 86500,
currency: 'PHP',
description: 'Order #1234',
order_reference: 'ORD-2026-1234',
expires_at: '2030-01-01T10:00:00Z',
metadata: {order_id: '1234'}
})
};
fetch('https://api.sbx.moduluslabs.io/ecom/v1/payment-intents', 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.sbx.moduluslabs.io/ecom/v1/payment-intents",
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([
'merchant_branch_reference_number' => 'SH-ANG-001',
'amount' => 86500,
'currency' => 'PHP',
'description' => 'Order #1234',
'order_reference' => 'ORD-2026-1234',
'expires_at' => '2030-01-01T10:00:00Z',
'metadata' => [
'order_id' => '1234'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"Idempotency-Key: <idempotency-key>",
"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.sbx.moduluslabs.io/ecom/v1/payment-intents"
payload := strings.NewReader("{\n \"merchant_branch_reference_number\": \"SH-ANG-001\",\n \"amount\": 86500,\n \"currency\": \"PHP\",\n \"description\": \"Order #1234\",\n \"order_reference\": \"ORD-2026-1234\",\n \"expires_at\": \"2030-01-01T10:00:00Z\",\n \"metadata\": {\n \"order_id\": \"1234\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Idempotency-Key", "<idempotency-key>")
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.sbx.moduluslabs.io/ecom/v1/payment-intents")
.header("Idempotency-Key", "<idempotency-key>")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"merchant_branch_reference_number\": \"SH-ANG-001\",\n \"amount\": 86500,\n \"currency\": \"PHP\",\n \"description\": \"Order #1234\",\n \"order_reference\": \"ORD-2026-1234\",\n \"expires_at\": \"2030-01-01T10:00:00Z\",\n \"metadata\": {\n \"order_id\": \"1234\"\n }\n}")
.asString();using RestSharp;
var options = new RestClientOptions("https://api.sbx.moduluslabs.io/ecom/v1/payment-intents");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddHeader("Idempotency-Key", "<idempotency-key>");
request.AddHeader("X-API-Key", "<api-key>");
request.AddJsonBody("{\n \"merchant_branch_reference_number\": \"SH-ANG-001\",\n \"amount\": 86500,\n \"currency\": \"PHP\",\n \"description\": \"Order #1234\",\n \"order_reference\": \"ORD-2026-1234\",\n \"expires_at\": \"2030-01-01T10:00:00Z\",\n \"metadata\": {\n \"order_id\": \"1234\"\n }\n}", false);
var response = await client.PostAsync(request);
Console.WriteLine("{0}", response.Content);
{
"id": "b7e2c1a4-9f3d-4c6b-8a21-5e0f7d9c3b18",
"client_secret": "3f9a6d2e-7c14-4b8f-a5d0-1e6c2b9f4a73",
"amount": 86500,
"currency": "PHP",
"order_reference": "ORD-2026-1234",
"status": "ACTIVE",
"expires_at": "2030-01-01T10:00:00Z"
}{
"error": {
"code": "BAD_REQUEST",
"message": "<string>",
"correlation_id": "<string>",
"details": {
"field": "description",
"rule": "non_blank"
}
}
}{
"error": {
"code": "BAD_REQUEST",
"message": "<string>",
"correlation_id": "<string>",
"details": {
"field": "description",
"rule": "non_blank"
}
}
}{
"error": {
"code": "BAD_REQUEST",
"message": "<string>",
"correlation_id": "<string>",
"details": {
"field": "description",
"rule": "non_blank"
}
}
}{
"error": {
"code": "BAD_REQUEST",
"message": "<string>",
"correlation_id": "<string>",
"details": {
"field": "description",
"rule": "non_blank"
}
}
}{
"error": {
"code": "BAD_REQUEST",
"message": "<string>",
"correlation_id": "<string>",
"details": {
"field": "description",
"rule": "non_blank"
}
}
}{
"error": {
"code": "BAD_REQUEST",
"message": "<string>",
"correlation_id": "<string>",
"details": {
"field": "description",
"rule": "non_blank"
}
}
}{
"error": {
"code": "BAD_REQUEST",
"message": "<string>",
"correlation_id": "<string>",
"details": {
"field": "description",
"rule": "non_blank"
}
}
}{
"error": {
"code": "BAD_REQUEST",
"message": "<string>",
"correlation_id": "<string>",
"details": {
"field": "description",
"rule": "non_blank"
}
}
}{
"error": {
"code": "BAD_REQUEST",
"message": "<string>",
"correlation_id": "<string>",
"details": {
"field": "description",
"rule": "non_blank"
}
}
}Returns
201 Created with the intent id, client_secret, and the supplied order_reference when present. Hand the id and client_secret to the JavaScript SDK to render the card fields and confirm the payment. Card data is never sent to this endpoint.pk_) instead, scoped to this intent by its client_secret. See What is client_secret?
order_reference participates in idempotency comparison. Reusing an Idempotency-Key with a different order reference returns 409 instead of changing the existing intent.Confirmation happens in the browser through the SDK, not through a REST call you make yourself. See Confirm the payment.
Authorizations
Headers
Unique client-generated identifier for Payment Intent creation. Allowed characters: letters, digits, dot (.), hyphen (-), and underscore (_); 8-64 characters. Reusing the same key for the same branch with an identical body returns the existing intent; reusing it with a different body returns a conflict.
Required string length:
8 - 64Pattern:
^[A-Za-z0-9._-]{8,64}$Body
application/json
Response
Payment intent created.
Was this page helpful?