承接 potelo/inter-php 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

potelo/inter-php

Composer 安装命令:

composer require potelo/inter-php

包简介

Banco Inter PHP Library

README 文档

README

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

Other languages

en pt-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

get doc

Get a Bank Slip.

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

print_r($bankSlip);

getPdf doc

Get a Bank Slip PDF.

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

print_r($bankSlip);

create doc

Create a Bank Slip.

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

print_r($bankSlip);

list doc

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);

summary doc

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);

cancel doc

Cancel a Bank Slip.

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

Immediate Charge Pix API

get doc

Get an Immediate Charge by transaction id.

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

print_r($immediateCharge);

create doc

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);

createAs doc

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);

update doc

Update an Immediate Charge.

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

print_r($immediateCharge);

list doc

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

get doc

Get a Pix by transaction id.

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

print_r($pix);

list doc

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);

returnPix doc

Return a Pix.

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

print_r($pix);

getReturnPix doc

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.

统计信息

  • 总下载量: 22
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 6
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 6
  • Watchers: 3
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2023-03-27

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固