Create a charge with chain
Create a charge with a destination parameter to enable marketplace payment splitting. This creates a chain linking the charge to an automatic transfer to a recipient.
API Credentials
Request Parametersโ
Required - 3 fieldsRequired Parameters
`amount`INTEGER(required)
Amount in smallest currency unit (satangs for THB, cents for USD, yen for JPY). For example, 100000 satangs = 1,000 THB.
`currency`STRING(required)
ISO 4217 three-letter currency code in lowercase.
`destination`STRING(required)
Recipient ID to receive automatic transfer after charge succeeds. Required for marketplace payment splitting.
Required - 1 of 3 fieldsPayment Method (one required)
`card`STRING(optional)
Token ID from Omise.js (e.g., tokn_test_...) or card ID from a customer (e.g., card_test_...). Required if customer and source not provided.
`source`STRING(optional)
Source ID for alternative payment methods like PromptPay, mobile banking, or QR codes. Required if card and customer not provided.
`customer`STRING(optional)
Customer ID. Will charge the customer's default card. Can be combined with card to specify a specific card. Required if card and source not provided.
Recommended - 2 fieldsRecommended Parameters
Additional - 1 fieldAdditional Parameters
Responsesโ
200
Successful transactionCharge with chain created successfully. An automatic transfer will be created to the destination recipient after the charge succeeds.
Response includes:
destination- Recipient ID for the automatic transferchain- Chain ID linking the charge to transferplatform_fee- Platform commission detailsstatus- Charge status (successful, pending, failed, etc.)
400
Bad requestRequest validation failed. Check the error message for details.
Common causes:
- Missing required fields (
amount,currency,destination) - Invalid currency code
- No payment method provided (
card,source, orcustomer) - Invalid destination recipient ID
401
UnauthorizedAuthentication failed. Invalid or missing API key.
Common causes:
- Missing Authorization header
- Invalid secret key
- Using public key instead of secret key
- Incorrect HTTP Basic Auth format
Code samplesโ
- cURL
- Ruby
- Python
- Node.js
- PHP
- Java
- C#
- Go
curl https://api.omise.co/charges \
-u skey_test_5xuy4w91xqz7d1w9u0t: \
-d "amount=100000" \
-d "currency=thb" \
-d "card=tokn_test_5xuy4w91xqz7d1w9u0t" \
-d "destination=recp_test_5xuy4w91xqz7d1w9u0t"
require 'omise'
Omise.api_key = 'skey_test_5xuy4w91xqz7d1w9u0t'
charge = Omise::Charge.create({
amount: 100000,
currency: 'thb',
card: 'tokn_test_5xuy4w91xqz7d1w9u0t',
destination: 'recp_test_5xuy4w91xqz7d1w9u0t'
})
import omise
omise.api_secret = 'skey_test_5xuy4w91xqz7d1w9u0t'
charge = omise.Charge.create(
amount=100000,
currency='thb',
card='tokn_test_5xuy4w91xqz7d1w9u0t',
destination='recp_test_5xuy4w91xqz7d1w9u0t'
)
const omise = require('omise')({
secretKey: 'skey_test_5xuy4w91xqz7d1w9u0t'
});
const charge = await omise.charges.create({
amount: 100000,
currency: 'thb',
card: 'tokn_test_5xuy4w91xqz7d1w9u0t',
destination: 'recp_test_5xuy4w91xqz7d1w9u0t'
});
<?php
define('OMISE_SECRET_KEY', 'skey_test_5xuy4w91xqz7d1w9u0t');
$charge = OmiseCharge::create([
'amount' => 100000,
'currency' => 'thb',
'card' => 'tokn_test_5xuy4w91xqz7d1w9u0t',
'destination' => 'recp_test_5xuy4w91xqz7d1w9u0t'
]);
Client client = new Client.Builder()
.secretKey("skey_test_5xuy4w91xqz7d1w9u0t")
.build();
Charge charge = client.charges().create()
.amount(100000L)
.currency("thb")
.card("tokn_test_5xuy4w91xqz7d1w9u0t")
.destination("recp_test_5xuy4w91xqz7d1w9u0t")
.send();
var client = new Client("skey_test_5xuy4w91xqz7d1w9u0t");
var charge = await client.Charges.Create(new CreateChargeRequest
{
Amount = 100000,
Currency = "thb",
Card = "tokn_test_5xuy4w91xqz7d1w9u0t",
Destination = "recp_test_5xuy4w91xqz7d1w9u0t"
});
client, _ := omise.NewClient(
"pkey_test_5xuy4w91xqz7d1w9u0t",
"skey_test_5xuy4w91xqz7d1w9u0t",
)
charge, _ := client.Charges().Create(&operations.CreateCharge{
Amount: 100000,
Currency: "thb",
Card: "tokn_test_5xuy4w91xqz7d1w9u0t",
Destination: "recp_test_5xuy4w91xqz7d1w9u0t",
})
Error and result codesโ
Common Error Codesโ
| Code | Description | Resolution |
|---|---|---|
bad_request | Missing or invalid parameters | Check all required fields are provided |
authentication_failure | Invalid API key | Verify your secret key is correct |
invalid_recipient | Invalid destination recipient ID | Verify recipient exists and is active |
recipient_not_verified | Recipient not verified | Recipient must be verified before receiving transfers |
Charge Status Codesโ
| Status | Description |
|---|---|
successful | Payment completed successfully |
pending | Awaiting customer action (e.g., scan QR code) |
failed | Payment failed (see failure_code) |
reversed | Charge cancelled/reversed |
expired | Charge expired before payment |
Try it outโ
Required - 3 fields
Required - 1 of 3Payment Method (1 required)
Recommended - 2 fields
Additional - 1 fields