To cancel a payment, you must call the API method cancel . You can cancel a payment if, only if, its status is open (OP) or pending (PE). It’s important to remember that is not possible to cancel confirmed payments (CO), only refunded.
curl
Node.js
PHP
Ruby
Copy
curl -X POST -G 'https://staging.ebanx.com.br/ws/cancel' \
-d 'integration_key=your_test_integration_key' \
-d 'hash=5476099e890c06ca6f02cae9da1b1faaf3c5929439076cb9'
Copy
var module = require('ebanx');
var ebanx = new module();
ebanx.configure({
integrationKey : "your_test_integration_key",
testMode : true
});
var params = {
hash: "5476099e890c06ca6f02cae9da1b1faaf3c5929439076cb9"
};
ebanx.cancel(params, function(err, reply) {
if (err) {
console.log(err);
} else {
console.log(reply);
}
});
Copy
$config = new Config([
'sandboxIntegrationKey' => 'your_test_integration_key_here',
'isSandbox' => true,
]);
$ebanx = EBANX($config);
$response = $ebanx->cancelPayment()->request("5476099e890c06ca6f02cae9da1b1faaf3c5929439076cb9");
Copy
require 'ebanx'
Ebanx.tap do |e|
e.integration_key = 'your_test_integration_key'
e.test_mode = true
end
response = Ebanx.do_cancel hash: '54737a76ffc1e5a520b0ed9062213a810ef41dae990184c7'
A successful request will return a JSON expression similar to the one below.
Copy
{
"payment": {
"hash": "5476099e890c06ca6f02cae9da1b1faaf3c5929439076cb9",
"merchant_payment_code": "1461416920319",
"order_number": "146",
"status": "CA",
"status_date": "2014-11-26 17:34:11",
"open_date": "2014-11-25 10:45:56",
"confirm_date": null,
"transfer_date": null,
"amount_br": "204.45",
"amount_ext": "204.45",
"amount_iof": "0.00",
"currency_rate": "1.0000",
"currency_ext": "BRL",
"due_date": "2014-12-2",
"instalments": "1",
"payment_type_code": "boleto",
"pre_approved": false,
"capture_available": null,
},
"operation": "cancel",
"status": "SUCCESS"
}