Version: current

EBANX PHP

This library enables you to integrate EBANX with any PHP application.

Requirements

  • PHP >= 5.6
  • cURL

Installation

Composer

The EBANX library is available on Packagist, therefore you can install it by just updating your composer.json file:

{
"require" : {
"ebanx/benjamin": "^1.14.0"
}
}

After that run composer install, wait for it to finish.

Usage

It is very simple to use Benjamin. You will only need an instance of Ebanx\Benjamin\Models\Configs\Config:

If you need to change other settings, you can use the following function call:

$config = new Config([
//Config properties
]);
$ebanx = EBANX($config);

Here’s an example of configuration:

$config = new Config([
'integrationKey' => 'YOUR_INTEGRATION_KEY',
'sandboxIntegrationKey' => 'YOUR_SANDBOX_INTEGRATION_KEY',
'isSandbox' => true,
'baseCurrency' => Currency::USD
]);

You can change the following settings:

  • integrationKey: Your integration key. This key will only be used on the live environment.
  • sandboxIntegrationKey: Your sandbox integration key. This key will only be used on the test environment.
  • isSandbox: Enable or disable the test mode. The default value is false.
  • baseCurrency: The base currency of the trasaction

Here’s an example of payment request:

$payment = new Payment([
'type' => 'boleto',
'address' => new Address([
'address' => 'Rua Rodrigues',
'city' => 'Vila Malena d\'Oeste',
'country' => Country::BRAZIL,
'state' => 'MS',
'streetComplement' => 'Apto 35',
'streetNumber' => '55',
'zipcode' => '10493-222'
]),
'amountTotal' => 48.63,
'deviceId' => 'b2017154beac2625eec083a5d45d872f12dc2c57535e25aa149d3bdb57cbdeb9',
'merchantPaymentCode' => 'a6d690137e32c38db369beed8844e997',
'note' => 'Example payment.',
'person' => new Person([
'type' => 'business',
'birthdate' => new \DateTime('1978-03-29 08:15:51.000000 UTC'),
'document' => '40701766000118',
'email' => 'sdasneves@r7.com',
'ip' => '30.43.84.28',
'name' => 'Sr. Gustavo Fernando Valência',
'phoneNumber' => '(43) 3965-4162'
]),
'items' => [
new Item ([
'sku' => 'S-NDI-359444',
'name' => 'consequuntur perferendis',
'description' => 'Aut aliquid quibusdam quidem neque alias aliquid culpa maxime. Totam voluptatum et fuga nesciunt expedita rerum.',
'unitPrice' => 7.19,
'quantity' => 3,
'type' => 'sed'
]),
new Item ([
'sku' => 'X-LQF-592041',
'name' => 'esse sint',
'description' => 'Eligendi error iusto et ut. Cupiditate sint ut et in vitae non.',
'unitPrice' => 9.02,
'quantity' => 3,
'type' => 'est'
])
],
'responsible' => new Person ([
'type' => 'personal',
'birthdate' => new \DateTime ('1986-06-18 10:18:33 UTC'),
'document' => '38346222653',
'email' => 'alessandra.dominato@galhardo.net',
'ip' => '49.29.237.45',
'name' => 'Luana Aragão Mendes',
'phoneNumber' => '(74) 97063-8157',
]),
'dueDate' => new \DateTime ('2017-05-20 01:47:31 UTC')
]);
$result = EBANX($config)->create($payment);
// Type can also be explicit, like so:
$result = EBANX($config)->boleto()->create($payment);

Here’s an example of response:

Array
(
[payment] => Array
(
[hash] => 591b803da5549b6a1bac524b31e6eef55c2e67af8e40e1e4
[pin] => 670071563
[merchant_payment_code] => 248b2672f000e293268be28d6048d600
[order_number] => null
[status] => PE
[status_date] => null
[open_date] => 2017-05-16 19:42:05
[confirm_date] => null
[transfer_date] => null
[amount_br] => 48.81
[amount_ext] => 48.63
[amount_iof] => 0.18
[currency_rate] => 1.0000
[currency_ext] => BRL
[due_date] => 2018-11-22
[instalments] => 1
[payment_type_code] => boleto
[boleto_url] => https://sandbox.ebanxpay.com/print/?hash=591b803da5549b6a1bac524b31e6eef55c2e67af8e40e1e4
[boleto_barcode] => 34191760071244348372714245740007871600000004881
[boleto_barcode_raw] => 34198716000000048811760012443483721424574000
[pre_approved] => null
[capture_available] => null
[customer] => Array
(
[document] => 40701766000118
[email] => sdasneves@r7.com
[name] => SR GUSTAVO FERNANDO VALENCIA
[birth_date] => 1978-03-28
)
)
[status] => SUCCESS
)

Contributing

Found a bug? Want to add a new feature? Go on and send a pull request to our GitHub repository:

https://github.com/ebanx/benjamin/

Last updated on by Fernando Pankiewicz Gomes