public function testSignature()
 {
     foreach (Environment::$ALLOWED_HASHES as $hash) {
         $this->environment->setHashAlgorithm($hash);
         $payment = $this->getRandomPayment();
         $parameters = $payment->getParameters()->getAll();
         $fields = $payment->getForm()->getHiddenFields();
         $hash = $this->createHash($parameters, $this->environment->getShaIn(), $this->environment->getHashAlgorithm());
         $this->assertEquals($fields[Parameter::SIGNATURE], $hash);
     }
 }
Пример #2
0
 /**
  * adds sha signature to the parameters.
  *
  * @return $this
  */
 protected function addSignature()
 {
     $parameters = $this->parameters->getAll();
     ksort($parameters);
     $string = '';
     foreach ($parameters as $key => $value) {
         $string .= sprintf('%s=%s%s', $key, $value, $this->environment->getShaIn());
     }
     $this->parameters->add(Parameter::SIGNATURE, strtoupper(hash($this->environment->getHashAlgorithm(), $string)));
     return $this;
 }