yo-uganda / yopaymentsphp
一个用于与Yo! Payments API交互的PHP库。
Requires
- php: ^5.3.3 || ^7.0
This package is auto-updated.
Last update: 2024-09-13 15:24:44 UTC
README
Yo! Payments是一种革命性的移动支付网关服务。Yo! Payments允许企业通过移动货币从其客户那里接收付款,以及向任何移动货币账户持有人进行移动货币付款。Yo! Payments还具有将移动通话信用(“话费”)直接发送给用户的能力。
Yo! Payments API PHP库是一个PHP库,可以包含在您的PHP项目中,以实现与网站和Web系统的无缝集成。
入门指南
先决条件
要使用API,您必须首先拥有Yo! Payments企业账户。API不适用于个人账户。
- Yo! Payments API用户名
- Yo! Payments API密码
$yoAPI = new YoAPI($username, $password);
安装
Yo! Payments API PHP库可以通过Composer/Packagist(使用语义版本)获取,因此只需将此行添加到您的composer.json
文件中
"yo-uganda/yopaymentsphp": "^1.0"
或
composer require yo-uganda/yopaymentsphp
然后在您的PHP脚本中添加以下行
require 'vendor/autoload.php';
就这样!Yo! Payments PHP API现在可用于使用。
或者,将YoPaymentsPHP文件夹的内容复制到您的PHP配置中指定的一个include_path
目录。
如果您不使用git,请点击GitHub页面顶部的'zip'按钮。
最小安装
虽然手动或使用Composer安装整个包很简单、方便且可靠,但您可能只想在项目中包含必要文件。至少您需要YoAPI.php。如果您正在执行即时支付通知,则还需要Yo_Uganda_Public_Certificate.crt(生产环境)和Yo_Uganda_Public_Sandbox_Certificate.crt(沙箱环境)。
然后只需通过require '/path/to/YoAPI.php';
加载库,一切应该都能正常工作。
一个简单的例子
启动移动货币用户提示输入PIN以转账资金
$yoAPI = new YoAPI($username, $password);
$yoAPI->set_nonblocking("TRUE");
$response = $yoAPI->ac_deposit_funds('256770000000', 10000, 'Reason for transfer of funds');
if($response['Status']=='OK'){
// Transaction was successful and funds were deposited onto your account
echo "Transaction Reference = ".$response['TransactionReference'];
}
当付款完成时接收付款通知。
$yoAPI = new YoAPI($username, $password);
if(isset($_POST)){
$response = $yoAPI->receive_payment_notification();
if($response['is_verified']){
// Notification is from Yo! Uganda Limited
echo "Payment from ".$response['msisdn']." on ".$response['date_time']." for ".$response['narrative']." with an amount of ".$response['amount'].". Mobile Network Reference = ".$response['network_ref']." and external reference of ".$response['external_ref'];
}
}
当付款失败时接收通知。
$yoAPI = new YoAPI($username, $password);
if(isset($_POST)){
$response = $yoAPI->receive_payment_failure_notification();
if($response['is_verified']){
// Notification is from Yo! Uganda Limited
echo "Payment on ".$response['transaction_init_date']." with a FAILED transaction status ".$response['failed_transaction_reference']." closed.";
}
}
您可以在示例文件夹中找到更多要玩的内容。
这就对了!现在您应该准备好使用YoAPI了。
使用的技术
- PHP - PHP编程语言
作者
- Aziz Kirumira - 初始工作 - Yo (U) Ltd
许可
本项目的许可协议为MIT许可 - 有关详细信息,请参阅LICENSE.md文件
鸣谢
- Gerald Begumisa
- Grace Kyeyune
- Joseph Tabajjwa