lightools / payu
此包已被弃用且不再维护。没有建议的替代包。
简单的PayU在线支付客户端,启用自动确认。
dev-master
2016-06-15 10:37 UTC
Requires
- php: >=5.4
- bitbang/http: ~0.3.0
- lightools/xml: ~1.0.1
Requires (Dev)
- php: >=5.5
- mockery/mockery: ~0.9.4
- nette/tester: ~1.7.1
This package is auto-updated.
Last update: 2022-10-04 10:17:19 UTC
README
此库提供了通过PayU进行最简单在线支付的API,其中启用了自动支付确认。
安装
$ composer require lightools/payu
简单用法
// 1. redirect to payment gate $httpClient = new Bitbang\Http\Clients\CurlClient(); $xmlLoader = new Lightools\Xml\XmlLoader(); $payu = new Lightools\PayU\PayU($posId, $posAuthKey, $key1, $key2, $httpClient, $xmlLoader); $payment = new Lightools\PayU\NewPayment( $orderId, // your order identification $priceAmount, // in crowns (not in hellers) PayU::CHANNEL_TEST, $paymentDescription, $clientFirstname, $clientSurname, $clientEmail ); $ipAddress = $_SERVER['REMOTE_ADDR']; $redirectUrl = $payu->getRedirectUrl($payment, $ipAddress); header("Location: $redirectUrl"); exit(); // 2. accept payment update (on "UrlOnline") try { $post = filter_input_array(INPUT_POST); $status = $payu->getPaymentStatus($post); $status->getOrderId(); $status->getStatus(); // e.g. PaymentStatus::STATUS_PAID echo 'OK'; exit(); } catch (InvalidRequestException $ex) { // invalid request received (e.g. some data missing) } catch (InvalidSignatureException $ex) { // invalid signature in request or response } catch (RequestFailedException $ex) { // HTTP request to PayU failed }
如何运行测试
$ vendor/bin/tester tests