/**
  * Gets the redirect target url.
  */
 public function getRedirectUrl()
 {
     /** @noinspection PhpUndefinedMethodInspection */
     $url = $this->getRequest()->getTestMode() ? GopayConfig::TEST_FULL_URL : GopayConfig::PROD_FULL_URL;
     /** @noinspection PhpUndefinedMethodInspection */
     $goId = $this->getRequest()->getGoId();
     $paymentSessionId = $this->getData()->paymentSessionId;
     /** @noinspection PhpUndefinedMethodInspection */
     $secureKey = $this->getRequest()->getSecureKey();
     return $url . '?' . http_build_query(array('sessionInfo.targetGoId' => $goId, 'sessionInfo.paymentSessionId' => $paymentSessionId, 'sessionInfo.encryptedSignature' => GopayHelper::getPaymentSessionSignature($goId, $paymentSessionId, $secureKey)));
 }
 public function testSendSuccess()
 {
     $notificationParams = array('targetGoId' => 12345, 'paymentSessionId' => 1111, 'orderNumber' => 2222, 'encryptedSignature' => GopayHelper::getPaymentIdentitySignature(12345, 1111, null, 2222, GatewayTest::SECURE_KEY));
     $paymentStatusParams = array('targetGoId' => 12345, 'paymentSessionId' => 1111, 'encryptedSignature' => GopayHelper::getPaymentSessionSignature(12345, 1111, GatewayTest::SECURE_KEY));
     $paymentStatusResponse = PaymentStatusResponseTest::paymentStatusWithState(GopayHelper::CREATED);
     $this->getHttpRequest()->query->replace($notificationParams);
     $this->soapClient->expects($this->once())->method('paymentStatus')->with($paymentStatusParams)->will($this->returnValue($paymentStatusResponse));
     $this->request = new CompletePurchaseRequest($this->soapClient, $this->getHttpClient(), $this->getHttpRequest());
     $this->request->setGoId('12345');
     $this->request->setSecureKey(GatewayTest::SECURE_KEY);
     $response = $this->request->send();
     $this->assertSame($paymentStatusResponse, $response->getData());
 }
 /**
  * Send the request with specified data
  *
  * @param  mixed $data The data to send
  * @return ResponseInterface
  */
 public function sendData($data)
 {
     $paymentSession = array("targetGoId" => (double) $this->getGoId(), "paymentSessionId" => (double) $data['paymentSessionId'], "encryptedSignature" => GopayHelper::getPaymentSessionSignature($this->getGoId(), $data['paymentSessionId'], $this->getSecureKey()));
     $paymentStatus = $this->soapClient->paymentStatus($paymentSession);
     return new PaymentStatusResponse($this, $paymentStatus);
 }
 /**
  * Dokončení platby
  *
  * @param float $paymentSessionId - identifikator platby
  * @param float $targetGoId - identifikator prijemnce - GoId
  * @param string $secureKey - kryptovaci klic prideleny GoPay
  * @throws \Exception
  * @return float payment session ID
  */
 public function capturePayment($paymentSessionId, $targetGoId, $secureKey)
 {
     try {
         //inicializace WS
         $go_client = self::createSoapClient();
         $sessionEncryptedSignature = GopayHelper::getPaymentSessionSignature($targetGoId, $paymentSessionId, $secureKey);
         $paymentSession = array("targetGoId" => (double) $targetGoId, "paymentSessionId" => (double) $paymentSessionId, "encryptedSignature" => $sessionEncryptedSignature);
         $paymentResult = $go_client->__call('capturePayment', array('sessionInfo' => $paymentSession));
         if ($paymentResult->result == GopayHelper::CALL_RESULT_FAILED) {
             throw new Exception("payment not captured [" . $paymentResult->resultDescription . "]");
         } else {
             if ($paymentResult->result == GopayHelper::CALL_RESULT_ACCEPTED) {
                 // dokonceni platby bylo zarazeno ke zpracovani
                 throw new Exception(GopayHelper::CALL_RESULT_ACCEPTED);
             }
         }
         return $paymentResult->paymentSessionId;
     } catch (SoapFault $f) {
         /*
          * Chyba v komunikaci s GoPay serverem
          */
         throw new Exception("SOAP error");
     }
 }