Expire a charge
Manually expire a pending charge that has not yet been authorized. Only applicable to certain payment methods with redirect-based flows.
API Credentials
Request Parametersโ
Required - 1 fieldRequired Parameters
`id`STRING(required)
The charge ID to expire. Must be a pending charge that has not yet been authorized. Only works with supported payment sources (Alipay CN/HK, DANA, GCash, KakaoPay, PayPay, Touch 'n Go).
Responsesโ
200
Successfully expiredCharge has been marked as expired. Customer can no longer complete payment.
Key field changes after expiration:
status- Changes from pending to expiredexpired- Changes from false to trueexpired_at- Set to current timestamp
400
Bad requestRequest validation failed.
Common causes:
- Invalid charge ID format
- Charge not eligible for expiration
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 expired.
Common causes:
- Charge is not pending (already successful, failed, or expired)
- Charge already authorized
- Payment method not supported for manual expiration
- Charge created with card instead of supported source
Code samplesโ
- cURL
- Ruby
- Python
- Node.js
- PHP
- Java
- C#
- Go
curl https://api.omise.co/charges/chrg_test_5xuy4w91xqz7d1w9u0t/expire \
-X POST \
-u skey_test_5xuy4w91xqz7d1w9u0t:
require 'omise'
Omise.api_key = 'skey_test_5xuy4w91xqz7d1w9u0t'
charge = Omise::Charge.expire('chrg_test_5xuy4w91xqz7d1w9u0t')
import omise
omise.api_secret = 'skey_test_5xuy4w91xqz7d1w9u0t'
charge = omise.Charge.expire('chrg_test_5xuy4w91xqz7d1w9u0t')
const omise = require('omise')({
secretKey: 'skey_test_5xuy4w91xqz7d1w9u0t'
});
const charge = await omise.charges.expire('chrg_test_5xuy4w91xqz7d1w9u0t');
<?php
define('OMISE_SECRET_KEY', 'skey_test_5xuy4w91xqz7d1w9u0t');
$charge = OmiseCharge::retrieve('chrg_test_5xuy4w91xqz7d1w9u0t');
$charge->expire();
Client client = new Client.Builder()
.secretKey("skey_test_5xuy4w91xqz7d1w9u0t")
.build();
Charge charge = client.charges().expire("chrg_test_5xuy4w91xqz7d1w9u0t")
.send();
var client = new Client("skey_test_5xuy4w91xqz7d1w9u0t");
var charge = await client.Charges.Expire("chrg_test_5xuy4w91xqz7d1w9u0t");
client, _ := omise.NewClient(
"pkey_test_5xuy4w91xqz7d1w9u0t",
"skey_test_5xuy4w91xqz7d1w9u0t",
)
charge, _ := client.ExpireCharge("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 |
not_pending | Charge is not pending | Can only expire pending charges |
already_expired | Charge already expired | No action needed |
not_expirable | Payment method not supported | Check supported sources |
already_authorized | Charge already authorized | Cannot expire authorized charges |
Supported Payment Methodsโ
| Payment Method | Supported | Notes |
|---|---|---|
| Alipay CN | Yes | Can expire pending charges |
| Alipay HK | Yes | Can expire pending charges |
| DANA | Yes | Can expire pending charges |
| GCash | Yes | Can expire pending charges |
| KakaoPay | Yes | Can expire pending charges |
| PayPay | Yes | Can expire pending charges |
| Touch 'n Go | Yes | Can expire pending charges |
| Credit Card | No | Cards have different flow |
| PromptPay | No | PromptPay expires automatically |
Try it outโ
Required - 1 fields