Client error handling for custom stripe checkout - stripe-payments

I'm trying to catch Stripe errors that customer sees after entering invalid card data. I'm using Stripe checkout.js in the same way like in another StackOverflow question: Error handling for custom stripe checkout
And according to the #Ywain answer there (https://stackoverflow.com/a/43896401/5008606)
Checkout validates the card information with the issuing bank. If the information is invalid, then the error is displayed directly to the customer in the popup form
What can I do to be aware of such errors (in order to log them)? Can I disable frontend errors and catch all errors in the backend? Or is there some way to catch such errors in a javascript handler? Thanks!

Related

Facebook Messages RESPONSE call working for my testing team, but not for FB testing team

I am creating a messaging app using Facebook messenger. I have been testing it thoroughly with my own account and another "tester" account. It works as expected for the two of us.
When submitting it for approval, the Facebook testing team messaged our page, but I received a ((#-1) Unexpected internal error) message when calling the RESPONSE api to reply.
Any ideas? I find it hard to believe this is an error on Facebook's end, but this is what's showing up for me.
Thank you in advance!
Detailed error message:
code:-1
error_subcode:2018012
message:(#-1) Unexpected internal error
type:OAuthException
I tried re-submitting the API call, but received the same error. I checked to see if it would work with another Recipient ID (my own), and it did. I'm not sure if this is a matter of approvals from Facebook's end, and if it's one of those cyclical situations where 'they need to approve me for it to be approved' or not.

Stripe API testing automation

Background
I am integrating stripe API into my site to take one off payments. My site will be API first on server side with a separate web and mobile front end. I am working on the API server side code. I will eventually use stripe payment pages to take credit card payments. I am trying to automate the testing of my APIs and am bamboozled by the documentation (which are thorough) as I just can't see what steps to take next.
My server side initiates a call with stripe using stripe sdk to create a stripe Session object - this contains a URL to redirect to checkout.stripe.com/pay/..., a success URL when payment is successful and a cancel URL (these I set to handle the callback).
Problem
I can automate in Postman all my API calls from Browse Products, Select Product, Place Order but the next step I am stuck. After Placing Order I get back the stripe session but how can I mimick making the payment with stripe for the session and then call my Success URL ?
When the site is complete I will redirect the UI to stripe to take payments but I am testing and completing the back end flow first.
I have copied and pasted the session URL which is returned by the stripe Session object to bring up the page in a browser and used Dev tools on Chrome to inspect Network to see which APIs are being called by stripe in an attempt to reproduce and I can see a POST to stripe.com/api/payment_methods and I can see the posted values but I can't reproduce this in Postman. Also, the documentation (https://stripe.com/docs/api/payment_methods/create) says
"Instead of creating a PaymentMethod directly, we recommend using the
PaymentsIntents API to accept a payment immediately"
Question
Which stripe APIs do I need to call to automate the flow from a stripe Session object to make a payment and then check that it was successful? Payment Methods? Make a Charge? Payments Intents? ...and how. Happy to be pointed to the documentation if you can help me understand the flow.
TIA
Checkout is a Stripe product that looks like a "box" and you can't know (and shouldn't need to know) what happens inside. It is created for the purpose that merchants won't have to think about what's being done under the hood.
Speaking from an automation perspective, you can try to reproduce the whole process but there's no guarantee it won't change in the future, and it could leave you with more problems later.
For options to reproduce:
The closest way is simulating browser filling and submission, using automated browser tools (ie Selenium). But it's not as straightforward as PostMan. Generally you would want to simulate every browser action that a human could do.
Or you can try to accomplish the same with the logs and events you receive on Stripe's Dashboard, when you test a Checkout Session by yourself. From now there are 3 requests.
And your goal is to receive the same 5 events in Webhook:
TBH I recommend to reconsider the need of this test, to see if it worth your efforts.

Update my database after Stripe payment successful

I am implementing Stripe on a website for the first time and I'm not sure the right way to do something. After the payment is successful I need to update my database before the client is redirected to the "client's account dashboard", so the dashboard shows the updated information. I thought the right way would be to use webhooks, but if the webhook takes longer to update the database then the redirection, the dashboard will show outdated info.
I found an old post with a similar problem to mine where they said there is no need to use webhooks, as Stripe API calls are synchronous and I can get "the charge object" back which indicates that the payment succeeded. It's a fairly old post so I am not sure if that's the way to go (and also, I can't find information on Stripe Docs on how retrieve the "charge object" once redirected to the "success page")
I would appreciate any help. Thanks!
*Edit: Would polling be a viable way to accomplish this? I can keep the client in the "success page" and use polling to check when the database has been updated, and then redirect.

Plaid with Stripte PRODUCT_NOT_READY 400 Error

I used ACH transfer with plaid and stripe my website.
Bank connections are currently working. However, after connecting their bank account, the user gets a 400 server error that prevents them from being redirected to the dashboard.
I believe the error code associated with this issue is PRODUCT_NOT_READY
https://plaid.com/docs/errors/assets/#product_not_ready.
The server is a node server.
I want to know how I can fix this error.
Regards
Are you tracking the webhook? It seems that the server will send you a WebHook to the endpoint and only after that the resource will be available.
The Plaid server will send you a PRODUCT_READY webhook before you can call /asset_report/get
The PRODUCT_NOT_READY error you linked to is of type ASSET_REPORT_ERROR. If you're using Plaid for ACH transfers, you're probably not using Assets and you're probably getting the PRODUCT_NOT_READY error of type ITEM_ERROR. For that error, the likely causes listed are:
/transactions/get was called before the first 30 days of transaction data could be pulled. [Not relevant to you if you're not using transactions]
/auth/get was called on an Item that hasn't been verified, which is possible when using micro-deposit based verification [probably the cause of your problem]
Like Nikolas L. says, you will need to listen for webhooks, in this case to be alerted when the Item has been verified.

How can I get localized error messages from Stripe

One of our customers triggered a "Your card has insufficient funds." error during card registration (we only issue a charge at a later time) and we weren't able to show a helpful error message because we didn't have a localization for this error. While my sibling-question Show (localized) payment source registration errors directly in Stripe Elements tries to work around the issue by avoiding to have to display the error at all, there are other places in our payment flow where our backend has to deal with payment errors (e.g. to send the user a mail stating the reason for the payment failure).
Is it possible to get a localized error text from stripe or is there a complete list of possible error codes so we can localize the messages ourselves? (We are using the stripe ruby gem, if that is of relevance.)
This gem might be useful for you here: https://github.com/ekosz/stripe-i18n

Resources