PHP code example of paysys / tatrapay

1. Go to this page and download the library: Download paysys/tatrapay library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

paysys / tatrapay example snippets


class OrderPresenter extends Presenter
{
	/** @var \PaySys\TatraPay\IButtonFactory @inject */
	public $tatraPayButtonFactory;

	/** @var \PaySys\TatraPay\Security\Request @inject */
	public $tatraPayRequest;

	protected function createComponentTatraPayButton()
	{
		$payment = new \PaySys\TatraPay\Payment("12.34", "00456", "John Doe");
		$button = $this->tatraPayButtonFactory->create($payment);
		$button->onPayRequest[] = function ($payment) {
			$this->redirectUrl($this->TatraPayRequest->getUrl($payment));
		};
		return $button;
	}
}


class OrderPresenter extends Presenter
{
	/** @var Nette\Http\IRequest @inject */
	public $httpRequest;

	/** @var \PaySys\TatraPay\Security\Response @inject */
	public $bankResponse;

	public function actionProcessTatraPay()
	{
		try {
			$this->bankResponse->paid($this->httpRequest->getQuery());
			// store info about payment
			$this->flashMessage('Thanks for payment.', 'success');
		} catch (\PaySys\PaySys\Exception $e) {
			// log
			$this->flashMessage('Payment failed. Please try it later.', 'danger');
		}
		$this->redirect('finish');
	}
}

class \PaySys\PaySys\Exception extends \Exception {}
class \PaySys\PaySys\SignatureException extends \PaySys\PaySys\Exception {}
class \PaySys\PaySys\ServerException extends \PaySys\PaySys\Exception {}
class \PaySys\PaySys\InvalidArgumentException extends \PaySys\PaySys\Exception {}
class \PaySys\PaySys\ConfigurationException extends \PaySys\PaySys\Exception {}