PHP code example of jlcd / api-cielo30

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

    

jlcd / api-cielo30 example snippets




use jlcd\Cielo\Cielo;

$cielo = new Cielo(CIELO_ID, CIELO_KEY, CIELO_ENVIRONMENT);




use jlcd\Cielo\Cielo;
use jlcd\Cielo\Resources\CieloPayment;
use jlcd\Cielo\Resources\CieloCreditCard;
use jlcd\Cielo\Resources\CieloCustomer;
use jlcd\Cielo\Resources\CieloOrder;

$cielo = new Cielo(CIELO_ID, CIELO_KEY, CIELO_ENVIRONMENT);

$payment = new CieloPayment();
$payment->setValue(1541);

$creditCard = new CieloCreditCard();
$creditCard->setCardNumber('1234432112344321');
$creditCard->setExpirationDate('12/2018');
$creditCard->setBrand('visa');
$creditCard->setSecurityCode('888');
$creditCard->setHolder('Fulano');
$payment->setCreditCard($creditCard);

$order = new CieloOrder();
$order->setId('123'); // Numero de identificacao personalizado

$customer = new CieloCustomer();
$customer->setName('Fulano');

$payment = $cielo->payment($payment, $order, $customer);

var_dump($payment);




use jlcd\Cielo\Cielo;
use jlcd\Cielo\Resources\CieloPayment;

$cielo = new Cielo(CIELO_ID, CIELO_KEY, CIELO_ENVIRONMENT);

$payment = new CieloPayment();
$payment->setId('PAYMENT_ID'); // Id retornado de um pagamento realizado na Cielo
$payment->setValue(1541);

$payment = $cielo->cancelPayment($payment);

var_dump($payment);




use jlcd\Cielo\Cielo;
use jlcd\Cielo\Resources\CieloPayment;

$cielo = new Cielo(CIELO_ID, CIELO_KEY, CIELO_ENVIRONMENT);

$payment = new CieloPayment();
$payment->setId('PAYMENT_ID'); // Id retornado de um pagamento realizado na Cielo
$payment->setValue(1541);

$payment = $cielo->capturePayment($payment);

var_dump($payment);




use jlcd\Cielo\Cielo;
use jlcd\Cielo\Resources\CieloCreditCard;
use jlcd\Cielo\Resources\CieloCustomer;

$cielo = new Cielo(CIELO_ID, CIELO_KEY, CIELO_ENVIRONMENT);

$creditCard = new CieloCreditCard();
$creditCard->setCardNumber("1234432112344321");
$creditCard->setHolder("Comprador T Cielo");
$creditCard->setExpirationDate("12/2018");
$creditCard->setBrand("Visa");

$customer = new CieloCustomer();
$customer->setName('Fulano');

$token = $cielo->tokenizeCreditCard($creditCard, $customer);

var_dump($token);




use jlcd\Cielo\Cielo;
use jlcd\Cielo\Resources\CieloPayment;
use jlcd\Cielo\Resources\CieloCreditCard;
use jlcd\Cielo\Resources\CieloCustomer;
use jlcd\Cielo\Resources\CieloOrder;

$cielo = new Cielo(CIELO_ID, CIELO_KEY, CIELO_ENVIRONMENT);

$payment = new CieloPayment();
$payment->setValue(1541);

$creditCard = new CieloCreditCard();
$creditCard->setBrand('visa');
$creditCard->setToken('TOKEN_DO_CARTAO'); // Gerado via tokenizeCreditCard
$creditCard->setSecurityCode('888');
$payment->setCreditCard($creditCard);

$order = new CieloOrder();
$order->setId('123'); // Numero de identificacao personalizado

$customer = new CieloCustomer();
$customer->setName('Fulano');

$payment = $cielo->payment($payment, $order, $customer);

var_dump($payment);