@@ -57,6 +57,7 @@ public function __construct() {
57
57
);
58
58
}
59
59
60
+
60
61
public function setBrand ($ brand )
61
62
{
62
63
$ this ->brand = $ brand ;
@@ -532,6 +533,19 @@ public function getSha256HPPParams()
532
533
return $ params ;
533
534
}
534
535
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
+ }
535
549
536
550
private function getMerchantSignature () {
537
551
$ sharedSecret = $ this ->getSharedSecret ();
@@ -675,8 +689,6 @@ public function submitRecurringPayment($recurringDetailReference = null)
675
689
$ shopperReference = $ this ->getShopperReference ();
676
690
$ openInvoiceLines = $ this ->getOpenInvoiceLines ();
677
691
$ brand = $ this ->getBrand ();
678
-
679
-
680
692
if (!$ merchantAccount ) throw new AdyenException ("No merchantAccount set. " );
681
693
if (!$ merchantReference ) throw new AdyenException ("No merchantReference set. " );
682
694
if (!$ currencyCode ) throw new AdyenException ("No Currency Code set. " );
0 commit comments