flutterwavedev/flutterwave-v3
Composer 安装命令:
composer require flutterwavedev/flutterwave-v3
包简介
A simple SDK for integrating to Flutterwave Payment
README 文档
README
Flutterwave v3 PHP SDK.
This Flutterwave v3 PHP Library provides easy access to Flutterwave for Business (F4B) v3 APIs from php apps. It abstracts the complexity involved in direct integration and allows you to make quick calls to the APIs.
Available features include:
- Collections: Card, Account, Mobile money, Bank Transfers, USSD, Barter, NQR.
- Payouts and Beneficiaries.
- Recurring payments: Tokenization and Subscriptions.
- Split payments
- Card issuing
- Transactions dispute management: Refunds.
- Transaction reporting: Collections, Payouts, Settlements, and Refunds.
- Bill payments: Airtime, Data bundle, Cable, Power, Toll, E-bills, and Remitta.
- Identity verification: Resolve bank account, resolve BVN information.
Table of Contents
- Requirements
- Installation
- Initialization
- Usage
- Testing
- Debugging Errors
- Support
- Contribution guidelines
- License
- Changelog
Requirements
- Flutterwave for business API Keys
- Acceptable PHP versions: >= 7.4.0. for older versions of PHP use the Legacy Branch
Installation
Download Release Artifact
If you do not want to make use of composer. each release contains a zip with all the dependencies installed. Simply download the one that supports your php version.
Installation via Composer.
To install the package via Composer, run the following command:
composer require flutterwavedev/flutterwave-v3
Initialization
Create a .env file and follow the format of the .env.example file
Save your PUBLIC_KEY, SECRET_KEY, ENV in the .env file
cp .env.example .env
Your .env file should look this. Make sure to retrieve your API keys from your dashboard.
FLW_PUBLIC_KEY=FLWSECK_TEST-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX-X FLW_SECRET_KEY=FLWPUBK_TEST-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX-X FLW_ENCRYPTION_KEY=FLWSECK_XXXXXXXXXXXXXXXX FLW_ENV='staging/production' FLW_LOG_DIR=logs
Render Payment Modal
The SDK provides two easy methods of making collections via the famous payment modal. Learn more
Get Started
Edit the paymentForm.php and processPayment.php files to suit your purpose. Both files are well documented.
Simply redirect to the paymentForm.php file on your browser to process a payment.
In this implementation, we are expecting a form encoded POST request to this script. The request will contain the following parameters.
{
"amount": "The amount required to be charged. (*)",
"currency": "The currency to charge in. (*)",
"first_name": "The first name of the customer. (*)",
"last_name" : "The last name of the customer. (*)",
"email": "The customers email address. (*)",
"phone_number": "The customer's phone number. (Optional).",
"success_url": "The url to redirect customer to after successful payment.",
"failure_url": "The url to redirect customer to after a failed payment.",
"tx_ref":"The unique transaction identifier. if ommited the apiclient would generate one"
}
The script in paymentProcess.php handles the request data via the PaymentController. If you are using a Framework like Laravel or CodeIgniter you might want to take a look at the PaymentController
<?php declare(strict_types=1); # if vendor file is not present, notify developer to run composer install. require __DIR__.'/vendor/autoload.php'; use Flutterwave\Controller\PaymentController; use Flutterwave\EventHandlers\ModalEventHandler as PaymentHandler; use Flutterwave\Flutterwave; use Flutterwave\Library\Modal; # start a session. session_start(); try { Flutterwave::bootstrap(); $customHandler = new PaymentHandler(); $client = new Flutterwave(); $modalType = Modal::POPUP; // Modal::POPUP or Modal::STANDARD $controller = new PaymentController( $client, $customHandler, $modalType ); } catch(\Exception $e ) { echo $e->getMessage(); } if ($_SERVER["REQUEST_METHOD"] === "POST") { $request = $_REQUEST; $request['redirect_url'] = $_SERVER['HTTP_ORIGIN'] . $_SERVER['REQUEST_URI']; try { $controller->process( $request ); } catch(\Exception $e) { echo $e->getMessage(); } } $request = $_GET; # Confirming Payment. if(isset($request['tx_ref'])) { $controller->callback( $request ); } else { } exit();
Configuration settings
Create a .env file and add the bootstrap method first before initiating a charge.
use \Flutterwave\Flutterwave; # normal configuration Flutterwave::bootstrap(); # this will use the default configuration set in .env
if you do not wish to use a .env, you can simply pass your API keys like the example below.
use \Flutterwave\Helper\Config; $myConfig = Config::setUp( 'FLWSECK_TEST-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX-X', 'FLWPUBK_TEST-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX-X', 'FLWSECK_XXXXXXXXXXXXXXXX', 'staging' ); Flutterwave::bootstrap($myConfig);
Usage
Charge
- Account Charge
- ACH Charge
- Card Charge
- Mobile Money
- FawryPay
- GooglePay
- ApplePay
- Mpesa
- BankTransfer
- USSD
- eNaira
Resources
- Banks
- Beneficiaries
- Payment Plans
- Collection Subaccounts
- Payout Subaccounts
- Subscriptions
- Transfers
- Transactions
- Virtual Cards
- Virtual Account
- Misc
Testing
All of the SDK's tests are written with PHP's phpunit module. The tests currently test:
Account,
Card,
Transfer,
Preauth,
Collection Subaccount,
Payout Subaccount,
Subscriptions and
Paymentplan
They can be run like so:
phpunit
NOTE: If the test fails for creating a subaccount, just change the
account_numberaccount_bankandbusinesss_emailto something different
NOTE: The test may fail for account validation -
Pending OTP validationdepending on whether the service is down or not
Debugging Errors
We understand that you may run into some errors while integrating our library. You can read more about our error messages here.
For authorization and validation error responses, double-check your API keys and request. If you get a server error, kindly engage the team for support.
Support
For additional assistance using this library, contact the developer experience (DX) team via email or on slack.
You can also follow us @FlutterwaveEng and let us know what you think 😊.
Contribution guidelines
Read more about our community contribution guidelines here
License
By contributing to this library, you agree that your contributions will be licensed under its MIT license.
Copyright (c) Flutterwave Inc.
Flutterwave API References
flutterwavedev/flutterwave-v3 适用场景与选型建议
flutterwavedev/flutterwave-v3 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 203.95k 次下载、GitHub Stars 达 24, 最近一次更新时间为 2020 年 09 月 17 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「payment」 「transfers」 「africa」 「flutterwave」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 flutterwavedev/flutterwave-v3 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 flutterwavedev/flutterwave-v3 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 flutterwavedev/flutterwave-v3 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Firefly III Data Import Tool.
A Flutterwave's Version 3 Implementation For Laravel
A Flutterwave's Version 3 Implementation For Laravel
Validation rules and an Eloquent Model attribute cast to value object encapsulating a South African government-issued personal identification number, for Laravel.
Feature-based billing for Laravel with African payment provider support (M-Pesa, Paystack, Flutterwave, Pesapal). Plans, feature gating, usage metering, subscriptions, and invoicing.
Modern Laravel package for Flutterwave v4 API integration
统计信息
- 总下载量: 203.95k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 24
- 点击次数: 25
- 依赖项目数: 4
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-09-17