iugu php
1.0.0
為了使其靈活而構建此lib,以便每個人都可以使用所有API版本的所有功能。
您可以通過訪問此鏈接訪問IUGU的官方文檔。
使用命令安裝庫
composer require igorsamaral/iugu-php
要在項目中包括圖書館,請執行以下操作:
<?php
require __DIR__ . " /vendor/autoload.php "
$ iugu = new IuguClient( " SUA_CHAVE_DE_API ");Client對象的實例化過程中通知他們: <?php
require __DIR__ . " /vendor/autoload.php "
$ iugu = new iuguClient(
" SUA_CHAVE_DE_API ",
[ " headers " => [ " MEU_HEADER_CUSTOMIZADO " => " VALOR HEADER CUSTOMIZADO " ]]
); 然後,您可以使用客戶向yugu.com.br提出請求,如下所示。
客戶代表您的商店或業務的用戶。該對象包含有關它們的信息,例如名稱,電子郵件和電話以及其他字段。
<?php
$ customer = $ iugu -> customers ()-> create ([
" email " => " [email protected] " ,
" name " => " João das Neves " ,
" notes " => " lorem... " ,
" phone " => " 999999999 " ,
" phone_prefix " => " 11 " ,
" cpf_cnpj " => " 11743685009 " ,
" zip_code " => " 76814112 " ,
" number " => " 100 " ,
" street " => " Rua Cabedelo " ,
" city " => " Porto Velho " ,
" state " => " RO " ,
" district " => " Marcos Freire " ,
" complement " => " complemento... " ,
" custom_variables " => [
" key " => " value "
]
]); <?php
$ customers = $ iugu -> customers ()-> getList (); <?php
$ customer = $ iugu -> customers ()-> get ([
" id " => " ID_DO_CLIENTE "
]);Token是客戶付款代表(例如您的信用卡),完全安全,因此不可能使用此代幣獲得客戶信用卡信息。代幣是用於特定交易的產生的,使其更安全。
<?php
$ token = $ iugu -> paymentToken ()-> create ([
" account_id " => " ID_DA_SUA_CONTA_IUGU " ,
" customer_id " => " ID_DO_CUSTOMER " ,
" method " => " credit_card " ,
" data " => [
" number " => " 4242424242424242 " ,
" verification_value " => " 648 " ,
" first_name " => " João " ,
" last_name " => " das Neves " ,
" month " => " 01 " ,
" year " => " 2023 "
],
" test " => true ,
]);通過票證或信用卡簡單收費。
<?php
$ charge = $ iugu -> charges ()-> create ([
" token " => " ID_DO_TOKEN_DE_PAGAMENTO_CRIADO " ,
" customer_id " => " ID_DO_CUSTOMER " ,
" total " => 10000 ,
" payer " => [
" cpf_cnpj " => " 84752882000 " ,
" name " => " João das Neves " ,
" address " => [
" zip_code " => " 72917210 " ,
" number " => " 100 "
]
],
" items " : [
[
" description " => " Descrição do item 1 " ,
" quantity " => 1 ,
" price_cents " => 10000
]
]
]);為客戶創建發票。
<?php
$ invoice = $ iugu -> invoices ()-> create ([
" email " => " [email protected] " ,
" due_date " => " 2021-07-21 " ,
" items " => [
[
" description " => " Descrição do item 1 " ,
" quantity " => 1 ,
" price_cents " => 10000
]
],
" total " => 10000 ,
" payer " => [
" cpf_cnpj " => " 84752882000 " ,
" name " => " João das Neves " ,
" address " => [
" zip_code " => " 72917210 " ,
" number " => " 100 "
]
]
]); <?php
$ invoices = $ iugu -> invoices ()-> getList (); <?php
$ invoice = $ iugu -> invoices ()-> get ([
" id " => " ID_DA_FATURA "
]);