To capture a payment, you must call the API method capture . This method applies only to authorized credit card payments where auto_capture
was set to false
.
Using the hash
to capture the payment:
curl
Node.js
PHP
Ruby
Copy
curl -X POST -G 'https://staging.ebanx.com.br/ws/capture' \
-d 'integration_key=your_test_integration_key' \
-d 'hash=5478ba283ef8674415082844ee14817376e49bb76aa9d4c7'
Copy
var module = require('ebanx');
var ebanx = new module();
ebanx.configure({
integrationKey : "your_test_integration_key",
testMode : true
});
var params = {
hash: "5478ba283ef8674415082844ee14817376e49bb76aa9d4c7"
};
ebanx.capture(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);
$result = $ebanx->creditCard()->captureByHash("5478ba283ef8674415082844ee14817376e49bb76aa9d4c7");
Copy
require 'ebanx'
Ebanx.tap do |e|
e.integration_key = 'your_test_integration_key'
e.test_mode = true
end
response = Ebanx.do_capture hash: '5478ba283ef8674415082844ee14817376e49bb76aa9d4c7'
Using the merchant_payment_code
to capture the payment:
curl
Node.js
PHP
Ruby
Copy
curl -X POST -G 'https://staging.ebanx.com.br/ws/capture' \
-d 'integration_key=your_test_integration_key' \
-d 'merchant_payment_code=126378126'
Copy
var module = require('ebanx');
var ebanx = new module();
ebanx.configure({
integrationKey : "your_test_integration_key",
testMode : true
});
var params = {
merchant_payment_code: "126378126"
};
ebanx.capture(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);
$result = $ebanx->creditCard()->captureByMerchantPaymentCode("126378126");
Copy
require 'ebanx'
Ebanx.tap do |e|
e.integration_key = 'your_test_integration_key'
e.test_mode = true
end
response = Ebanx.do_capture merchant_payment_code: '126378126'
A successful request will return a JSON expression similar to the one below.
Copy
{
"payment": {
"hash": "5478ba283ef8674415082844ee14817376e49bb76aa9d4c7",
"merchant_payment_code": "126378126",
"order_number": null,
"status": "CO",
"status_date": "2014-11-28 16:09:19",
"open_date": "2014-11-28 16:08:39",
"confirm_date": "2014-11-28 16:09:19",
"transfer_date": null,
"amount_br": "100.00",
"amount_ext": "100.00",
"amount_iof": "0.00",
"currency_rate": "1.0000",
"currency_ext": "BRL",
"due_date": "2014-12-05",
"instalments": "1",
"payment_type_code": "visa",
"transaction_status": {
"acquirer": "EBANX",
"code": "OK",
"description": "Cartão de teste autorizado - aguardando captura",
"authcode": "12345"
},
"pre_approved": true,
"capture_available": false
},
"status": "SUCCESS"
}