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

This package is not auto-updated.

Last update: 2024-11-13 05:00:56 UTC


README

CircleCI

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();