novotnyj / thepay-client
There is no license information available for the latest version (dev-master) of this package.
Client for thepay payment gate.
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-11-13 05:00:56 UTC
README
Unofficial client for ThePay payment gate.
Instalation
Add following to your config:
extensions: thepayClient: NovotnyJ\ThepayClient\DI\ThepayClientExtension thepayClient: merchantId: 1 accountId: 1 secret: 'xxx' apiKey: 'xxx' demo: false
Create payment
Create new payment:
$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);
Now redirect your customer to the payment gate on $url
.
Process payment response
$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()) { ... }
Available payment methods
To get available payment methods:
$methods = $this->thepayClient->getPaymentMethods();