Closed egorsmth closed 4 years ago
Hi @egorsmth , can you add more context about this issue? do you have code snippet?
@xjijies
var foo = {a: 1.0}
var bar = JSON.parse(JSON.stringify(foo))
console.log(foo === bar)
console.log(bar)
// false
// {a: 1}
so when sdk tries to validate body it fails if body contains for example 1.0
as you see in snippet
@egorsmth Can you tell me for which flow you are facing this issue. I mean the function and file you called under lib/resources/*
@xjijies
Notification.js
line 119
When we receive webhook we should call verify
function to verify that this webhook is from paypal.
We pass to verify received headers and body, which sdk transforms and sends to PayPal for validation.
As you see in Notification.js
on line 119, sdk either call JSON.parse to parse body or just use object we passed to make a request. But if our body contains in some field value 1.0
, it parsed and the stringified to 1, so paypal can't validate it.
@egorsmth I tried with sample in PayPal-node-SDK, webhook_payload_verify.js. In eventbody decimal values are in stringify pattern, I got verification_status as Success. For var foo = '{"a": "1.0"}' parsed value result in 1.0. Do you have any use case where you send data in decimal number format.
@egorsmth Closing this issue. Please reopen if you are still need any help further around this.
Issue description
There is an issue with verify function. Because of using
JSON.parse
on body, some values are changed. For example1.0
become1
, that is give us failure on verification in paypal. Please fix that.