novotnyj / thepay-client
关于该软件包最新版本(dev-master)没有提供许可证信息。
thepay支付网关的客户端。
dev-master
2017-02-06 21:58 UTC
Requires
- php: >7.0
- guzzlehttp/guzzle: ^6.2
- nette/utils: ~2.4
Requires (Dev)
- nette/di: ^2.4
- nette/tester: ^1.7
- phpstan/phpstan: ^0.6.3
Suggests
- nette/di: To use class ThepayClientExtension
This package is not auto-updated.
Last update: 2024-09-18 04:18:27 UTC
README
ThePay支付网关的非官方客户端。
安装
将以下内容添加到您的配置文件中
extensions: thepayClient: NovotnyJ\ThepayClient\DI\ThepayClientExtension thepayClient: merchantId: 1 accountId: 1 secret: 'xxx' apiKey: 'xxx' demo: false
创建支付
创建新的支付
$payment = new PaymentRequest($method->getId(), 10.00, 'http://my-super-eshop.com/thepay'); $payment->setMerchantData('test data'); $payment->setDescription('test description'); $payment->setBackToEshopUrl('http://my-super-shop.com/'); $url = $this->thepayClient->getPaymentUrl($payment);
现在将客户重定向到支付网关 $url
。
处理支付响应
$get = $this->getParameters(); $response = new PaymentResponse($get); if ($response->isPaid()) { ... } if ($response->isUnderPaid()) { $paymentInfo = $this->thepayClient->getPaymentInfo($response->getPaymentId()); $paid = $paymentInfo->getReceivedValue(); } if ($response->isCancelled()) { ... } if ($response->isError()) { ... }
可用的支付方式
获取可用的支付方式
$methods = $this->thepayClient->getPaymentMethods();