razorpay / razorpay/razorpay-node

Incorrect TypeScript Typings for `fail_existing` in customers.create (should allow '0' | '1' strings)

Open
#463 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
243
Forks
128
PR merge metrics
No merged PRs in 30d

Description

Steps to reproduce the behavior
  1. Create a new Node.js project using TypeScript.

  2. Install the Razorpay package by running: npm install razorpay@2.9.6.

  3. Set up the Razorpay client with your API keys, then attempt to create a new customer using the following code:

await razorpay.customers.create({
  contact: '....',
  email: '....',
  fail_existing: 0
});

see the video for more clarity onedrive_link
If you run this code the first time, it should work. If you try again, you may receive an error indicating that the customer already exists in your merchant account.

Expected behavior

The type definition should be:

fail_existing?: '0' | '1' | undefined;

so that valid strings are allowed.

Actual behavior

It currently allows:

fail_existing?: boolean | 1 | 0 | undefined;

which does not match actual API behavior.

Code snippets

Node version

Node v22.20.0

Library version

razorpay v2.9.6

Additional Information

No response

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the TypeScript definition used by customers.create and compare the fail_existing type with the expected API values described in the issue. Done means the customer creation input accepts the documented string values and the package's TypeScript checks pass.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, typescript
Domain
api
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.