Skip to content

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

@htomar6397

Description

@htomar6397

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions