/**
  * Add query config data to PaynetEasy payment transaction
  *
  * @param       PaymentTransaction      $paynetTransaction      PaynetEasy payment transaction
  * @param       string                  $redirectUrl            Url for final payment processing
  */
 protected function addQueryConfigData(PaymentTransaction $paynetTransaction, $redirectUrl = null)
 {
     $paynetTransaction->getQueryConfig()->setEndPoint($this->paymentConfig['end_point'])->setLogin($this->paymentConfig['login'])->setSigningKey($this->paymentConfig['signing_key'])->setGatewayMode($this->paymentConfig['gateway_mode'])->setGatewayUrlSandbox($this->paymentConfig['sandbox_gateway'])->setGatewayUrlProduction($this->paymentConfig['production_gateway']);
     if (Validator::validateByRule($redirectUrl, Validator::URL, false)) {
         $paynetTransaction->getQueryConfig()->setRedirectUrl($redirectUrl)->setCallbackUrl($redirectUrl);
     }
 }
 /**
  * Validate callback response control code
  *
  * @param       PaymentTransaction      $paymentTransaction     Payment transaction for control code checking
  * @param       CallbackResponse        $callbackResponse       Callback for control code checking
  *
  * @throws      ValidationException                             Invalid control code
  */
 protected function validateSignature(PaymentTransaction $paymentTransaction, CallbackResponse $callbackResponse)
 {
     // This is SHA-1 checksum of the concatenation
     // status + orderid + client_orderid + merchant-control.
     $expectedControlCode = sha1($callbackResponse->getStatus() . $callbackResponse->getPaymentPaynetId() . $callbackResponse->getPaymentClientId() . $paymentTransaction->getQueryConfig()->getSigningKey());
     if ($expectedControlCode !== $callbackResponse->getControlCode()) {
         throw new ValidationException("Actual control code '{$callbackResponse->getControlCode()}' does " . "not equal expected '{$expectedControlCode}'");
     }
 }
 /**
  * Add query config data to PaynetEasy payment transaction
  *
  * @param       PaynetTransaction       $paynetTransaction      PaynetEasy payment transaction
  * @param       string                  $redirectUrl            Url for final payment processing
  *
  * @return      PaynetTransaction                               PaynetEasy payment transaction
  */
 protected function addQueryConfigData(PaynetTransaction $paynetTransaction, $redirectUrl = null)
 {
     $paynetTransaction->getQueryConfig()->setEndPoint($this->getConfigData('endpoint_id'))->setLogin($this->getConfigData('merchant_login'))->setSigningKey($this->getConfigData('merchant_key'))->setGatewayMode($this->getConfigData('gateway_mode'))->setGatewayUrlSandbox($this->getConfigData('sandbox_api_url'))->setGatewayUrlProduction($this->getConfigData('production_api_url'));
     if (Validator::validateByRule($redirectUrl, Validator::URL, false)) {
         $paynetTransaction->getQueryConfig()->setRedirectUrl($redirectUrl)->setCallbackUrl($redirectUrl);
     }
 }
 /**
  * Validates payment transaction query config
  *
  * @param       PaymentTransaction      $paymentTransaction     Payment transaction
  *
  * @throws      RuntimeException                                Some query config property is empty
  */
 protected function validateQueryConfig(PaymentTransaction $paymentTransaction)
 {
     $queryConfig = $paymentTransaction->getQueryConfig();
     if (strlen($queryConfig->getSigningKey()) === 0) {
         throw new ValidationException("Property 'signingKey' does not defined in PaymentTransaction property 'queryConfig'");
     }
     if (strlen($queryConfig->getEndPoint()) == 0 && strlen($queryConfig->getEndPointGroup()) === 0) {
         throw new ValidationException("Properties 'endPont' and 'endPointGroup' do not defined in " . "PaymentTransaction property 'queryConfig'. Set one of them.");
     }
     if (strlen($queryConfig->getEndPoint()) > 0 && strlen($queryConfig->getEndPointGroup()) > 0) {
         throw new ValidationException("Property 'endPont' was set and property 'endPointGroup' was set in " . "PaymentTransaction property 'queryConfig'. Set only one of them.");
     }
 }