yo-uganda-muokid3/yopaymentsphp

一个用于与Yo! Payments API交互的PHP库。

v1.0.2 2021-04-30 13:05 UTC

This package is not auto-updated.

Last update: 2024-09-29 05:49:07 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

然后,您只需通过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编程语言

作者

许可证

本项目采用MIT许可证 - 请参阅LICENSE.md文件以获取详细信息

致谢

  • Gerald Begumisa
  • Grace Kyeyune
  • Joseph Tabajjwa