Giter Site home page Giter Site logo

Comments (5)

roykho avatar roykho commented on June 30, 2024

code should be correct per Stripe's reference docs seen here https://stripe.com/docs/api#errors

from woocommerce-gateway-stripe.

 avatar commented on June 30, 2024

I'm the original poster on the WP support area. - I've investigated this a little more. It ends up this only occurs on empty form submission.

If you submit an empty form to stripe, it returns an error message without a code.

Empty form response:
{
"error": {
"type": "invalid_request_error",
"message": "Could not find payment information"
}
}

If the form has any data it will return with a code

Example response:
{
"error": {
"message": "Your card's expiration year is invalid.",
"type": "card_error",
"param": "exp_year",
"code": "invalid_expiry_year"
}
}

The problem being it's not currently possible to localise the empty form error response.

from woocommerce-gateway-stripe.

samuelaguilera avatar samuelaguilera commented on June 30, 2024

@roykho you have added messages only for card_error type and assumed that any responseObject will have a code, but as you can see in the results pasted by @netplus and also in the Stripe docs, there also additional error types and not all types have a code, some of them only have a type and message. From the Stripe.com docs linked above:

The type of error returned. Can be: api_connection_error, api_error, authentication_error, card_error, invalid_request_error, or rate_limit_error.

The appropriate solution would be check responseObject.response.error.type to determine what data contains the responseObject (e.g. it has a code or not?) and proceed accordingly. That is basically what Stripe.com is recommending with this:

Handling errors
Our API libraries raise exceptions for many reasons, such as a failed charge, invalid parameters, authentication errors, and network unavailability. We recommend writing code that gracefully handles all possible API exceptions.

from woocommerce-gateway-stripe.

roykho avatar roykho commented on June 30, 2024

@samuelaguilera - this has already been flagged a bug so it is known and will be fixed by next release.

from woocommerce-gateway-stripe.

samuelaguilera avatar samuelaguilera commented on June 30, 2024

@roykho great! just commented because of your comment after flagging it as a bug and also seeing that it was labeled as "needs author reply" days after that. Just wanted to add some light here :)

from woocommerce-gateway-stripe.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.