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
3434 public function isValid (Request $ request , WebhookConfig $ config ): bool
3535 {
3636 $ 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 ' ),
4040 ];
4141
4242 $ secret = $ config ->signingSecret ;
4343
4444 try {
45- Webhook::constructEvent ($ request ->all (), $ signatureArray , $ secret );
45+ Webhook::constructEvent ($ request ->input (), $ signatureArray , $ secret );
4646 } catch (Exception $ exception ) {
4747 return false ;
4848 }
4949
5050 return true ;
5151 }
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+ }
5266}
You can’t perform that action at this time.
0 commit comments