/**
  * Returns all parameters as a querystring.
  *
  * @return string
  */
 protected function stringifyParameters()
 {
     if (isset($this->parameters['PBX_HMAC'])) {
         unset($this->parameters['PBX_HMAC']);
     }
     ksort($this->parameters);
     return Tools::stringify($this->parameters);
 }
Esempio n. 2
0
 /**
  * Verifies the validity of the signature.
  *
  * @return bool
  */
 public function verifySignature()
 {
     $this->logger->info('New IPN call.');
     $this->initData();
     $this->initSignature();
     $file = fopen($this->parameters['public_key'], 'r');
     $cert = fread($file, 1024);
     fclose($file);
     $publicKey = openssl_pkey_get_public($cert);
     $result = openssl_verify(Tools::stringify($this->data), $this->signature, $publicKey, 'sha1WithRSAEncryption');
     $this->logger->info(Tools::stringify($this->data));
     $this->logger->info(base64_encode($this->signature));
     if ($result == 1) {
         $this->logger->info('Signature is valid.');
     } elseif ($result == 0) {
         $this->logger->error('Signature is invalid.');
     } else {
         $this->logger->error('Error while verifying Signature.');
     }
     $result = 1 == $result;
     openssl_free_key($publicKey);
     $event = new PayboxResponseEvent($this->data, $result);
     $this->dispatcher->dispatch(PayboxEvents::PAYBOX_IPN_RESPONSE, $event);
     return $result;
 }