Capture a charge
Capture a previously authorized charge to complete the payment. Use this for pre-authorization workflows where you authorize first (with capture=false) and capture later.
API Credentials
Request Parametersโ
Required - 1 fieldRequired Parameters
`id`STRING(required)
The charge ID to capture. Must be an uncaptured authorized charge (status: successful, authorized: true, capture: false, capturable: true).
Additional - 1 fieldAdditional Parameters
Responsesโ
200
Successful captureCharge captured successfully. Payment now completed and funds transferred.
Key field changes after capture:
capture- Changes from false to truepaid- Changes from false to truecapturable- Changes from true to falserefundable- Changes from false to truepaid_at- Set to current timestamp
400
Bad requestInvalid parameters provided.
Common causes:
- Invalid capture_amount (exceeds authorized amount)
- Invalid charge ID format
401
UnauthorizedAuthentication failed. Invalid or missing API key.
Common causes:
- Missing Authorization header
- Invalid secret key
- Using public key instead of secret key
404
Not foundCharge ID does not exist.
Common causes:
- Incorrect charge ID
- Charge from different account
- Using test key for live charge (or vice versa)
422
Unprocessable entityCharge cannot be captured.
Common causes:
- Charge already captured
- Charge not capturable (expired or reversed)
- Capture amount exceeds authorized amount
- Authorization expired (beyond 7-day window)
Code samplesโ
- cURL
- Ruby
- Python
- Node.js
- PHP
- Java
- C#
- Go
curl https://api.omise.co/charges/chrg_test_5xuy4w91xqz7d1w9u0t/capture \
-X POST \
-u skey_test_5xuy4w91xqz7d1w9u0t:
require 'omise'
Omise.api_key = 'skey_test_5xuy4w91xqz7d1w9u0t'
charge = Omise::Charge.capture('chrg_test_5xuy4w91xqz7d1w9u0t')
import omise
omise.api_secret = 'skey_test_5xuy4w91xqz7d1w9u0t'
charge = omise.Charge.capture('chrg_test_5xuy4w91xqz7d1w9u0t')
const omise = require('omise')({
secretKey: 'skey_test_5xuy4w91xqz7d1w9u0t'
});
const charge = await omise.charges.capture('chrg_test_5xuy4w91xqz7d1w9u0t');
<?php
define('OMISE_SECRET_KEY', 'skey_test_5xuy4w91xqz7d1w9u0t');
$charge = OmiseCharge::retrieve('chrg_test_5xuy4w91xqz7d1w9u0t');
$charge->capture();
Client client = new Client.Builder()
.secretKey("skey_test_5xuy4w91xqz7d1w9u0t")
.build();
Charge charge = client.charges().capture("chrg_test_5xuy4w91xqz7d1w9u0t")
.send();
var client = new Client("skey_test_5xuy4w91xqz7d1w9u0t");
var charge = await client.Charges.Capture("chrg_test_5xuy4w91xqz7d1w9u0t");
client, _ := omise.NewClient(
"pkey_test_5xuy4w91xqz7d1w9u0t",
"skey_test_5xuy4w91xqz7d1w9u0t",
)
charge, _ := client.CaptureCharge("chrg_test_5xuy4w91xqz7d1w9u0t", nil)
Error and result codesโ
Common Error Codesโ
| Code | Description | Resolution |
|---|---|---|
not_found | Charge ID doesn't exist | Verify charge ID is correct |
already_captured | Charge already captured | Check charge status before capture |
not_capturable | Charge cannot be captured | Verify capturable field is true |
capture_amount_too_high | Amount exceeds authorization | Reduce capture_amount |
authorization_expired | Pre-auth expired (>7 days) | Create new charge |
Charge Status After Captureโ
| Field | Before Capture | After Capture |
|---|---|---|
capture | false | true |
paid | false | true |
capturable | true | false |
refundable | false | true |
paid_at | null | ISO 8601 timestamp |
Try it outโ
Required - 1 fields
Additional - 1 fields