Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error return value does not match RecurlyError type signature #110

Open
froesecom opened this issue Feb 9, 2021 · 1 comment
Open

Error return value does not match RecurlyError type signature #110

froesecom opened this issue Feb 9, 2021 · 1 comment
Labels

Comments

@froesecom
Copy link

Issue:

When validating user input errors, the type of "error" returned by recurly.token in this example, recurly.token(formRef.current, (error, token) => {} does not match the RecurlyError type defined by Recurly.js
.

recurly.token errors have this structure:

{
  "name": "validation",
  "code": "validation",
  "message": "There was an error validating your request.",
  "fields": [
    "number",
    "month",
    "year"
  ],
  "details": [
    {
      "field": "number",
      "messages": [
        "is invalid"
      ]
    },
    {
      "field": "month",
      "messages": [
        "is invalid"
      ]
    },
    {
      "field": "year",
      "messages": [
        "is invalid"
      ]
    }
  ]
}

RecurlyError is defined by Recurly.js as:

export interface RecurlyError extends Error {
  code: string;
  message: string;
  classification: string;
  help?: string;
}

When using TypeScript, this causes compilation errors if you try to handle the actual response from Recurly.js.

To Reproduce

The bug can be reproduced by inputting an invalid credit card expiry date in the React Recurly demo page and checking the console output.

Expected behavior

The returned error matches the type defined by Recurly.js

Your Environment

  • Using ReactReculry 1.2.3
@froesecom froesecom added the bug? label Feb 9, 2021
@javimbk
Copy link
Contributor

javimbk commented Oct 12, 2021

Any updates on this? Struggling with it when trying to do proper error handling on our code.

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants