Create a payment intent
POST /payment_intents with idempotency, merchant_reference, customer details, and next_action.
Create a payment intent. The platform routes it to a payment method, begins processing, and returns next_action when the provider responds in time.
Endpoint
POST /payment_intentsRequired headers:
Authorization: Basic <base64(publicKey:secretKey)>.Content-Type: application/json.
Optional but recommended:
Idempotency-Key: <uuid>.
Request
curl -s -X POST "$API_BASE/payment_intents" \
-u "$API_PUBLIC_KEY:$API_SECRET_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{
"amount": "10000",
"currency": "MYR",
"country": "MY",
"payment_method": "MY_FPX",
"merchant_reference": "order_12345",
"customer": {
"name": "Aisyah Rahman",
"email": "[email protected]",
"reference": "cus_8421"
}
}'import { randomUUID } from "node:crypto";
const auth =
"Basic " +
Buffer.from(`${process.env.API_PUBLIC_KEY}:${process.env.API_SECRET_KEY}`).toString("base64");
const res = await fetch(`${process.env.API_BASE}/payment_intents`, {
method: "POST",
headers: {
Authorization: auth,
"Idempotency-Key": randomUUID(),
"Content-Type": "application/json",
},
body: JSON.stringify({
amount: "10000",
currency: "MYR",
country: "MY",
payment_method: "MY_FPX",
merchant_reference: "order_12345",
customer: { name: "Aisyah Rahman", email: "[email protected]" },
}),
});
if (!res.ok) {
const { error } = (await res.json()) as { error: { code: string; message: string } };
throw new Error(`${error.code}: ${error.message}`);
}
const intent = await res.json();Body fields
Prop
Type
Success
{
"object": "payment_intent",
"id": "dord_01HZX...",
"amount": "10000",
"currency": "MYR",
"country": "MY",
"environment": "test",
"status": "requires_action",
"merchant_reference": "order_12345",
"payment_method": "MY_FPX",
"next_action": {
"type": "redirect_to_url",
"url": "https://pay.example-psp.com/session/abc123",
"expires_at": "2026-05-09T12:15:00.000Z"
},
"failure_code": null,
"failure_message": null,
"created_at": "2026-05-09T12:00:00.000Z",
"updated_at": "2026-05-09T12:00:02.000Z"
}Response fields
Prop
Type
next_action is null when no customer action is required. When present, type is one of
redirect_to_url, display_qr_code, or display_bank_transfer_instructions. The shape per type
and the merchant checkout mode that drives it are documented in Checkout
mode.
Notes
amountis a minor-unit decimal string. See Currency.merchant_referenceis your application order id. A repeat POST with the same value returns the original intent.- See Idempotency for retry semantics.