n8n-io / n8n

Free and source-available fair-code licensed workflow automation tool. Easily automate tasks across different services.
https://n8n.io
Other
45.52k stars 6.27k forks source link

Example workflow uses wrong timestamp format for Stripe API #5162

Closed jekuno closed 1 year ago

jekuno commented 1 year ago

Summary The example workflow Sync payment and customer data between Stripe and Pipedrive uses the wrong timestamp format (milliseconds instead of seconds) for getting a filtered list of charges from Stripe.

That's why the workflow doesn't return any charges and therefore doesn't execute.

To Reproduce

  1. Run the example workflow.
  2. Create a charge in Pipe.
  3. Run the workflow again.

The node "Search for charges in stripe" doesn't return the newly created charge.

Expected behavior The newly created charge gets returned.

Environment

How to FIX The Stripe API expects seconds instead of milliseconds. see https://stripe.com/docs/api/charges/object#charge_object-created:

created: Timestamp. Time at which the object was created. Measured in seconds since the Unix epoch.

Therefore in the 'Get last execution timestamp' node of the workflow replace the following lines new Date().getTime() with Math.round(new Date().getTime() / 1000)

Joffcom commented 1 year ago

Hey @jekuno

Good spot, I will get that template updated on Monday.

jekuno commented 1 year ago

Great. Another detail: In the "Create note with charge information" node, I also changed {{ $json["amount"]}} to {{ $json["amount"] / 100}} as Stripe returns cents, but the currency is displayed as eur or usd.

Joffcom commented 1 year ago

Hey @jekuno,

I have just made both updates to that one as it is one of ours and not a community submitted one, It might take about 30 minutes to update.

For now I am going to mark this one as closed, Thanks again for letting us know 🙌🏻