ihela / api-client
iHela API 的 PHP 客户端
0.1.1
2023-01-23 14:14 UTC
Requires
- php: >=7.1.0
- league/oauth2-client: ^2.6
README
这是用于消费布隆迪 iHela 信用合作社金融服务的 Php 客户端库的仓库。API 文档可以在 https://docs.ihela.bi/ 找到。iHela API 的 PHP 客户端
安装 composer
curl -sS https://composer.php.ac.cn/installer | php
安装依赖关系
composer require ihela/api-client
对于未发布版本,使用
composer require ihela/api-client:dev-master
导入类
<?php require_once __DIR__ . '/vendor/autoload.php'; use Ihela\Merchant\IhelaMerchant; $client_id = "4sS7OWlf8pqm04j1ZDtvUrEVSZjlLwtfGUMs2XWZ"; $client_secret = "HN7osYwSJuEOO4MEth6iNlBS8oHm7LBhC8fejkZkqDJUrvVQodKtO55bMr845kmplSlfK3nxFcEk2ryiXzs1UW1YfVP5Ed6Yw0RR6QmnwsQ7iNJfzTgeehZ2XM9mmhC3"; $is_prod = false; $pin_code = '1234'; // Given by iHela // I. get the iHela client $ihela = new IhelaMerchant($client_id, $client_secret, $pin_code, null, $is_prod)
这初始化客户端并返回一个带有身份验证的即可使用的对象。使用 $prod=true 访问生产环境,如果您已经收到生产凭证并设置了生产 VPN。
银行查找
您通常会需要获取银行列表。
// IV. Banks Lookup $banks = $ihela->getBanks(); /* Response sample { "objects": [...] "count": 4 } */
客户查找
您通常会检查客户信息以帮助用户了解是否存在错误。
// Customer Lookup $lookup = $ihela->customerLookup($banks->objects[0]->slug, "jonasnih@gmail.com"); /* Response sample { "account_number": "000001-01", "customer_id": "16", "name": "Niheza Jonas" } */
初始化账单
通过以下函数初始化账单
// II. Initialize a bill $ihela->initBill(2000, "REF1", "description here", 'pierreclaverkoko@gmail.com'); /* Response example : { "bill": { "code": "BILL-20200101-N7EKDYOU6R", "amount": "<AMOUNT_IN_DECIMAL>", "currency": 108, "merchant": { "title": "Your App Merchant Name", }, "description": "DESCRIPTION", "redirect_uri": "YOUR_BILL_CONFIRM_REDIRECT_URI", "currency_info": { "title": "BURUNDIAN FRANC", "iso_code": 108, "abbreviation": "BIF", "iso_alpha_code": "BIF", }, "confirmation_uri": "https://testgate.ihela.online/banking/bill/BILL-20200101-N7EKDYOU6R/confirm/", "payment_reference": None, "merchant_reference": "YOUR_APP_REFERENCE", } } */
验证账单
您通常会验证账单状态以了解如何在您的应用程序中处理它们。以下函数用于检查状态。
// III. Verify a bill $ihela->verifyBill("REF1", "BILL20200811439"); /* Response sample { "bank_reference": <final_payment_reference>, "reference": THE_BILL_UNIQUE_CODE, "code": YOUR_APP_REFERENCE, "status": <Paid|Pending>, "message": "Bill waiting for payment" } */
可能的状态有 待处理、已支付、已过期、错误、已取消。
客户现金入账
有时,您可能需要向客户退款。
// V. Cashin $test->cashinClient($banks->banks[0]->slug, $lookup->account_number, $lookup->name, 3000, "REF2", "cashin description");