Make your transactions with more convenience.
EBANX supports recurring payments via credit card tokenization. You can create tokens along with a payment request when calling the API method direct or separately using the API method token . The customer information is sent all together during the token creation.
That way, in the subsequent payments you just use the token to charge the customer’s credit card. Very simple, right?
It’s important to know that tokens expire after 14 months of its last use and can only be used in the Direct API integration.
Creating a token
curl
Copy
curl -X POST 'https://staging.ebanx.com.br/ws/token' \
-d 'request_body={
"integration_key": "your_test_integration_key",
"payment_type_code": "visa",
"country": "br",
"creditcard": {
"card_number": "4111111111111111",
"card_name": "Jose da Silva",
"card_due_date": "10/2020",
"card_cvv": "123"
}
}'
A successful request will return a JSON expression similar to the one below.
Copy
{
"status": "SUCCESS",
"payment_type_code": "visa",
"token": "805c49a8c606b4f2d53fad5aa688ec6c3aa247b83ac2146ee148e328244670b16f5cb719766b3a82e902387670958e71c323413c62df5ce975c1abf99d2049c6",
"masked_card_number": "411111xxxxxx1111"
}
You will need to store the token to further use, and you may also store the masked card number to display for the customer.
Charging the customer
To charge a customer using the token, you will have to send the entire customer data but the credit card number, credit card CVV – you will send the token instead.
curl
Copy
curl -X POST 'https://staging.ebanx.com.br/ws/direct' \
-d 'request_body={
"integration_key": "your_test_integration_key",
"operation": "request",
"mode": "full",
"payment": {
"merchant_payment_code": "70976036df5",
"amount_total": 100,
"currency_code": "BRL",
"name": "Jose da Silva",
"email": "jose@example.com",
"birth_date": "12/04/1979",
"document": "853.513.468-93",
"address": "Rua E",
"street_number": "1040",
"city": "Maracanaú",
"state": "CE",
"zipcode": "61919-230",
"country": "br",
"phone_number": "(85) 2284-7035",
"payment_type_code": "visa",
"creditcard": {
"token": "805c49a8c606b4f2d53fad5aa688ec6c3aa247b83ac2146ee148e328244670b16f5cb719766b3a82e902387670958e71c323413c62df5ce975c1abf99d2049c6"
}
}
}'
Copy
var module = require('ebanx');
var ebanx = new module();
ebanx.configure({
integrationKey: "your_test_integration_key",
testMode: true
});
var direct = {
mode: "full",
operation: "request",
payment: {
name: "Jose da Silva",
email: "jose@example.com",
birth_date: "12/04/1979",
document: "853.513.468-93",
address:"Rua E",
street_number: "1040",
city: "Maracanaú",
state: "CE",
zipcode: "61919-230",
country: "br",
phone_number: "(85) 2284-7035",
payment_type_code: "visa",
merchant_payment_code: "0baba44581e",
currency_code: "BRL",
amount_total: 100.00,
creditcard: {
token: "805c49a8c606b4f2d53fad5aa688ec6c3aa247b83ac2146ee148e328244670b16f5cb719766b3a82e902387670958e71c323413c62df5ce975c1abf99d2049c6"
}
}
};
ebanx.direct(direct, function(err, reply) {
if (err) {
console.log(err);
} else {
console.log(reply);
}
});
Copy
$config = new Config([
'sandboxIntegrationKey' => 'your_test_integration_key_here',
'isSandbox' => true,
'baseCurrency' => Currency::BRL
]);
$creditCardConfig = new CreditCardConfig();
$payment = new Payment([
'type' => 'creditcard',
'address' => new Address([
'address' => 'Rua E',
'city' => 'Maracanaú',
'country' => Country::BRAZIL,
'state' => 'CE',
'streetNumber' => '1040',
'zipcode' => '61919-230'
]),
'amountTotal' => 100,
'merchantPaymentCode' => '9ecf68cef82',
'person' => new Person([
'type' => 'personal',
'document' => '853.513.468-93',
'email' => 'jose@example.com',
'name' => 'José Silva',
'phoneNumber' => '8522847035',
]),
'instalments' => 3,
'card' => new Card([
'token' => "805c49a8c606b4f2d53fad5aa688ec6c3aa247b83ac2146ee148e328244670b16f5cb719766b3a82e902387670958e71c323413c62df5ce975c1abf99d2049c6"
])
]);
$result = EBANX($config, $creditCardConfig)->create($payment);
Copy
require 'ebanx'
Ebanx.tap do |e|
e.integration_key = 'your_test_integration_key'
e.test_mode = true
end
response = Ebanx.do_direct({
mode: 'full',
operation: 'request',
payment: {
name: "Jose da Silva",
email: "jose@example.com",
birth_date: "12/04/1979",
document: "853.513.468-93",
address:"Rua E",
street_number: "1040",
city: "Maracanaú",
state: "CE",
zipcode: "61919-230",
country: "br",
phone_number: "(85) 2284-7035",
payment_type_code: "visa",
merchant_payment_code: "579b6de8723",
currency_code: "BRL",
amount_total: 100.00,
creditcard: {
token: "805c49a8c606b4f2d53fad5aa688ec6c3aa247b83ac2146ee148e328244670b16f5cb719766b3a82e902387670958e71c323413c62df5ce975c1abf99d2049c6"
}
}
})
A successful request will return a JSON expression similar to the one below.
Copy
{
"payment": {
"hash": "547cbd54c10e001921933635f1405566bedefe585e2b95ef",
"merchant_payment_code": "1417461074",
"order_number": null,
"status": "CO",
"status_date": null,
"open_date": "2014-12-01 17:11:15",
"confirm_date": null,
"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-08",
"instalments": "1",
"payment_type_code": "visa",
"transaction_status": {
"acquirer": "EBANX",
"code": "OK",
"description": "Accepted",
"authcode": "12345"
},
"pre_approved": true,
"capture_available": false
},
"status": "SUCCESS"
}