brightantwiboasiako/theteller-php-sdk
Composer 安装命令:
composer require brightantwiboasiako/theteller-php-sdk
包简介
PHP SDK for theteller payment system
README 文档
README
PHP SDK for theteller Payments API
Introduction
To use this sdk, you'll need an account from TheTeller. Create one here if you don't already have one. Also, this sdk follows TheTeller documentation https://www.theteller.net/documentation
Installation
This sdk can be installed using composer.
composer require omnilesolutions/theteller-php-sdk
Authentication
TheTeller uses basic HTTP authentication. You'll need your API username and key, which are available under My Account section of your TheTeller account dashboard.
TheTeller Checkout
To perform a checkout, you first need to get a payment token with an order payload.
// Get the teller instance. $teller = new TheTeller\TheTeller($username, $apiKey) // There is a third argument for mode which is LIVE by default. If you want to // use this sdk in test mode, instantiate the teller as // $teller = new TheTeller\TheTeller($username, $apiKey, TheTeller\TheTeller::THETELLER_MODE_TEST) // Create order payload $order = [ 'merchant_id' => 'YOUR-MERCHANT-ID', // available on TheTeller dashboard, under My Account. 'transaction_id' => 'A UNIQUE TRANSACTION ID', 'desc' => 'DESCRIPTION OF YOUR ORDER', 'amount' => '20', // Amount to charge the customer 'redirect_url' => 'YOUR REDIRECT URL', 'email' => 'EMAIL ADDRESS OF CUSTOMER' ]; // Process the checkout $checkout = $teller->requestPaymentToken($order); // If successful, the returned $checkout will be an instance of TheTeller\Checkout\Checkout // You now have to redirect the customer to TheTeller to make payment. // This will take the customer to TheTeller. $checkout->proceedToPayment(); // When the payment is completed by the customer, TheTeller will // redirect them back to your provided 'redirect_url' in the order // with query parameters indicating the status of the payment. // The response looks like this: // https://redirect_url?code=000&status=successful&reason=transaction20%successful&transaction_id=000000000000
TheTeller Funds Transfer
You can transfer funds from your Merchant Float Account which can be created from TheTeller dashboard. More information here.
Mobile Money Transfer
// Get the teller instance. $teller = new TheTeller\TheTeller($username, $apiKey); // There is a third argument for mode which is LIVE by default. If you want to // use this sdk in test mode, instantiate the teller as // $teller = new TheTeller\TheTeller($username, $apiKey, TheTeller\TheTeller::THETELLER_MODE_TEST) // Create transfer payload $payload = [ 'amount' => '20', // The transfer amount 'merchant_id' => 'YOUR-MERCHANT-ID', // available on TheTeller dashboard, under My Account. 'account_number' => '0240000000', // The mobile account number 'account_issuer' => 'MTN', // The mobile money network 'transaction_id' => 'A UNIQUE TRANSACTION ID', 'desc' => 'DESCRIPTION OF TRANSFER', 'pass_code' => 'UNIQUE FLOAT ACCOUNT PASSCODE' ] // Process the transfer try{ $teller->transfer('mobile-money', $payload); // Transfer is successful }catch(\Exception $e){ var_dump($e->getMessage()); // The reason for the failure }
Bank Transfer
// Get the teller instance. $teller = new TheTeller\TheTeller($username, $apiKey); // There is a third argument for mode which is LIVE by default. If you want to // use this sdk in test mode, instantiate the teller as // $teller = new TheTeller\TheTeller($username, $apiKey, TheTeller\TheTeller::THETELLER_MODE_TEST) // Create transfer payload $payload = [ 'amount' => '20', // The transfer amount 'merchant_id' => 'YOUR-MERCHANT-ID', // available on TheTeller dashboard, under My Account. 'account_bank' => 'GCB', // List of supported banks [here](https://theteller.net/documentation#theTeller_Standard) 'account_number' => '0082000141685300', // The bank account number 'transaction_id' => 'A UNIQUE TRANSACTION ID', 'desc' => 'DESCRIPTION OF TRANSFER', 'pass_code' => 'UNIQUE FLOAT ACCOUNT PASSCODE' ] // Process the transfer try{ // This step performs an enquiry of the bank account $transfer = $teller->transfer('bank', $payload); // Enquiry was successfull. // You can get the bank account name to ensure // that the transfer is going to the intended account. $name = $transfer->getAccountName(); // Complete the transfer $transfer->confirm($merchantId); // Your TheTeller Merchant ID }catch(\Exception $e){ var_dump($e->getMessage()); // The reason for the failure }
Get Transaction Status
// Get the teller instance. $teller = new TheTeller\TheTeller($username, $apiKey); // There is a third argument for mode which is LIVE by default. If you want to // use this sdk in test mode, instantiate the teller as // $teller = new TheTeller\TheTeller($username, $apiKey, TheTeller\TheTeller::THETELLER_MODE_TEST) // Get status try{ $response = $teller->getTransactionStatus($transactionId, $merchantId); }catch(\Exception $e){ var_dump($e->getMessage()); // The reason for the failure }
Prerequisites
Contributing
Contributions are welcome! Please do a PR with any bug-fixes or email me at brightantwiboasiako@aol.com for a long term commitment.
License
This open-source project is licensed under the MIT LICENSE
brightantwiboasiako/theteller-php-sdk 适用场景与选型建议
brightantwiboasiako/theteller-php-sdk 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 182 次下载、GitHub Stars 达 0, 最近一次更新时间为 2019 年 08 月 15 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 brightantwiboasiako/theteller-php-sdk 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 brightantwiboasiako/theteller-php-sdk 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 182
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-08-15