frmiqueias / iugu-php-sdk
Iugu API非官方集成库
v1.0.2
2018-07-14 17:31 UTC
Requires
- php: ~5.6|~7.0
- guzzlehttp/guzzle: ~6.0
Requires (Dev)
- codeclimate/php-test-reporter: ~0.3
- larapack/dd: ^1.1
- mockery/mockery: ~0.9
- phpunit/phpunit: ~5.0
- squizlabs/php_codesniffer: ~2.3
This package is auto-updated.
Last update: 2024-09-05 04:15:10 UTC
README
与Iugu API集成的库
通过composer安装
$ composer require bubbstore/iugu-php-sdk
服务
此SDK支持以下服务
配置
要使用此SDK,您需要使用您的Iugu账户访问令牌。
use bubbstore\Iugu; use bubbstore\Iugu\Exceptions\IuguException; use bubbstore\Iugu\Exceptions\IuguValidationException; $iugu = new Iugu('SEU_TOKEN');
客户
创建客户
$customer = $iugu->customer()->create([ 'name' => 'Lucas Colette', 'email' => 'lucas@bubb.com.br', ]); // Imprime o ID do cliente echo $customer['id'];
更新客户
$customer = $iugu->customer()->update('ID_CLIENTE', [ 'name' => 'John' ]);
查找客户
$customer = $iugu->customer()->find('ID_CLIENTE'); var_dump($customer);
删除客户
$iugu->customer()->delete('ID_CLIENTE');
直接收款
创建带有银行汇票的收款
$charge = $iugu->charge()->create([ 'method' => 'bank_slip', 'email' => 'lucas@bubb.com.br', 'order_id' => uniqid(), 'payer' => [ 'cpf_cnpj' => '65634052076', 'name' => 'Lucas Colette', 'phone_prefix' => '11', 'phone' => '11111111', 'email' => 'lucas@bubb.com.br', 'address' => [ 'street' => 'Foo Bar', 'number' => '123', 'district' => 'Foo', 'city' => 'Foo', 'state' => 'SP', 'zip_code' => '14940000', ], ], 'items' => [ [ 'description' => 'Item 1', 'quantity' => 1, 'price_cents' => 1000 ], [ 'description' => 'Item 2', 'quantity' => 2, 'price_cents' => 2000 ], ], ]);
使用信用卡支付账单
$charge = $iugu->charge()->create([ 'invoice_id' => '12345678', 'token' => '0000000000000000' // Token gerado através da lib iugu.js ]);
账单
创建账单
$invoice = $iugu->invoice()->create([ 'order_id' => uniqid(), 'email' => 'lucas@bubb.com.br', 'due_date' => '2018-07-14', 'notification_url' => 'https://webhook.site/08703bf2-d408-4f4c-b91c-0bc8e14352b2', 'fines' => false, 'per_day_interest' => false, 'discount_cents' => 500, 'ignore_due_email' => true, 'payable_with' => 'bank_slip', 'items' => [ [ 'description' => 'Item 1', 'quantity' => 1, 'price_cents' => 1000 ], [ 'description' => 'Item 2', 'quantity' => 2, 'price_cents' => 2000 ], [ 'description' => 'Frete', 'quantity' => 1, 'price_cents' => 1000 ], ], 'payer' => [ 'cpf_cnpj' => '65634052076', 'name' => 'Lucas Colette', 'phone_prefix' => '11', 'phone' => '11111111', 'email' => 'lucas@bubb.com.br', 'address' => [ 'street' => 'Foo Bar', 'number' => '123', 'district' => 'Foo', 'city' => 'Foo', 'state' => 'SP', 'zip_code' => '14940000', ], ], ]); // Imprime o ID da fatura echo $invoice['id'];
捕获账单
$iugu->invoice()->capture('ID_FATURA');
查找账单
$iugu->invoice()->find('ID_FATURA');
退款账单
$iugu->invoice()->refund('ID_FATURA');
取消账单
$iugu->invoice()->cancel('ID_FATURA');
支付方式
创建支付方式
$payment = $iugu->paymentMethod()->create('ID_CLIENTE', [ 'description' => 'Cartão de Crédito', 'token' => '123456', ]); // Imprime o ID do pagamento echo $payment['id'];
更新支付方式
$iugu->paymentMethod()->update('ID_CLIENTE', 'ID_METODO_PAGAMENTO', [ 'description' => 'Outra description', ]);
查找支付方式
$iugu->paymentMethod()->find('ID_CLIENTE', 'ID_METODO_PAGAMENTO');
删除支付方式
$iugu->paymentMethod()->delete('ID_CLIENTE', 'ID_METODO_PAGAMENTO');
测试
$ composer test
变更日志
请参阅CHANGELOG以获取最近更改的更多信息。
贡献
请参阅CONTRIBUTING以获取更多详细信息。
安全
如果您发现任何与安全相关的问题,请通过电子邮件发送至contato@bubbstore.com.br,而不是使用问题跟踪。