PHP code example of descubraomundo / omnipay-ebanx

1. Go to this page and download the library: Download descubraomundo/omnipay-ebanx library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

descubraomundo / omnipay-ebanx example snippets

 php
// Create a gateway for the Ebanx Gateway
  // (routes to GatewayFactory::create)
  $gateway = Omnipay::create('Ebanx');

  // Initialise the gateway
  $gateway->initialize(array(
      'integration_key' => 'MyApiKey',
  ));

  // Create a credit card object
  // This card can be used for testing.
  $card = new CreditCard(array(
              'firstName'    => 'Example',
              'lastName'     => 'Customer',
              //'name'         => 'Example Customer',
              'birthday'     => '1988-02-28',
              'gender'       => 'M',
              'number'       => '4242424242424242',
              'expiryMonth'  => '01',
              'expiryYear'   => '2020',
              'cvv'          => '123',
              'email'        => '[email protected]',
              'address1'     => 'Street name, Street number, Complementary',
              'address2'     => 'Neighborhood',
              'postcode'     => '05443100',
              'phone'        => '19 3242 8855',
  ));

  // Do an authorize transaction on the gateway
  $transaction = $gateway->authorize(array(
      'amount'           => '10.00',
      'paymentMethod'   => 'creditcard',
      'installments'     => 5,
      'documentNumber' => '246.375.149-23', // CPF or CNPJ
      'notifyUrl'     => 'http://application.com/api/',
      'card'             => $card,
      // 'cardReference'      => 'card_k5sT...',
  ));
  $response = $transaction->send();
  if ($response->isSuccessful()) {
      echo "Authorize transaction was successful!\n";
      $sale_id = $response->getTransactionReference();
      echo "Transaction reference = " . $sale_id . "\n";
  }
 php
  // Create a gateway for the Ebanx Gateway
  // (routes to GatewayFactory::create)
  // Create array with customer data
  $customer = array(
              'firstName'    => 'Example',
              'lastName'     => 'Customer',,
              'email'        => '[email protected]',
              'address1'     => 'Street name, Street number, Complementary',
              'address2'     => 'Neighborhood',
              'postcode'     => '05443100',
              'phone'        => '19 3242 8855',
  ));

  // Create a credit card object
  // The card object is   'address2'     => 'Neighborhood',
              'city'         => 'City',
              'state'        => 'sp',
              'country'      => 'BR',
              'postcode'     => '05443100',
              'phone'        => '19 3242 8855',
  ));

  // Do an authorize transaction on the gateway
  $transaction = $gateway->authorize(array(
      'amount'           => '10.00',
      'paymentMethod'   => 'boleto',
      'documentNumber' => '246.375.149-23', // CPF or CNPJ
      'notifyUrl'     => 'http://application.com/api/',
      'card'             => $card,
  ));

  $response = $transaction->send();
  if ($response->isSuccessful()) {
      echo "Authorize Boleto transaction was successful!\n";
      $sale_id = $response->getTransactionReference();
      $boleto = $response->getBoleto();
      echo "Boleto Url = " . $boleto['boleto_url'];
      echo "Boleto Barcode = " . $boleto['boleto_barcode'];
      echo "Boleto Expiration Date = " . $boleto['boleto_expiration_date'];
      echo "Transaction reference = " . $sale_id . "\n";
  }
 php
 // Create a gateway for the Ebanx Gateway
  // (routes to GatewayFactory::create)
  $gateway = Omnipay::create('Ebanx');

  // Initialise the gateway
  $gateway->initialize(array(
      'testMode' => true,
      'integration_key' => 'MyApiKey',
  ));