Skip to content

Commit 1ff1f73

Browse files
author
Thom Werring
committed
Merge remote-tracking branch 'origin/adyen'
# Conflicts: # src/Adyen/Adyen.php
2 parents 0769373 + c6d70a8 commit 1ff1f73

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/Adyen/Adyen.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ public function __construct() {
5757
);
5858
}
5959

60+
6061
public function setBrand($brand)
6162
{
6263
$this->brand = $brand;
@@ -532,6 +533,19 @@ public function getSha256HPPParams()
532533
return $params;
533534
}
534535

536+
public static function verifySignature($data,$sharedSecret){
537+
$signature = $data['merchantSig'];
538+
$hmacData = '';
539+
ksort($data);
540+
$sign = [];
541+
foreach($data as $key=>$value){
542+
if(!in_array($key,['sig','merchantSig']) && substr($key,0,7) !=='ignore.') {
543+
$sign[$key] = str_replace(':','\\:',str_replace('\\','\\\\',$value));
544+
}
545+
}
546+
$hmacData = implode(':',array_merge(array_keys($sign),array_values($sign)));
547+
return base64_encode(hash_hmac('sha256', $hmacData, $sharedSecret, true)) === urldecode($signature);
548+
}
535549

536550
private function getMerchantSignature() {
537551
$sharedSecret = $this->getSharedSecret();
@@ -675,8 +689,6 @@ public function submitRecurringPayment($recurringDetailReference = null)
675689
$shopperReference = $this->getShopperReference();
676690
$openInvoiceLines = $this->getOpenInvoiceLines();
677691
$brand = $this->getBrand();
678-
679-
680692
if(!$merchantAccount) throw new AdyenException("No merchantAccount set.");
681693
if(!$merchantReference) throw new AdyenException("No merchantReference set.");
682694
if(!$currencyCode) throw new AdyenException("No Currency Code set.");

0 commit comments

Comments
 (0)