PHP code example of csweb / bin-pagamentos
1. Go to this page and download the library: Download csweb/bin-pagamentos 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/ */
csweb / bin-pagamentos example snippets
SWeb\BIN\Environment;
use CSWeb\BIN\Transactions\Sale;
use CSWeb\BIN\Bin;
$payload = [
'CreditCardTxType' => [
'Type' => 'sale'
],
'CreditCardData' => [
'CardNumber' => 411111111111,
'ExpMonth' => 12,
'ExpYear' => 30,
'CardCodeValue' => 123
],
'Payment' => [
'NumberOfInstallments' => 1, // Opcional
'ChargeTotal' => 10.0,
'Currency' => 986 // REAL formato ISO
],
'TransactionDetails' => [
'OrderId',
'TDate'
],
'cardFunction' => 'credit'
];
$sale = new Sale($payload, 'v1');
$env = new Environment('username', 'password', 'path/to/cert', 'path/to/key', 'ssl_key');
$bin = new Bin($env);
$response = $bin->send($sale);
SWeb\BIN\Environment;
use CSWeb\BIN\Transactions\RevokeSale;
use CSWeb\BIN\Bin;
$payload = [
'CreditCardTxType' => [
'Type' => 'void'
],
'TransactionDetails' => [
'OrderId' => 1,
'TDate' => 1190244932
]
];
$sale = new RevokeSale($payload, 'v1');
$env = new Environment('username', 'password', 'path/to/cert', 'path/to/key', 'ssl_key');
$bin = new Bin($env);
$response = $bin->send($sale);