|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * Created by PhpStorm. |
| 4 | + * User: jam |
| 5 | + * Date: 20.8.15 |
| 6 | + * Time: 11:16 |
| 7 | + */ |
| 8 | + |
| 9 | +namespace Trejjam\ThePay; |
| 10 | + |
| 11 | + |
| 12 | +use Nette, |
| 13 | + Tp, |
| 14 | + Trejjam; |
| 15 | + |
| 16 | +class PermanentPayment extends Tp\PermanentPayment |
| 17 | +{ |
| 18 | + /** |
| 19 | + * @var Nette\Application\LinkGenerator |
| 20 | + */ |
| 21 | + protected $linkGenerator; |
| 22 | + |
| 23 | + public function __construct(Tp\MerchantConfig $config, Nette\Application\LinkGenerator $linkGenerator) |
| 24 | + { |
| 25 | + parent::__construct($config, NULL, NULL, NULL); |
| 26 | + |
| 27 | + $this->linkGenerator = $linkGenerator; |
| 28 | + } |
| 29 | + |
| 30 | + public function getMerchantData() |
| 31 | + { |
| 32 | + if (is_null($this->merchantData)) { |
| 33 | + throw new PermanentPaymentException('Property merchantData was not set', PermanentPaymentException::UNDEFINED_PROPERTY); |
| 34 | + } |
| 35 | + |
| 36 | + return parent::getMerchantData(); |
| 37 | + } |
| 38 | + |
| 39 | + public function getDescription() |
| 40 | + { |
| 41 | + if (is_null($this->description)) { |
| 42 | + throw new PermanentPaymentException('Property description was not set', PermanentPaymentException::UNDEFINED_PROPERTY); |
| 43 | + } |
| 44 | + |
| 45 | + return parent::getDescription(); |
| 46 | + } |
| 47 | + |
| 48 | + public function getReturnUrl() |
| 49 | + { |
| 50 | + if (is_null($this->returnUrl)) { |
| 51 | + throw new PermanentPaymentException('Property returnUrl was not set', PermanentPaymentException::UNDEFINED_PROPERTY); |
| 52 | + } |
| 53 | + |
| 54 | + return parent::getReturnUrl(); |
| 55 | + } |
| 56 | + |
| 57 | + public function setReturnUrl($returnUrl, $params = []) |
| 58 | + { |
| 59 | + if (preg_match('~^([\w:]+):(\w*+)(#.*)?()\z~', $returnUrl)) { |
| 60 | + $returnUrl = $this->linkGenerator->link($returnUrl, $params); |
| 61 | + } |
| 62 | + |
| 63 | + parent::setReturnUrl($returnUrl); |
| 64 | + } |
| 65 | + |
| 66 | + public function getSignature() |
| 67 | + { |
| 68 | + $this->getMerchantData(); |
| 69 | + $this->getDescription(); |
| 70 | + $this->getReturnUrl(); |
| 71 | + |
| 72 | + return parent::getSignature(); |
| 73 | + } |
| 74 | + public function getSignatureLite() |
| 75 | + { |
| 76 | + $this->getMerchantData(); |
| 77 | + |
| 78 | + return parent::getSignatureLite(); |
| 79 | + } |
| 80 | +} |
0 commit comments