hngx/moneywave-php 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

hngx/moneywave-php

Composer 安装命令:

composer require hngx/moneywave-php

包简介

PHP wrapper for the Moneywave API

README 文档

README

Latest Stable Version Total Downloads License Latest Unstable Version

PHP wrapper for the Moneywave API Please consult the official documentation for more details.

Contents

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:

  1. Create the transaction. All transactions take the moneywave client instance as a constructor argument. The WalletToAccountTransaction and BulkWalletToAccountTransaction transactions also take a second parameter: the wallet password

  2. 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
  1. 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:

  1. Create the resource. All resources take the moneywave client instance as their only constructor argument.

  2. Set the appropriate details, if any. The GetWalletBalance do 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 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 resource:

Field Default
apiKey the API key used when creating the Moneywave client
secret the secret key used when creating the Moneywave client
  1. 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 我们能提供哪些服务?
定制开发 / 二次开发

基于 hngx/moneywave-php 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 373
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 13
  • 点击次数: 10
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 13
  • Watchers: 2
  • Forks: 8
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-01-27