athlan/yetipay
Composer 安装命令:
composer require athlan/yetipay
包简介
Yetipay.pl PHP library
关键字:
README 文档
README
This library allows to easy integration with yetipay payments.
Features
- Generated payment button
- Handles pingback (
URL_STATUS) - Verifies payments
Installation
Composer
Add dependency in composer.json file:
{
"require": {
"athlan/yetipay": "1.*"
}
}
Examples
Handle pingback (URL_STATUS)
<?php use Yetipay as Yetipay; $merchantId = ''; $authKey1 = ''; $authKey2 = ''; $yetipay = new Yetipay\Client($merchantId, $authKey1, $authKey2); $pingback = new Yetipay\TransactionPingback($yetipay); $params = $_POST; // or more proper way in frameworks, from Request object if($pingback->validateHash($params['hash'], $params)) { // activate product here die('ACK'); // yetipay expects "ACK" string in response to confirm transaction } die('FAILED');
Generate payment button
<?php use Yetipay as Yetipay; $merchantId = ''; $authKey1 = ''; $authKey2 = ''; $yetipay = new Yetipay\Client($merchantId, $authKey1, $authKey2); $amount = 5; $description = 'Test payment'; $button = new Yetipay\PaymentButton($amount, $description); $button->setUserId('userid_here'); $button->setProductId('productid_here'); $button->setReturnUrl('http://localhost/validate-transaction.php?transactionId=%transactionId%'); $buttonGenerator = new Yetipay\PaymentButtonCodeGenerator($yetipay); ?><html xmlns:yp="https://www.yetipay.pl"> <head> <script type="text/javascript" src="https://www.yetipay.pl/payments/js/316/yetixd.js"></script> </head> <body> <?php echo $buttonGenerator->getButtonCode($button) ?> </body> </html>
Validate payment
<?php use Yetipay as Yetipay; $merchantId = ''; $authKey1 = ''; $authKey2 = ''; $yetipay = new Yetipay\Client($merchantId, $authKey1, $authKey2); $pingback = new Yetipay\TransactionValidate($yetipay); $transactionId = $_GET['transactionId']; // or more proper way in frameworks, from Request object $data = $pingback->validateTransaction($transactionId); if($data['status'] == 200) { // activte product here }
统计信息
- 总下载量: 47
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2014-09-22