batons0/yopaymentsphp

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

1.0.2 2022-02-18 12:06 UTC

This package is auto-updated.

Last update: 2024-09-18 18:06:32 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文件中

"batons0/yopaymentsphp": "^1.0" 

或者

composer require batons0/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