tpweb / targetpay
PHP TargetPay 库
Requires
- php: >=5.6
Requires (Dev)
- phpunit/phpunit: 5.*|6.*|7.*
This package is auto-updated.
Last update: 2024-09-06 05:52:38 UTC
README
安装
在您的 composer.json
中要求此包并更新 composer。
"tpweb/targetpay": "1.*"
更新 composer 后,将 ServiceProvider 添加到 config/app.php
中的 providers 数组
TPWeb\TargetPay\TargetPayServiceProvider::class,
您可以使用外观来缩短代码。将以下内容添加到您的别名中
'TargetPay' => TPWeb\TargetPay\TargetPayFacade::class,
在 Laravel 5 中使用以下命令发布配置设置
php artisan vendor:publish --provider="TPWeb\TargetPay\TargetPayServiceProvider"
这将在您的配置文件夹中添加一个 targetpay.php
配置文件。在您的 .env 文件中,您可以使用
TARGETPAY_LAYOUTCODE=xxxxx TARGETPAY_KLANTCODE=xxxxx TARGETPAY_TEST=false TARGETPAY_DEBUG=true
(LAYOUTCODE 指的是您的 'outlet code',它是每个网店/网站唯一的,KLANTCODE 指的是您的 API 密钥,它是每个 TP 账户唯一的。)
文档
IVR 090X- (按通话付费 & 按分钟付费)
获取支付信息
$targetPay = new TargetPay(new \TPWeb\TargetPay\Transaction\IVR); //$targetPay->transaction->setCountry(32); $targetPay->transaction->setCountry(\TPWeb\TargetPay\Transaction\IVR::BELGIUM); $targetPay->setAmount(3.00); $targetPay->getPaymentInfo(); //Fetch payment info echo $targetPay->transaction->getCurrency(); //Currency: EURO, GBP, ... echo $targetPay->getAmount(); //Real payed amount.: 3.00 echo $targetPay->transaction->getServiceNumber(); //Number to call echo $targetPay->transaction->getPayCode(); //Code to enter during call echo $targetPay->transaction->getMode(); //Call type: PC or PM echo ($targetPay->transaction->getMode() == "PM" ? $targetPay->transaction->getDuration() . "s" : ""); //duration in seconds
检查支付
(这将只会给您一次成功的回调!)
$targetPay = new TargetPay(new \TPWeb\TargetPay\Transaction\IVR); $targetPay->transaction->setCountry($request->get('country')); $targetPay->setAmount($request->get('amount')); $targetPay->transaction->setServiceNumber($request->get('servicenumber')); $targetPay->transaction->setPayCode($request->get('paycode')); $targetPay->checkPaymentInfo(); if($targetPay->transaction->getPaymentDone()) { //Payment done echo $targetPay->getAmount(); //Real payed amount echo targetPay->transaction->getPayout(); //amount you 'll receive. } else { //payment not completed }
IDEAL
获取支付信息和 URL
保存 $transactionId,将用户重定向到 $redirectUrl。
$targetPay = new TargetPay(new \TPWeb\TargetPay\Transaction\IDeal); $targetPay->transaction->setBank(IDeal::ING); $targetPay->setAmount(10.00); $targetPay->transaction->setDescription("Description"); $targetPay->transaction->setReturnUrl("https://www.example.com"); $targetPay->getPaymentInfo(); $redirectUrl = $targetPay->transaction->getIdealUrl(); $transactionId = $targetPay->transaction->getTransactionId();
检查支付
$targetPay = new TargetPay(new \TPWeb\TargetPay\Transaction\IDeal); $targetPay->transaction->setTransactionId($transactionId); $targetPay->checkPaymentInfo(); $once = false; $targetPay->transaction->getPaymentDone($once);
Mister Cash
获取支付信息和 URL
保存 $transactionId,将用户重定向到 $redirectUrl。
$targetPay = new TargetPay(new \TPWeb\TargetPay\Transaction\MisterCash); $targetPay->transaction->setLang("NL"); $targetPay->setAmount(10.00); $targetPay->transaction->setDescription("Description"); $targetPay->transaction->setReturnUrl("https://www.example.com"); $targetPay->getPaymentInfo(); $redirectUrl = $targetPay->transaction->getMisterCashUrl(); $transactionId = $targetPay->transaction->getTransactionId();
检查支付
$targetPay = new TargetPay(new \TPWeb\TargetPay\Transaction\MisterCash); $targetPay->transaction->setTransactionId($transactionId); $targetPay->checkPaymentInfo(); $once = false; $targetPay->transaction->getPaymentDone($once);
Paysafecard
获取支付信息和 URL
保存 $transactionId,将用户重定向到 $redirectUrl。
$targetPay = new TargetPay(new \TPWeb\TargetPay\Transaction\Paysafecard); $targetPay->setAmount(10.00); $targetPay->transaction->setDescription("Description"); $targetPay->transaction->setReturnUrl("https://www.example.com"); $targetPay->getPaymentInfo(); $redirectUrl = $targetPay->transaction->getPaysafecardUrl(); $transactionId = $targetPay->transaction->getTransactionId(); //redirect to $redirectUrl
检查支付
$targetPay = new TargetPay(new \TPWeb\TargetPay\Transaction\Paysafecard); $targetPay->transaction->setTransactionId($transactionId); $targetPay->checkPaymentInfo(); $once = false; $targetPay->transaction->getPaymentDone($once);
高级短信
获取支付信息和 URL
保存 $transactionId,将用户重定向到 $redirectUrl。
$targetPay = new TargetPay(new \TPWeb\TargetPay\Transaction\SMS); $targetPay->transaction->setCountry(SMS::BELGIUM); $targetPay->setAmount(1.00); $shortcode = $targetPay->transaction->getShortcode(); $keyword = $targetPay->transaction->getKeyword(); //User send keyword to shortcode, user get answer with code
检查支付
$targetPay = new TargetPay(new \TPWeb\TargetPay\Transaction\SMS); $targetPay->transaction->setCountry(SMS::BELGIUM); $targetPay->setAmount(1.00); $targetPay->transaction->setPayCode($code); $targetPay->checkPaymentInfo(); $targetPay->transaction->getPaymentDone();
完整的文档可以在以下位置找到:http://www.tpweb.org/my-projects/php-targetpay-library/
支持
支持 github 或邮件: tjebbe.lievens@madeit.be
贡献
请尽量遵循 psr-2 编码风格指南。 http://www.php-fig.org/psr/psr-2/
许可
此包受 LGPL 许可。您可以在个人和商业项目中免费使用它。代码可以被分叉和修改,但必须始终包含原始版权作者!