PHP code example of abelaguiar / cielo-api

1. Go to this page and download the library: Download abelaguiar/cielo-api 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/ */

    

abelaguiar / cielo-api example snippets




belAguiar\Cielo\Cielo;
use AbelAguiar\Cielo\Payments\CreditCardPayment;

// Create a new instance of Cielo...
$cielo = new Cielo(
    'Your Merchant ID goes here',
    'Your Merchant Key goes here'
);

// Create a new instance of Payment Method Credit...
$creditCard = new CreditCardPayment([
    'cardNumber' => '0000000000000001',
    'holder' => 'John F Doe',
    'expirationDate' => '12/2020',
    'securityCode' => '123',
    'installments' => 5,
    'amount' => 259.90
]);

// Set the Customer and the Payment Method...
$cielo->setCustomer('John F. Doe')
      ->setPaymentMethod($creditCard);

// Performs a transaction...
$response = $cielo->performTransaction();

// or ------------------------------------

// Create a new instance of Payment Method Debit...
$debitCard = new DebitCardPayment([
    'cardNumber' => '0000000000000001',
    'holder' => 'John F Doe',
    'expirationDate' => '12/2020',
    'securityCode' => '123',
    'amount' => 259.90,
    'returnUrl' => 'https://www.cielo.com.br'
]);

// Set the Customer and the Payment Method...
$cielo->setCustomer('John F. Doe')
      ->setPaymentMethod($debitCard);

// Performs a transaction...
$response = $cielo->performTransaction();



belAguiar\Cielo\Cielo;

// Create a new instance of Cielo...
$cielo = new Cielo(
    'Your Merchant ID goes here',
    'Your Merchant Key goes here'
);

// Consult a transaction by id...
$response = $cielo->consultTransaction('Transaction ID goes here');

// Consult a transaction by id...
$response = $cielo->captureTransaction('Transaction ID goes here');