chico-rei/cielo-ecommerce-v3-php

1.1.3 2020-05-15 20:15 UTC

This package is auto-updated.

Last update: 2024-04-16 07:54:09 UTC


README

Build Status Coverage Status Latest Stable Version License

This is a PHP client wrapper for Cielo e-Commerce v3.

Install

Via Composer

$ composer require chico-rei/cielo-ecommerce-v3-php "^1.0"

Requires PHP 7.1 or newer.

Features

  • Create Payment
    • Credit/Debit Card
    • Wallet (Visa Checkout / Masterpass / Apple Pay / Samsung Pay)
    • Boleto
    • Eletronic Transfer
    • Recurrent
  • Update Payment
    • Capture
    • Void
    • Recurrent Payment
  • Query Payment
    • By Payment ID
    • By Order ID
  • Query Card Bin
  • Tokenize Card
  • Fraud Analysis
  • Velocity
  • Zero Auth
  • Silent Order Post

Usage

require 'path/to/vendor/autoload.php';

use \ChicoRei\Packages\Cielo\Cielo;
use \ChicoRei\Packages\Cielo\Merchant;
use \ChicoRei\Packages\Cielo\Util;

$merchant = Merchant::create([
    'id' => 'Your_ID',
    'key' => 'Your_KEY',
]);

$cielo = new Cielo($merchant); // For sandbox use: new Cielo($merchant, true);

try {
    $response = $cielo->sale()->create([
        'merchantOrderId' => '19800731',
        'payment' => [
            'type' => 'CreditCard',
            'amount' => 15700, // 157,00
            'installments' => 2,
            'softDescriptor' => 'Your Company',
            'capture' => true,
            'creditCard' => [
                'cardNumber' => '4551870000000000',
                'holder' => 'Name',
                'expirationDate' => '12/2021',
                'securityCode' => '123',
                'brand' => 'Visa'
            ]
        ]
    ]);
    
    echo $response->getPayment()->getStatus(); // Transaction Status Code 
    
    $returnCode = $response->getPayment()->getReturnCode(); // Ex: '00'
    $details = Util::getReturnCodeDetails($returnCode);
    echo $details['definition']; // Transação autorizada com sucesso.
    
} catch (CieloAPIException $e) {
    // Handle API errors (or validation errors)
} catch (Exception $e) {
   // Handle exceptions
}

See examples for more.

Testing

$ composer test

Credits

Project based on DeveloperCielo/API-3.0-PHP

License

The MIT License (MIT). Please see License File for more information.