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 "
]);トークンは顧客支払いの代表(クレジットカードなど)であり、完全に安全であるため、誰かがこのトークンを使用して顧客のクレジットカード情報を取得することは不可能です。トークンは特定のトランザクションのために生成され、さらに安全になります。
<?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 "
]);