hngx/moneywave-php
Composer 安装命令:
composer require hngx/moneywave-php
包简介
PHP wrapper for the Moneywave API
README 文档
README
PHP wrapper for the Moneywave API Please consult the official documentation for more details.
Contents
- Configuration
- Usage: Dispatching Transactions/Resources
- Usage: Handling Responses
- Usage: Errors
- Installation
- Bugs
Configuration
To carry out a transaction or access a resource, you will need an instance of the moneywave client This will be used for your API calls.
$mw = new \HngX\Moneywave\Moneywave($yourApiKey, $yourSecretKey);
Usage: Dispatching Transactions/Resources
Performing Transactions
To perform a transaction, there are 3 simple steps:
-
Create the transaction. All transactions take the moneywave client instance as a constructor argument. The
WalletToAccountTransactionandBulkWalletToAccountTransactiontransactions also take a second parameter: the wallet password -
Set the appropriate details All the fields listed for each transaction in the docs are available as properties on the transaction class (via magic methods), so you can set them individually. Alternatively, you could use the
setDetails()function to set them in one go. Caution: be sure to use the exact parameter names (including capitalisation) as described at https://moneywave.flutterwave.com/api. The following fields are automatically set for you on each transaction:
| Field | Default |
|---|---|
| apiKey | the API key used when creating the Moneywave client |
| secret | the secret key used when creating the Moneywave client |
| currency | "NGN" |
| lock | (for WalletToAccountTransaction and BulkWalletToAccountTransaction) the wallet password supplied in the constructor |
- Dispatch the transaction by calling
dispatch()
Here is an example:
//we want to perform a wallet to account transfer $tran = new \HngX\Moneywave\Transactions\WalletToAccountTransaction($mw, $walletPassword); //set details $tran->amount = 25000; $tran->bankcode = \HngX\Moneywave\Bank::STERLING; $tran->accountNumber = "000056050"; $tran->senderName = "Johnson"; $tran->ref = 40; //then make the transaction $tran->dispatch(); //or you could do this in a batch $tran->setDetails(array( "amount" => 25000, "bankcode" => \HngX\Moneywave\Bank::STERLING, "accountNumber" => "000056050", "senderName" => "Johnson", "ref" => 40 ))->dispatch();
Available Transaction Types
AccountToAccountTransaction
CardToAccountTransaction
CardToWalletTransaction
TotalChargeToCardTransaction
WalletToAccountTransaction
BulkWalletToAccountTransaction
Available bank codes
Here is the list of banks currently supported by the Moneywave API. Their codes are available as constants in the \HngX\Moneywavw\Bank class:
FCMB // FIRST CITY MONUMENT BANK PLC
UNITY // UNITY BANK PLC
STANBIC_IBTC // STANBIC IBTC BANK PLC
STERLING // STERLING BANK PLC
STANBIC_MOBILE // STANBIC Mobile PLC
PAYCOM // PAYCOM
ECOBANK_MOBILE // ECOBANK MOBILE
FBN_MOBILE // FBN MOBILE
PARKWAY // PARKWAY
GTBANK_MOBILE // GTBank Mobile Money
ZENITH_MOBILE // ZENITH Mobile
ACCESS_MOBILE // ACCESS Mobile
ASO // Aso Savings and Loans
ACCESS // ACCESS BANK NIGERIA
AFRIBANK // AFRIBANK NIGERIA PLC
DIAMOND // DIAMOND BANK PLC
ECOBANK // ECOBANK NIGERIA PLC
ENTERPRISE // ENTERPRISE BANK LIMITED
FIDELITY // FIDELITY BANK PLC
FIRST // FIRST BANK PLC
GTBANK // GTBANK PLC
HERITAGE // HERITAGE BANK
KEYSTONE // KEYSTONE BANK PLC
SKYE // SKYE BANK PLC
STANDARD_CHARTERED // STANDARD CHARTERED BANK NIGERIA LIMITED
UNION // UNION BANK OF NIGERIA PLC
UBA // UNITED BANK FOR AFRICA PLC
WEMA // WEMA BANK PLC
ZENITH // ZENITH BANK PLC
Accessing a Resource
The same 3 steps apply:
-
Create the resource. All resources take the moneywave client instance as their only constructor argument.
-
Set the appropriate details, if any. The
GetWalletBalancedo not need any extra data All the fields listed for each resource in the docs are available as properties on the resource class (via magic methods), so you can set them individually. Alternatively, you could use thesetDetails()function to set them in one go. Caution: be sure to use the exact parameter names (including capitalisation) as described at https://moneywave.flutterwave.com/api. The following fields are automatically set for you on each resource:
| Field | Default |
|---|---|
| apiKey | the API key used when creating the Moneywave client |
| secret | the secret key used when creating the Moneywave client |
- Dispatch the resource by calling
dispatch().
Here is an example:
//we want to check our wallet balance $bal=new \HngX\Moneywave\Resources\GetWalletBalance($mw); $bal->dispatch();
Available Resource Types
GetWalletBalance
PreviousCardToAccount
PreviousWalletToAccount
RetryFailedTransaction
ValidateAccountNumber
TokenizeCard
Usage: Handling Responses
After dispatching a transaction or resource, you may access the full response by calling getResponse() on the object.
$tran->getResponse(); /* [ "status" => "success", "data" => [ ...] ] */
You can also find out the status alone by calling getStatus().
$tran->getStatus(); // -> "success" or "error"
You may also call successful() directly to test if the status of the response was success:
Caution: According to Moneywave, "success" does not neccessarily mean The transaction has gone through. Consult the official docs for more details
if ($tran->successful()) { //yay! } else { print_r($tran->getResponse()); }
Validating Transactions
According to the docs, the two transaction types AccountToAccountTransaction and CardToAccountTransaction may also need validation after being dispatched. To do that, simply call validate() on the transaction object with the appropriate data:
$tran = new \HngX\Moneywave\AccountToAccountTransaction($mw); $tran->setDetails([ "firstname" => "Donald", "lastname" => "Trump", ... ]) ->dispatch(); if ($tran->successful()){ $tran->validate([ "transactionRef" => $tran->getResponse()["data"]["ref"], "authType" => "OTP", "authValue" => "7489", ]); }
Note: after this, calling getResponse() or getStatus() will return the response or status for the validation process
Usage: Errors
You will get an instance of \HngX\MoneywaveException if you do anything naughty.
Installation
composer require hngx/moneywave-php
Bugs
If you notice any bugs, please create a new issue. We will attend to it promptly.
hngx/moneywave-php 适用场景与选型建议
hngx/moneywave-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 373 次下载、GitHub Stars 达 13, 最近一次更新时间为 2017 年 01 月 27 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「Moneywave」 「flutterwave」 「fintech」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 hngx/moneywave-php 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 hngx/moneywave-php 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 hngx/moneywave-php 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Sila PHP SDK for API Version 0.2
Laravel wrapper for the flutterwave-php library
Cliente PHP para la API de HeyBanco
Feature-based billing for Laravel with African payment provider support (M-Pesa, Paystack, Flutterwave, Pesapal). Plans, feature gating, usage metering, subscriptions, and invoicing.
Starling Bank Payments Service data objects
Modern Laravel package for Flutterwave v4 API integration
统计信息
- 总下载量: 373
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 13
- 点击次数: 10
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-01-27