public function __construct(RequestInterface $request, $data)
 {
     parent::__construct($request, $data);
     $requestParams = $request->getParameters();
     $secureKey = $requestParams['secureKey'];
     $hashedSignature = GopayHelper::hash(GopayHelper::concatPaymentStatus($data, $secureKey));
     $decryptedHash = GopayHelper::decrypt($data->encryptedSignature, $secureKey);
     if ($decryptedHash != $hashedSignature) {
         throw new InvalidResponseException("Invalid response signature");
     }
 }
 public static function paymentStatusWithState($sessionState)
 {
     $data = new stdClass();
     $data->targetGoId = 12345;
     $data->productName = 'Product Description';
     $data->totalPrice = 1000;
     $data->currency = 'CZK';
     $data->orderNumber = '1234';
     $data->recurrentPayment = '';
     $data->parentPaymentSessionId = '';
     $data->preAuthorization = '';
     $data->result = GopayHelper::CALL_COMPLETED;
     $data->sessionState = $sessionState;
     $data->sessionSubState = '';
     $data->paymentChannel = '';
     $data->paymentSessionId = 11112222;
     $data->encryptedSignature = GopayHelper::encrypt(GopayHelper::hash(GopayHelper::concatPaymentStatus($data, self::SECURE_KEY)), self::SECURE_KEY);
     return $data;
 }
 /**
  * Kontrola parametru predavanych ve zpetnem volani po potvrzeni/zruseni platby - verifikace podpisu.
  *
  * @param float $returnedPaymentSessionId - paymentSessionId vracene v redirectu
  * @param string $returnedEncryptedSignature - kontrolni podpis vraceny v redirectu
  * @param float $paymentResult - vysledek volani
  * @param float $paymentSessionId - identifikator platby na GoPay
  * @param string $secureKey - kryptovaci klic prideleny eshopu / uzivateli, urceny k podepisovani komunikace
  *
  * @throws Exception
  */
 public static function checkPaymentResult($returnedPaymentSessionId, $returnedEncryptedSignature, $paymentResult, $paymentSessionId, $secureKey)
 {
     if ($returnedPaymentSessionId != $paymentSessionId) {
         throw new Exception("PaymentResult invalid PSID");
     }
     $hashedSignature = GopayHelper::hash(GopayHelper::concatPaymentResult((double) $paymentSessionId, $paymentResult, $secureKey));
     $decryptedHash = GopayHelper::decrypt($returnedEncryptedSignature, $secureKey);
     if ($decryptedHash != $hashedSignature) {
         throw new Exception("PaymentResult invalid signature");
     }
 }
 /**
  * Založení opakovane platby
  *
  * @param float $parentPaymentSessionId - identifikator rodicovske platby
  * @param int $recurrentPaymentOrderNumber - identifikator objednavky
  * @param int $recurrentPaymentTotalPriceInCents - castka
  * @param string $recurrentPaymentCurrency - mena (CZK)
  * @param string $recurrentPaymentProductName - popis objednavky
  * @param float $targetGoId - identifikator prijemnce - GoId
  * @param string $secureKey - kryptovaci klic prideleny GoPay
  * @throws \Exception
  * @return
  */
 public function performRecurrence($parentPaymentSessionId, $recurrentPaymentOrderNumber, $recurrentPaymentTotalPriceInCents, $recurrentPaymentCurrency, $recurrentPaymentProductName, $targetGoId, $secureKey)
 {
     try {
         //inicializace WS
         $go_client = self::createSoapClient();
         $encryptedSignature = GopayHelper::encrypt(GopayHelper::hash(GopayHelper::concatRecurrenceRequest((double) $parentPaymentSessionId, (int) $recurrentPaymentOrderNumber, (int) $recurrentPaymentTotalPriceInCents, (double) $targetGoId, $secureKey)), $secureKey);
         $recurrenceRequest = array("parentPaymentSessionId" => (double) $parentPaymentSessionId, "orderNumber" => (int) $recurrentPaymentOrderNumber, "totalPrice" => (int) $recurrentPaymentTotalPriceInCents, "targetGoId" => (double) $targetGoId, "encryptedSignature" => $encryptedSignature);
         $status = $go_client->__call('createRecurrentPayment', array('recurrenceRequest' => $recurrenceRequest));
         if ($status->result == GopayHelper::CALL_COMPLETED) {
             GopayHelper::checkPaymentStatus($status, GopayHelper::CREATED, (double) $targetGoId, (int) $recurrentPaymentOrderNumber, (int) $recurrentPaymentTotalPriceInCents, $recurrentPaymentCurrency, $recurrentPaymentProductName, $secureKey);
             return $status->paymentSessionId;
         } else {
             throw new Exception("Bad payment status");
         }
     } catch (SoapFault $f) {
         /*
          * Chyba v komunikaci s GoPay serverem
          */
         throw new Exception("SOAP error");
     }
 }