diff --git a/Action/Api/CreateChargeAction.php b/Action/Api/CreateChargeAction.php index 23b6268..4944cca 100644 --- a/Action/Api/CreateChargeAction.php +++ b/Action/Api/CreateChargeAction.php @@ -107,6 +107,9 @@ public function execute($request): void $model['hashedOrderid'] = md5($model['orderid'] . 'H' . $request->getToken()->getHash() . $retries); $mappedModel = new ArrayObject(); + if (isset($model['version'])) { + $mappedModel['version'] = $model['version']; + } if (isset($model['mid'])) { $mappedModel['mid'] = $model['mid']; } elseif ($this->mid != null) { diff --git a/Action/ConvertPaymentAction.php b/Action/ConvertPaymentAction.php index 09f53f2..5b64dae 100644 --- a/Action/ConvertPaymentAction.php +++ b/Action/ConvertPaymentAction.php @@ -1,4 +1,5 @@ isSandbox = $isSandbox; $this->useMasterPass = $useMasterPass; $this->lang = $lang; @@ -29,7 +31,7 @@ public function __construct(bool $isSandbox, bool $useMasterPass, string $lang, * * @param Convert $request */ - public function execute($request) + public function execute($request): void { RequestNotSupportedException::assertSupports($this, $request); @@ -37,34 +39,34 @@ public function execute($request) $payment = $request->getSource(); $details = ArrayObject::ensureArrayObject($payment->getDetails()); + $details['version'] = 2; $details['lang'] = $this->lang; $details['orderid'] = $payment->getNumber(); $details['orderDesc'] = $payment->getDescription(); - $details['orderAmount'] = $payment->getTotalAmount()/100; + $details['orderAmount'] = $payment->getTotalAmount() / 100; $details['currency'] = $payment->getCurrencyCode(); $details['payerEmail'] = $payment->getClientEmail(); - if($this->isSandbox) { + if ($this->isSandbox) { $details['orderAmount'] = 0.5; // Alpha Bank's sandbox requires <1 EUR } - if($this->useMasterPass == true) { + if ($this->useMasterPass == true) { $details['payMethod'] = 'auto:MasterPass'; } - if($this->cssUrl != null) { + if ($this->cssUrl != null) { $details['cssUrl'] = $this->cssUrl; } - $request->setResult((array) $details); + $request->setResult((array)$details); } /** * {@inheritDoc} */ - public function supports($request) + public function supports($request): bool { return $request instanceof Convert && $request->getSource() instanceof PaymentInterface && - $request->getTo() == 'array' - ; + $request->getTo() == 'array'; } } diff --git a/Util/DigestCalculator.php b/Util/DigestCalculator.php index f96559f..7aa7253 100644 --- a/Util/DigestCalculator.php +++ b/Util/DigestCalculator.php @@ -25,16 +25,15 @@ public function calculateDigest(ArrayObject $model): string $string .= $curValue; } $string .= $this->sharedSecretKey; - error_log($string); - return base64_encode(sha1($string, true)); + return base64_encode(hash('sha256', $string, true)); } public function calculateDigestForString(string $string): string { $string .= $this->sharedSecretKey; - return base64_encode(sha1($string, true)); + return base64_encode(hash('sha256', $string, true)); } public function verifyDigest(array $model, string $digest): bool @@ -45,7 +44,7 @@ public function verifyDigest(array $model, string $digest): bool $string .= $curValue; } $string .= $this->sharedSecretKey; - $newDigest = base64_encode(sha1($string, true)); + $newDigest = base64_encode(hash('sha256', $string, true)); return $newDigest === $digest; }