Skip to main content
Version: 2019-05-29 (Current)

Create a Charge

Create a new charge to process a payment. Charges can be created using a token (for credit cards), source (for alternative payment methods), or customer ID (for saved cards).


๐Ÿ”‘API Credentials

Request Parametersโ€‹

Required - 2 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.
Example:100000
Constraints:Minimum: 1 (smallest unit), Maximum: Varies by payment method and currency
`currency`STRING(required)
ISO 4217 three-letter currency code in lowercase.
Example:"thb"
Values:thb, jpy, sgd, myr, usd, eur, gbp
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.
Example:"tokn_test_5xuy4w91xqz7d1w9u0t"
`source`STRING(optional)
Source ID for alternative payment methods like PromptPay, mobile banking, or QR codes. Required if card and customer not provided.
Example:"src_test_5xuy4w91xqz7d1w9u0t"
`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.
Example:"cust_test_5xuy4w91xqz7d1w9u0t"
Recommended - 5 fieldsRecommended Parameters
Additional - 5 fieldsAdditional Parameters

Responsesโ€‹

200

Successful transaction

Charge created successfully. Check the status field to determine next steps.

Possible charge statuses:
  • successful - Payment completed successfully. You got paid.
  • pending - Charge not yet authorized or captured. Awaiting customer action.
  • failed - Payment failed. Check failure_code and failure_message for details.
  • reversed - Charge was reversed (uncaptured charges can be reversed).
  • expired - Pending charge expired before authorization.

400

Bad request

Request validation failed. Check the error message for details.

Common causes:
  • Missing required fields (amount, currency)
  • Invalid currency code
  • No payment method provided (card, source, or customer)
  • Invalid amount (below minimum)

401

Unauthorized

Authentication 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

402

Payment required

Payment processing failed.

Common causes:
  • Insufficient funds
  • Card declined by issuer
  • Expired card
  • 3D Secure authentication failed
  • Invalid card number or CVV

Code samplesโ€‹

curl https://api.omise.co/charges \
-u skey_test_5xuy4w91xqz7d1w9u0t: \
-d "amount=100000" \
-d "currency=thb" \
-d "card=tokn_test_5xuy4w91xqz7d1w9u0t"

Error and result codesโ€‹

Common Error Codesโ€‹

CodeDescriptionResolution
bad_requestMissing or invalid parametersCheck all required fields are provided
authentication_failureInvalid API keyVerify your secret key is correct
invalid_cardCard validation failedCheck card number, expiry, CVV
insufficient_fundsCard has insufficient fundsRequest different payment method
stolen_or_lost_cardCard reported stolen/lostPayment blocked for security
failed_fraud_checkFailed fraud detectionContact Omise support

Charge Status Codesโ€‹

StatusDescription
successfulPayment completed successfully
pendingAwaiting customer action (e.g., scan QR code)
failedPayment failed (see failure_code)
reversedCharge cancelled/reversed
expiredCharge expired before payment

Try it outโ€‹

Required - 2 fields
โ–ผ
Required - 1 of 3Payment Method (1 required)
โ–ผ
Recommended - 5 fields
Additional - 5 fields