abelaguiar/cielo-api

Cielo API 的 PHP-SDK

1.1.4 2018-08-18 13:33 UTC

This package is auto-updated.

Last update: 2024-09-17 05:35:54 UTC


README

PHP from Packagist Packagist Packagist Build Status

我在进行中,目前请勿认真对待我的更改。Cielo 文档: https://developercielo.github.io/manual/cielo-ecommerce#sandbox-e-ferramentas

通过 Composer 安装

您可以通过终端执行以下命令进行安装

composer require abelaguiar/cielo-api

或者您可以在您的 composer.json 文件中添加以下内容

"require": {
    "abelaguiar/cielo-api": "^1.1.1"
}

执行简单交易

<?php

require_once('vendor/autoload.php');

use AbelAguiar\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();

咨询或捕获交易

<?php

require_once('vendor/autoload.php');

use AbelAguiar\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');