承接 jilenloa/tppmyone4all-php 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

jilenloa/tppmyone4all-php

Composer 安装命令:

composer require jilenloa/tppmyone4all-php

包简介

PHP Library to integration myone4all tpp service easily

README 文档

README

Latest Version Build Status Total Downloads

This library makes it easy for PHP developers to integrate with One4All TPP online service.

It's supported on PHP 5.5+

Using the Library

use MyOne4All\TppClient;
use MyOne4All\Exceptions\TppException;
use MyOne4All\Models\DataBundle;
use MyOne4All\NetworkCodes;

$tppClient = new TppClient("apikey", "apisecret", "retailer");

Get Balance

# ecredit balance
echo $tppClient->getBalance(); # 0.0

# mobile money collection balance
echo $tppClient->getBalance(TppClient::WALLET_TYPE_MOBILE_MONEY_COLLECTION); # 0.0

# mobile money credit balance
echo $tppClient->getBalance(TppClient::WALLET_TYPE_MOBILE_MONEY_CREDIT); # 0.0

Send Airtime

// send airtime implementation
$airtime_response = $tppClient->sendAirtime("0245667942", 1, "trans03423423", NetworkCodes::AUTO_DETECT);
if($airtime_response->isSuccessful()){
    echo "airtime sent";
}else{
    echo "Failed: ".$airtime_response->getErrorMessage();
}

Send Data Bundle

// send internet data implementation
$data_code = "DAILY_20MB";
$transaction_reference = "trans03423423";
$bundle_response = $tppClient->sendDataBundle("0245667942", $data_code, $transaction_reference, NetworkCodes::MTN_GH);
if($bundle_response->isSuccessful()){
    echo "internet bundle sent";
}else{
    echo "Failed: ".$bundle_response->getErrorMessage();
}

Send Flexi Data Bundle

// send internet data implementation
$data_code = "flexi_data_bundle";
$transaction_reference = "trans03423423";
$amount = 10;
$bundle_response = $tppClient->sendFlexiDataBundle("0245667942", $amount, $data_code, $transaction_reference, NetworkCodes::MTN_GH);
if($bundle_response->isSuccessful()){
    echo "internet bundle sent";
}else{
    echo "Failed: ".$bundle_response->getErrorMessage();
}

Send Mobile Money

// send mobile money implementation
$transaction_reference = "trans03423423";
$amount = 1;
$momo_response = $tppClient->sendMobileMoney("0245667942", $amount, $transaction_reference);
if($momo_response->isSuccessful()){
    echo "mobile money sent";
}else if($momo_response->isPending()){
    // this is very important, do not treat as an error.
    // you must check transaction status later to know if it was successful or not
    echo "mobile money request is being processed.";
}else{
    echo "Failed: ".$momo_response->getErrorMessage();
}

Receive Mobile Money

// receive mobile money implementation
$transaction_reference = "trans03423423";
$amount = 1;
$payer_number = "0245667XXX";
$momo_response = $tppClient->receiveMobileMoney($payer_number, $amount, $transaction_reference);
if($momo_response->isSuccessful()){
    // check transaction status later to confirm receipt
    echo "mobile money payment request initiated";
}else{
    echo "Failed: ".$momo_response->getErrorMessage();
}

Receive Mobile Money on USSD

When working with USSD sessions, it is important there is a delay between the closing of the current session and the payment prompt. Use the delay parameter to specify the number of seconds to delay the payment prompt after the current USSD session ends.

// receive mobile money implementation
$transaction_reference = "trans03423423";
$amount = 1;
$payer_number = "0245667XXX";
$narration = "Food Purchase";
$delay = 5;
// the last parameter represents the number of seconds to delay the payment prompt
$momo_response = $tppClient->receiveMobileMoney($payer_number, $amount, $transaction_reference, $delay, $narration);
if($momo_response->isSuccessful()){
    // check transaction status later to confirm receipt
    echo "mobile money payment request initiated";
}else{
    echo "Failed: ".$momo_response->getErrorMessage();
}

Send SMS

$sms_message = "hello world";
$sms_sender_id = "One4All";
$transaction_reference = "sms11";
$sms_response = $tppClient->sendSms("0572180376", $sms_message, $sms_sender_id, $transaction_reference);
if($sms_response->isSuccessful()){
    echo "sms message queued";
}else{
    echo "Failed: ".$sms_response->getErrorMessage();
}

Query Bundle List

We recommend you cache this list for at least 24 hours to avoid unnecessary API calls.

echo NetworkCodes::AUTO_DETECT; # 0
echo NetworkCodes::MTN_GH; # 4
echo NetworkCodes::AIRTEL_DRC; # 2

// fetch available data packages for all networks
$data_packages = $tppClient->getDataBundleList();

// only fetch data packages for mtn
$data_packages = $tppClient->getDataBundleList(NetworkCodes::MTN_GH);

foreach($data_pages as $data_package){
    echo $data_package->plan_id; # DAILY_20MB
    echo $data_package->plan_name; # DAILY_20MB
    echo $data_package->category; # DAILY
    echo $data_package->network_id; # 4
    echo $data_package->volume; # 20 MB
}

Query Transaction Status

$transaction_reference = "trans03423423";
$transaction_status = $tppClient->getTransactionStatus($transaction_reference);
if($transaction_status == TppClient::TRANSACTION_STATUS_COMPLETED){
    echo "transaction successful";
}

Install package using Composer

composer require jilenloa/tppmyone4all-php

After installing, you need to require Composer's autoloader:

require 'vendor/autoload.php';

You can then later update the package later using composer:

composer update

In order to run unit tests for this package

npm install -g mockserver

jilenloa/tppmyone4all-php 适用场景与选型建议

jilenloa/tppmyone4all-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 419 次下载、GitHub Stars 达 0, 最近一次更新时间为 2019 年 10 月 28 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 jilenloa/tppmyone4all-php 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 jilenloa/tppmyone4all-php 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 419
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-10-28