PHP code example of jlcd / api-cielo30-laravel

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


(...)

   'providers' => [

    (...)

        /*
         * Package Service Providers...
         */

        // Cielo
        jlcd\CieloLaravel\CieloServiceProvider::class,

    (...)

    ],

(...)



return [

    'merchant_id'  => env('CIELO_ID', 'default_id'),
    'merchant_key' => env('CIELO_KEY', 'default_key'),
    'environment'  => env('CIELO_ENV', 'default_environment'), // production | sandbox

];


(...)

$app->configure('cielo');
$app->register(jlcd\CieloLaravel\CieloServiceProvider::class);

(...)



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

Route::get('/', function () {
    $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');

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

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



use jlcd\Cielo\Resources\CieloPayment;

Route::get('/cancel/{id}', function ($id) {
    $payment = new CieloPayment();
    $payment->setId($id);
    $payment->setValue(1541);

    $payment = app()->cielo->cancelPayment($payment);
    dd($payment);
});



use jlcd\Cielo\Resources\CieloPayment;
Route::get('/capture/{id}', function ($id) {
    $payment = new CieloPayment();
    $payment->setId($id);
    $payment->setValue(1541);

    $payment = app()->cielo->capturePayment($payment);
    dd($payment);
});



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

Route::get('/tokenize', function () {
    $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 = app()->cielo->tokenizeCreditCard($creditCard, $customer);
    dd($token);
});



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

Route::get('/paymenttoken/{id}', function ($id) {
    $payment = new CieloPayment();
    $payment->setValue(1541);

    $creditCard = new CieloCreditCard();
    $creditCard->setBrand('visa');
    $creditCard->setToken($id);
    $creditCard->setSecurityCode('888');
    $payment->setCreditCard($creditCard);

    $order = new CieloOrder();
    $order->setId('123');

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

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