Mark charge as failed
Mark a test charge as failed. This endpoint is primarily used for testing and reconciliation purposes with limited support for specific payment methods.
API Credentials
Request Parametersโ
Required - 1 fieldRequired Parameters
`id`STRING(required)
The charge ID to mark as failed. Must be a test charge that is eligible for manual status updates.
Responsesโ
200
Successfully marked as failedCharge status updated to failed.
Key field changes:
status- Changes to failedfailure_code- Set to appropriate failure codefailure_message- Descriptive failure message
400
Bad requestRequest validation failed.
Common causes:
- Invalid charge ID format
- Charge not eligible for manual failure
- Using live charge (only test charges supported)
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)
Code samplesโ
- cURL
- Ruby
- Python
- Node.js
- PHP
- Java
- C#
- Go
curl https://api.omise.co/charges/chrg_test_5xuy4w91xqz7d1w9u0t/mark_as_failed \
-X POST \
-u skey_test_5xuy4w91xqz7d1w9u0t:
require 'omise'
Omise.api_key = 'skey_test_5xuy4w91xqz7d1w9u0t'
charge = Omise::Charge.mark_failed('chrg_test_5xuy4w91xqz7d1w9u0t')
import omise
omise.api_secret = 'skey_test_5xuy4w91xqz7d1w9u0t'
charge = omise.Charge.mark_failed('chrg_test_5xuy4w91xqz7d1w9u0t')
const omise = require('omise')({
secretKey: 'skey_test_5xuy4w91xqz7d1w9u0t'
});
const charge = await omise.charges.markFailed('chrg_test_5xuy4w91xqz7d1w9u0t');
<?php
define('OMISE_SECRET_KEY', 'skey_test_5xuy4w91xqz7d1w9u0t');
$charge = OmiseCharge::retrieve('chrg_test_5xuy4w91xqz7d1w9u0t');
$charge->markFailed();
Client client = new Client.Builder()
.secretKey("skey_test_5xuy4w91xqz7d1w9u0t")
.build();
Charge charge = client.charges().markFailed("chrg_test_5xuy4w91xqz7d1w9u0t")
.send();
var client = new Client("skey_test_5xuy4w91xqz7d1w9u0t");
var charge = await client.Charges.MarkFailed("chrg_test_5xuy4w91xqz7d1w9u0t");
client, _ := omise.NewClient(
"pkey_test_5xuy4w91xqz7d1w9u0t",
"skey_test_5xuy4w91xqz7d1w9u0t",
)
charge, _ := client.MarkChargeFailed("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_eligible | Charge cannot be marked as failed | Check charge status and payment method |
already_failed | Charge already failed | No action needed |
not_test_charge | Only test charges supported | Use test key and test charge |
Try it outโ
Required - 1 fields