Skip to content

Commit 96d3f19

Browse files
committed
fix hmac calculation in complete purchase response
1 parent efaa183 commit 96d3f19

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

src/Messages/CompletePurchaseResponse.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,18 @@ public function getCardToken()
7777

7878
private function everyPayRequestHmac()
7979
{
80+
$options = SignedDataOptions::gateway(
81+
$this->request->getSecret()
82+
)->dontInclude([
83+
'utf8',
84+
'hmac',
85+
'_method',
86+
'authenticity_token'
87+
]);
88+
8089
return SignedData::make(
8190
$this->data['request'],
82-
SignedDataOptions::gateway(
83-
$this->request->getSecret()
84-
)
91+
$options
8592
)['hmac'];
8693
}
8794

src/Support/SignedDataOptions.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,17 @@ public static function backend($secret)
3131
]);
3232
}
3333

34+
public function dontInclude(array $fields)
35+
{
36+
$this->options['dontInclude'] = array_unique(
37+
array_merge(
38+
$this->options['dontInclude'] ?? [],
39+
$fields
40+
)
41+
);
42+
return $this;
43+
}
44+
3445
public function shouldHmacInclude($field)
3546
{
3647
return !in_array($field, $this->options['dontInclude']);

0 commit comments

Comments
 (0)