Skip to content

Normalize from/to dates in QR code, settlement & refund list endpoints#482

Closed
vinothksekar wants to merge 1 commit into
razorpay:masterfrom
vinothksekar:fix/normalize-dates-in-list-endpoints
Closed

Normalize from/to dates in QR code, settlement & refund list endpoints#482
vinothksekar wants to merge 1 commit into
razorpay:masterfrom
vinothksekar:fix/normalize-dates-in-list-endpoints

Conversation

@vinothksekar

Copy link
Copy Markdown

Summary

Five list endpoints destructure { from, to, count, skip } from params and then spread them straight back into the request as { ...params, from, to, count, skip } — a no-op that never calls normalizeDate:

  • payments.fetchMultipleRefund
  • qrCode.all
  • qrCode.fetchAllPayments
  • settlements.all
  • settlements.fetchAllOndemandSettlement

Every other list endpoint (orders.all, payments.all, items.all, invoices.all, addons.all) normalizes from/to so a Date/date-string is converted to epoch seconds. These five silently skip that, so passing a human-readable date sends an unconverted value to the API and the date filter is wrong.

Fix

Call normalizeDate on from/to in the five methods (adding the util import to qrCode.js and settlements.js). normalizeDate passes numeric timestamps through unchanged, so this is backward compatible for callers already sending epoch seconds.

Tests

Added regression tests asserting from/to are converted to seconds for each fixed method. Verified they fail without the source change and pass with it. Full suite: 384 passing.

`qrCode.all`, `qrCode.fetchAllPayments`, `settlements.all`,
`settlements.fetchAllOndemandSettlement` and `payments.fetchMultipleRefund`
destructured `{ from, to, count, skip }` from params and then spread them
back into the request as `{ ...params, from, to, count, skip }` — a no-op
that never called `normalizeDate`. As a result these endpoints did not
convert `from`/`to` Date objects / date strings into epoch seconds the way
every other list endpoint (orders.all, payments.all, items.all,
invoices.all, addons.all) does, so passing a human date silently sent an
unconverted value to the API.

Normalize `from`/`to` via normalizeDate in these five methods (added the
util import to qrCode.js and settlements.js). normalizeDate passes numeric
timestamps through unchanged, so this is backward compatible for callers
already sending epoch seconds.

Added regression tests asserting the dates are converted (they fail
without this change).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@vku2018

vku2018 commented Jul 3, 2026

Copy link
Copy Markdown

One thing I deliberately left out to keep this focused on the date bug: these same five methods also don't default count/skip the way the other list endpoints do (count = Number(count) || 10, skip = Number(skip) || 0). Happy to fold that consistency fix into this PR or send it as a separate one — whichever you prefer.

@vinothksekar vinothksekar closed this by deleting the head repository Jul 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants