/**
  * Calculates signature for any data given as an array of strings.
  *
  * @param string[]             $data
  * @param CredentialsInterface $credentials private key is needed to calculate signature
  * @param AlgorithmInterface   $algorithm   calculator uses encoder which can use multiple algorithms
  *
  * @return string
  * @throws SignatureCalculatorException
  */
 public function calculate(array $data, CredentialsInterface $credentials, AlgorithmInterface $algorithm)
 {
     $concatenated = '';
     array_walk_recursive($data, function ($value) use(&$concatenated) {
         $concatenated .= $value;
     });
     $concatenated .= $credentials->getPrivateKey();
     return $this->encode($concatenated, $algorithm);
 }
Example #2
0
 /**
  * @param CredentialsInterface $credentials
  *
  * @return array
  */
 private function getOptions(CredentialsInterface $credentials)
 {
     return [CURLOPT_HTTPAUTH => CURLAUTH_BASIC, CURLOPT_USERPWD => sprintf('%s:%s', $credentials->getMerchantPosId(), $credentials->getMerchantPosId()), CURLOPT_SSLVERSION => 1, CURLOPT_SSL_CIPHER_LIST => $credentials->getEncryptionProtocols(), CURLOPT_SSL_VERIFYHOST => 2, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_ENCODING => 'gzip', CURLOPT_FOLLOWLOCATION => false];
 }