curl --request POST \
--url https://api.sandbox.zafapay.com/v1/payments \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"amount": 17.62,
"currency": "usd",
"external_id": "order_12345",
"flow_id": "flow_abc123",
"payment_method": "card",
"metadata": {},
"save_card": true,
"payment_method_id": "pmi_abc123",
"name": "John Doe",
"customer_id": "cust001",
"product_name": "Premium Plan",
"email": "customer@example.com",
"tel": "08000000000",
"token": "tok_xxxxxxxxxxxxxxxxxxxxxx",
"return_url": "https://your-site.com/payment-complete",
"success_url": "https://your-site.com/orders/12345/thanks",
"failure_url": "https://your-site.com/orders/12345/failed",
"cancel_url": "https://your-site.com/orders/12345/cancelled"
}
'import requests
url = "https://api.sandbox.zafapay.com/v1/payments"
payload = {
"amount": 17.62,
"currency": "usd",
"external_id": "order_12345",
"flow_id": "flow_abc123",
"payment_method": "card",
"metadata": {},
"save_card": True,
"payment_method_id": "pmi_abc123",
"name": "John Doe",
"customer_id": "cust001",
"product_name": "Premium Plan",
"email": "customer@example.com",
"tel": "08000000000",
"token": "tok_xxxxxxxxxxxxxxxxxxxxxx",
"return_url": "https://your-site.com/payment-complete",
"success_url": "https://your-site.com/orders/12345/thanks",
"failure_url": "https://your-site.com/orders/12345/failed",
"cancel_url": "https://your-site.com/orders/12345/cancelled"
}
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: 17.62,
currency: 'usd',
external_id: 'order_12345',
flow_id: 'flow_abc123',
payment_method: 'card',
metadata: {},
save_card: true,
payment_method_id: 'pmi_abc123',
name: 'John Doe',
customer_id: 'cust001',
product_name: 'Premium Plan',
email: 'customer@example.com',
tel: '08000000000',
token: 'tok_xxxxxxxxxxxxxxxxxxxxxx',
return_url: 'https://your-site.com/payment-complete',
success_url: 'https://your-site.com/orders/12345/thanks',
failure_url: 'https://your-site.com/orders/12345/failed',
cancel_url: 'https://your-site.com/orders/12345/cancelled'
})
};
fetch('https://api.sandbox.zafapay.com/v1/payments', 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.sandbox.zafapay.com/v1/payments",
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' => 17.62,
'currency' => 'usd',
'external_id' => 'order_12345',
'flow_id' => 'flow_abc123',
'payment_method' => 'card',
'metadata' => [
],
'save_card' => true,
'payment_method_id' => 'pmi_abc123',
'name' => 'John Doe',
'customer_id' => 'cust001',
'product_name' => 'Premium Plan',
'email' => 'customer@example.com',
'tel' => '08000000000',
'token' => 'tok_xxxxxxxxxxxxxxxxxxxxxx',
'return_url' => 'https://your-site.com/payment-complete',
'success_url' => 'https://your-site.com/orders/12345/thanks',
'failure_url' => 'https://your-site.com/orders/12345/failed',
'cancel_url' => 'https://your-site.com/orders/12345/cancelled'
]),
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.sandbox.zafapay.com/v1/payments"
payload := strings.NewReader("{\n \"amount\": 17.62,\n \"currency\": \"usd\",\n \"external_id\": \"order_12345\",\n \"flow_id\": \"flow_abc123\",\n \"payment_method\": \"card\",\n \"metadata\": {},\n \"save_card\": true,\n \"payment_method_id\": \"pmi_abc123\",\n \"name\": \"John Doe\",\n \"customer_id\": \"cust001\",\n \"product_name\": \"Premium Plan\",\n \"email\": \"customer@example.com\",\n \"tel\": \"08000000000\",\n \"token\": \"tok_xxxxxxxxxxxxxxxxxxxxxx\",\n \"return_url\": \"https://your-site.com/payment-complete\",\n \"success_url\": \"https://your-site.com/orders/12345/thanks\",\n \"failure_url\": \"https://your-site.com/orders/12345/failed\",\n \"cancel_url\": \"https://your-site.com/orders/12345/cancelled\"\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.sandbox.zafapay.com/v1/payments")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"amount\": 17.62,\n \"currency\": \"usd\",\n \"external_id\": \"order_12345\",\n \"flow_id\": \"flow_abc123\",\n \"payment_method\": \"card\",\n \"metadata\": {},\n \"save_card\": true,\n \"payment_method_id\": \"pmi_abc123\",\n \"name\": \"John Doe\",\n \"customer_id\": \"cust001\",\n \"product_name\": \"Premium Plan\",\n \"email\": \"customer@example.com\",\n \"tel\": \"08000000000\",\n \"token\": \"tok_xxxxxxxxxxxxxxxxxxxxxx\",\n \"return_url\": \"https://your-site.com/payment-complete\",\n \"success_url\": \"https://your-site.com/orders/12345/thanks\",\n \"failure_url\": \"https://your-site.com/orders/12345/failed\",\n \"cancel_url\": \"https://your-site.com/orders/12345/cancelled\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sandbox.zafapay.com/v1/payments")
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\": 17.62,\n \"currency\": \"usd\",\n \"external_id\": \"order_12345\",\n \"flow_id\": \"flow_abc123\",\n \"payment_method\": \"card\",\n \"metadata\": {},\n \"save_card\": true,\n \"payment_method_id\": \"pmi_abc123\",\n \"name\": \"John Doe\",\n \"customer_id\": \"cust001\",\n \"product_name\": \"Premium Plan\",\n \"email\": \"customer@example.com\",\n \"tel\": \"08000000000\",\n \"token\": \"tok_xxxxxxxxxxxxxxxxxxxxxx\",\n \"return_url\": \"https://your-site.com/payment-complete\",\n \"success_url\": \"https://your-site.com/orders/12345/thanks\",\n \"failure_url\": \"https://your-site.com/orders/12345/failed\",\n \"cancel_url\": \"https://your-site.com/orders/12345/cancelled\"\n}"
response = http.request(request)
puts response.read_body{
"id": "req_abc123",
"status": "pending",
"amount": 17.62,
"currency": "usd",
"external_id": "order_12345",
"metadata": {},
"flow_id": "flow_default",
"payment_type": "single",
"payment_url": "https://pay.sandbox.zafapay.com/checkout/req_abc123?token=xxxxxxxx",
"redirect_url": "https://pay.sandbox.zafapay.com/3ds/req_abc123?token=xxxxxxxx",
"created_at": "2025-01-01T00:00:00.000Z"
}{
"status": "failed",
"error": {
"code": "card_declined",
"category": "soft_decline",
"message": "Your card was declined",
"recommended_action": "use_different_card"
},
"id": "req_abc123",
"transaction_id": "tx_xyz789",
"payment_type": "token"
}{
"error": {
"type": "invalid_request_error",
"code": "validation_error",
"message": "Invalid request parameters",
"param": "amount",
"details": [
{
"path": [
"<string>"
],
"message": "<string>"
}
],
"request_id": "req_abc123xyz789"
}
}{
"error": {
"type": "invalid_request_error",
"code": "validation_error",
"message": "Invalid request parameters",
"param": "amount",
"details": [
{
"path": [
"<string>"
],
"message": "<string>"
}
],
"request_id": "req_abc123xyz789"
}
}{
"error": {
"type": "invalid_request_error",
"code": "validation_error",
"message": "Invalid request parameters",
"param": "amount",
"details": [
{
"path": [
"<string>"
],
"message": "<string>"
}
],
"request_id": "req_abc123xyz789"
}
}Create Payment
Create a new payment
curl --request POST \
--url https://api.sandbox.zafapay.com/v1/payments \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"amount": 17.62,
"currency": "usd",
"external_id": "order_12345",
"flow_id": "flow_abc123",
"payment_method": "card",
"metadata": {},
"save_card": true,
"payment_method_id": "pmi_abc123",
"name": "John Doe",
"customer_id": "cust001",
"product_name": "Premium Plan",
"email": "customer@example.com",
"tel": "08000000000",
"token": "tok_xxxxxxxxxxxxxxxxxxxxxx",
"return_url": "https://your-site.com/payment-complete",
"success_url": "https://your-site.com/orders/12345/thanks",
"failure_url": "https://your-site.com/orders/12345/failed",
"cancel_url": "https://your-site.com/orders/12345/cancelled"
}
'import requests
url = "https://api.sandbox.zafapay.com/v1/payments"
payload = {
"amount": 17.62,
"currency": "usd",
"external_id": "order_12345",
"flow_id": "flow_abc123",
"payment_method": "card",
"metadata": {},
"save_card": True,
"payment_method_id": "pmi_abc123",
"name": "John Doe",
"customer_id": "cust001",
"product_name": "Premium Plan",
"email": "customer@example.com",
"tel": "08000000000",
"token": "tok_xxxxxxxxxxxxxxxxxxxxxx",
"return_url": "https://your-site.com/payment-complete",
"success_url": "https://your-site.com/orders/12345/thanks",
"failure_url": "https://your-site.com/orders/12345/failed",
"cancel_url": "https://your-site.com/orders/12345/cancelled"
}
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: 17.62,
currency: 'usd',
external_id: 'order_12345',
flow_id: 'flow_abc123',
payment_method: 'card',
metadata: {},
save_card: true,
payment_method_id: 'pmi_abc123',
name: 'John Doe',
customer_id: 'cust001',
product_name: 'Premium Plan',
email: 'customer@example.com',
tel: '08000000000',
token: 'tok_xxxxxxxxxxxxxxxxxxxxxx',
return_url: 'https://your-site.com/payment-complete',
success_url: 'https://your-site.com/orders/12345/thanks',
failure_url: 'https://your-site.com/orders/12345/failed',
cancel_url: 'https://your-site.com/orders/12345/cancelled'
})
};
fetch('https://api.sandbox.zafapay.com/v1/payments', 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.sandbox.zafapay.com/v1/payments",
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' => 17.62,
'currency' => 'usd',
'external_id' => 'order_12345',
'flow_id' => 'flow_abc123',
'payment_method' => 'card',
'metadata' => [
],
'save_card' => true,
'payment_method_id' => 'pmi_abc123',
'name' => 'John Doe',
'customer_id' => 'cust001',
'product_name' => 'Premium Plan',
'email' => 'customer@example.com',
'tel' => '08000000000',
'token' => 'tok_xxxxxxxxxxxxxxxxxxxxxx',
'return_url' => 'https://your-site.com/payment-complete',
'success_url' => 'https://your-site.com/orders/12345/thanks',
'failure_url' => 'https://your-site.com/orders/12345/failed',
'cancel_url' => 'https://your-site.com/orders/12345/cancelled'
]),
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.sandbox.zafapay.com/v1/payments"
payload := strings.NewReader("{\n \"amount\": 17.62,\n \"currency\": \"usd\",\n \"external_id\": \"order_12345\",\n \"flow_id\": \"flow_abc123\",\n \"payment_method\": \"card\",\n \"metadata\": {},\n \"save_card\": true,\n \"payment_method_id\": \"pmi_abc123\",\n \"name\": \"John Doe\",\n \"customer_id\": \"cust001\",\n \"product_name\": \"Premium Plan\",\n \"email\": \"customer@example.com\",\n \"tel\": \"08000000000\",\n \"token\": \"tok_xxxxxxxxxxxxxxxxxxxxxx\",\n \"return_url\": \"https://your-site.com/payment-complete\",\n \"success_url\": \"https://your-site.com/orders/12345/thanks\",\n \"failure_url\": \"https://your-site.com/orders/12345/failed\",\n \"cancel_url\": \"https://your-site.com/orders/12345/cancelled\"\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.sandbox.zafapay.com/v1/payments")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"amount\": 17.62,\n \"currency\": \"usd\",\n \"external_id\": \"order_12345\",\n \"flow_id\": \"flow_abc123\",\n \"payment_method\": \"card\",\n \"metadata\": {},\n \"save_card\": true,\n \"payment_method_id\": \"pmi_abc123\",\n \"name\": \"John Doe\",\n \"customer_id\": \"cust001\",\n \"product_name\": \"Premium Plan\",\n \"email\": \"customer@example.com\",\n \"tel\": \"08000000000\",\n \"token\": \"tok_xxxxxxxxxxxxxxxxxxxxxx\",\n \"return_url\": \"https://your-site.com/payment-complete\",\n \"success_url\": \"https://your-site.com/orders/12345/thanks\",\n \"failure_url\": \"https://your-site.com/orders/12345/failed\",\n \"cancel_url\": \"https://your-site.com/orders/12345/cancelled\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sandbox.zafapay.com/v1/payments")
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\": 17.62,\n \"currency\": \"usd\",\n \"external_id\": \"order_12345\",\n \"flow_id\": \"flow_abc123\",\n \"payment_method\": \"card\",\n \"metadata\": {},\n \"save_card\": true,\n \"payment_method_id\": \"pmi_abc123\",\n \"name\": \"John Doe\",\n \"customer_id\": \"cust001\",\n \"product_name\": \"Premium Plan\",\n \"email\": \"customer@example.com\",\n \"tel\": \"08000000000\",\n \"token\": \"tok_xxxxxxxxxxxxxxxxxxxxxx\",\n \"return_url\": \"https://your-site.com/payment-complete\",\n \"success_url\": \"https://your-site.com/orders/12345/thanks\",\n \"failure_url\": \"https://your-site.com/orders/12345/failed\",\n \"cancel_url\": \"https://your-site.com/orders/12345/cancelled\"\n}"
response = http.request(request)
puts response.read_body{
"id": "req_abc123",
"status": "pending",
"amount": 17.62,
"currency": "usd",
"external_id": "order_12345",
"metadata": {},
"flow_id": "flow_default",
"payment_type": "single",
"payment_url": "https://pay.sandbox.zafapay.com/checkout/req_abc123?token=xxxxxxxx",
"redirect_url": "https://pay.sandbox.zafapay.com/3ds/req_abc123?token=xxxxxxxx",
"created_at": "2025-01-01T00:00:00.000Z"
}{
"status": "failed",
"error": {
"code": "card_declined",
"category": "soft_decline",
"message": "Your card was declined",
"recommended_action": "use_different_card"
},
"id": "req_abc123",
"transaction_id": "tx_xyz789",
"payment_type": "token"
}{
"error": {
"type": "invalid_request_error",
"code": "validation_error",
"message": "Invalid request parameters",
"param": "amount",
"details": [
{
"path": [
"<string>"
],
"message": "<string>"
}
],
"request_id": "req_abc123xyz789"
}
}{
"error": {
"type": "invalid_request_error",
"code": "validation_error",
"message": "Invalid request parameters",
"param": "amount",
"details": [
{
"path": [
"<string>"
],
"message": "<string>"
}
],
"request_id": "req_abc123xyz789"
}
}{
"error": {
"type": "invalid_request_error",
"code": "validation_error",
"message": "Invalid request parameters",
"param": "amount",
"details": [
{
"path": [
"<string>"
],
"message": "<string>"
}
],
"request_id": "req_abc123xyz789"
}
}Authorizations
Bearer authentication using access token
Body
Payment amount (positive number, supports up to 2 decimal places). For Depot, the amount must be a positive integer in whole yen and at most 100000 — decimals are rejected.
17.62
3-letter currency code (e.g., usd, sgd, jpy). Depot supports jpy only.
"usd"
Capture method (uses flow configuration if omitted)
automatic, manual Merchant's order ID
"order_12345"
Flow ID to use (defaults to default flow if omitted)
"flow_abc123"
Payment method (string or object format)
"card"
Additional data to store with the transaction
If true, save card for future recurring payments
true
Use a saved payment method for recurring payment (get from /v1/customers/{id}/payment-methods)
"pmi_abc123"
Cardholder name (required for some payment methods)
"John Doe"
Customer ID (used for saving and retrieving payment methods). For Depot this must be half-width alphanumerics only, up to 150 characters. A value containing symbols is accepted here but fails with error 1004 when the customer pays.
"cust001"
Product name shown to the customer on the payment page. For Depot, up to 30 characters and kanji is not supported.
"Premium Plan"
Customer email address. Required for Depot payments.
"customer@example.com"
Customer phone number. For Depot this must be 10-15 digits.
"08000000000"
Token ID from the JavaScript SDK (tok_ prefix). Used for server-to-server payments. The token is single-use and expires after 30 minutes.
"tok_xxxxxxxxxxxxxxxxxxxxxx"
URL to redirect the customer after 3D Secure authentication. Strongly recommended when using token parameter — without it, the customer has no redirect destination after 3DS.
"https://your-site.com/payment-complete"
URL to redirect the customer to after a successful payment. Set per payment, it overrides the payment link URL and the merchant default configured in the dashboard. Must be an http(s) URL.
2048"https://your-site.com/orders/12345/thanks"
URL to redirect the customer to after a failed payment. Overrides the payment link URL and the merchant default. Must be an http(s) URL.
2048"https://your-site.com/orders/12345/failed"
URL to redirect the customer to when the payment is cancelled. Overrides the payment link URL and the merchant default. Must be an http(s) URL.
2048"https://your-site.com/orders/12345/cancelled"
Response
Payment created successfully
Payment request ID
"req_abc123"
Status
"pending"
Payment amount
17.62
Currency code
"usd"
Merchant's order ID
"order_12345"
Additional data (empty object if not specified)
{}
Payment flow ID used
"flow_default"
Payment type. single: Regular one-time payment, initial: Initial payment with card saving, recurring: Recurring payment using saved card, token: Server-to-server payment using token
single, initial, recurring, token "single"
Hosted checkout page URL (with signature). Returned for hosted checkout payments.
"https://pay.sandbox.zafapay.com/checkout/req_abc123?token=xxxxxxxx"
3D Secure authentication URL. Returned when status is requires_action (token payments only).
"https://pay.sandbox.zafapay.com/3ds/req_abc123?token=xxxxxxxx"
Creation timestamp (ISO 8601 format)
"2025-01-01T00:00:00.000Z"