Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

11 Commits

Repository files navigation

Banco Inter PHP client

The Banco Inter PHP client provides convenient access to the Banco Inter API from applications written in the PHP language.

Other languages

enpt-br

Requirements

PHP 7.4.0 and later.

Composer

You can install the package via Composer. Run the following command:

composer require potelo/inter-php

Or simply add it to your composer.json dependences and run composer update:

"require": {
"potelo/inter-php": "dev-main"
}

To use the client, use Composer's autoload:

require_once'vendor/autoload.php';

Dependencies

The library require the following extensions in order to work properly:

If you use Composer, these dependencies should be handled automatically. If you install manually, you'll want to make sure that these extensions are available.

Usage

Getting Authorization doc

$privateKey = 'you-private-key-path.key';
$certificate = 'you-certificate-path.crt';
$clientId = 'you-client-id';
$clientSecret = 'your-client-secret';
$client = new \Potelo\InterPhp\InterClient($privateKey, $certificate, $clientId, $clientSecret);
$scopes = ['cob.read'];
$client->authorize($scopes);

You can get new token with new scopes using the same client instance:

$scopes = ['cob.read', 'cob.write', 'pix.read', 'pix.write'];
$client->authorize($scopes);

Bank Slip Charge API

getdoc

Get a Bank Slip.

$bankSlip = $client->bankSlipApi()->get('bank-slip-our-number');
print_r($bankSlip);

getPdfdoc

Get a Bank Slip PDF.

$bankSlip = $client->bankSlipApi()->getPdf('bank-slip-our-number');
print_r($bankSlip);

createdoc

Create a Bank Slip.

$yorNumber = "your-number";
$dueDate = new \DateTime('2023-03-31');
$payer = newPayer("cpf number", "FISICA", "Payer Name", "Address", "Salvador", "BA", "41000000");
$bankSlip = $this->client->bankSlipApi()->create($yorNumber, 10.90, $dueDate, 0, $payer);
print_r($bankSlip);

listdoc

Get a list of Bank Slips in a period.

$after = new \DateTime('2023-03-31');
$before = new \DateTime('2023-03-31');
$bankSlips = $this->client->bankSlipApi()->list($after, $before);
print_r($bankSlips);

Other filters

You can pass an array of filters to the list method.

$after = new \DateTime('2023-03-31');
$before = new \DateTime('2023-03-31');
$filters = [
'filtrarDataPor' => 'VENCIMENTO',
];
$bankSlips = $this->client->bankSlipApi()->list($after, $before, $filters);
print_r($bankSlips);

summarydoc

Get a summary of a list of Bank Slips.

$after = new \DateTime('2023-03-31');
$before = new \DateTime('2023-03-31');
$summary = $this->client->bankSlipApi()->summary($after, $before);
print_r($summary);

canceldoc

Cancel a Bank Slip.

$cancelReason = "APEDIDODOCLIENTE";
$this->client->bankSlipApi()->cancel('bank-slip-our-number', $cancelReason);

Immediate Charge Pix API

getdoc

Get an Immediate Charge by transaction id.

$immediateCharge = $client->immediateChargeApi()->get('your-immediate-charge-txid');
print_r($immediateCharge);

createdoc

Create an Immediate Charge.

$amount = 12.50;
$pixKey = 'your-pix-key';
$expiry = 3600; // seconds$data = [
"devedor" => [
"cpf" => "01234567891",
"nome" => "John Doe"
],
"loc" => [
"tipoCob" => "cob"
],
"solicitacaoPagador" => "",
"infoAdicionais" => [
[
"nome" => "Product",
"valor" => "cool pajamas"
]
]
];
$immediateCharge = $client->immediateChargeApi()->create($pixKey, $amount, $expiry, $data);
print_r($immediateCharge);

createAsdoc

Create an Immediate Charge specifying a unique transaction id.

$txId = 'your-unique-transaction-id';
$amount = 12.44;
$pixKey = 'your-pix-key';
$secondsToExpiry = 3600;
$data = [
"devedor" => [
"cpf" => "01234567891",
"nome" => "John Doe"
],
"loc" => [
"tipoCob" => "cob"
],
"solicitacaoPagador" => "",
"infoAdicionais" => [
[
"nome" => "Product",
"valor" => "cool pajamas"
]
]
];
$immediateCharge = $client->immediateChargeApi()->createAs($txId, $pixKey, $amount, $secondsToExpiry, $data);
print_r($immediateCharge);

updatedoc

Update an Immediate Charge.

$data = [
"valor" => 22.50
];
$immediateCharge = $client->immediateChargeApi()->update('immediate-charge-txid', $data);
print_r($immediateCharge);

listdoc

Get a list of Immediate Charges in a period.

$after = new \DateTime('2023-03-01T00:00:00-03:00');
$before = new \DateTime('2023-03-23T23:59:00-03:00');
$immediateCharges = $client->immediateChargeApi()->list($after, $before);
print_r($immediateCharges);

Other filters

You can pass an array of filters to the list method.

$after = new \DateTime('2023-03-01T00:00:00-03:00');
$before = new \DateTime('2023-03-23T23:59:00-03:00');
$filters = [
'cpf' => '01234567891',
];
$immediateCharges = $client->immediateChargeApi()->list($after, $before, $filters);
print_r($immediateCharges);

Pix Pix API

getdoc

Get a Pix by transaction id.

$pix = $client->pixApi()->get('pix-endToEndId');
print_r($pix);

listdoc

Get a list of Pix in a period.

$after = new \DateTime('2023-03-01T00:00:00-03:00');
$before = new \DateTime('2023-03-23T23:59:00-03:00');
$pixList = $client->immediateChargeApi()->list($after, $before);
print_r($pixList);

returnPixdoc

Return a Pix.

$id = 'your-unique-id';
$amountToReturn = 12.44;
$pix = $client->pixApi()->returnPix('pix-endToEndId', $id, $amountToReturn);
print_r($pix);

getReturnPixdoc

Get a Pix return.

$id = 'your-unique-id';
$pix = $client->pixApi()->getReturnPix('pix-endToEndId', $id);
print_r($pix);

API Documentation

The Banco Inter API documentation can be found here.

About

The Banco Inter PHP Library provides convenient access to the Banco Inter API from applications written in the PHP language.

Topics

Resources

Stars

6 stars

Watchers

3 watching

Forks

Releases

Packages

Contributors

Languages