Thepay Client
, (*1)
Unofficial client for ThePay payment gate., (*2)
Instalation
Add following to your config:, (*3)
extensions:
thepayClient: NovotnyJ\ThepayClient\DI\ThepayClientExtension
thepayClient:
merchantId: 1
accountId: 1
secret: 'xxx'
apiKey: 'xxx'
demo: false
Create payment
Create new payment:, (*4)
$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., (*5)
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:, (*6)
$methods = $this->thepayClient->getPaymentMethods();