File tree Expand file tree Collapse file tree 1 file changed +18
-4
lines changed Expand file tree Collapse file tree 1 file changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -34,19 +34,33 @@ class LobSignatureValidator implements SignatureValidator
34
34
public function isValid (Request $ request , WebhookConfig $ config ): bool
35
35
{
36
36
$ signatureArray = [
37
- 'token ' => json_encode ( $ request -> all () ),
38
- 'timestamp ' => $ request ->header ('lob-signature-timestamp ' ),
39
- 'signature ' => $ request ->header ('lob-signature ' ),
37
+ 'token ' => $ this -> payload ( $ request ),
38
+ 'timestamp ' => $ request ->header ('lob-signature-timestamp ' ),
39
+ 'signature ' => $ request ->header ('lob-signature ' ),
40
40
];
41
41
42
42
$ secret = $ config ->signingSecret ;
43
43
44
44
try {
45
- Webhook::constructEvent ($ request ->all (), $ signatureArray , $ secret );
45
+ Webhook::constructEvent ($ request ->input (), $ signatureArray , $ secret );
46
46
} catch (Exception $ exception ) {
47
47
return false ;
48
48
}
49
49
50
50
return true ;
51
51
}
52
+
53
+ /**
54
+ * Compile the payload.
55
+ *
56
+ * @param Illuminate\Http\Request $request
57
+ * @return string
58
+ */
59
+ protected function payload (Request $ request ): string
60
+ {
61
+ // Will decode the body into an object, not an array
62
+ $ decoded = json_decode ($ request ->getContent ());
63
+ // recode back into string
64
+ return json_encode ($ decoded , JSON_UNESCAPED_SLASHES );
65
+ }
52
66
}
You can’t perform that action at this time.
0 commit comments