Stripe unpaid status - stripe-payments

In my Pyro CMS project, I am using Stripe payment gateway, while testing product's payment in test environment, all things go smooth but in live, I am getting a lot of unpaid order status. When is this status flag set? Is there any way that i can track the reason?

Ok, I figured out the problem. When a customer checkout the products and reach payment page but, doesnot pays or proceed further, the status remains unpaid which is default case**(had customer proceeded and placed credit card details, the status would have changed to failed or paid according to the validity of credit card)**. The order is placed but not paid. So if someone gives just try out to the whole thing, we see a lot of Unpaid orders...

Related

Is it okay to have a bunch of incomplete Stripe payment intents?

I am implementing the Stripe payment platform using JavaScript and the PHP SDK.
I don't have any issues with the implementation itself, but I am not sure whether I have to reuse an existing PaymentIntent or it's perfectly fine to have a bunch of them created and incomplete.
I searched for this in Stripe's documentation, but I can't seem to find anything related to this.
For example, in my test account I have this:
It's all for the same transaction, because I was changing some visuals and refreshing the browser.
I am aware that each PaymentIntent has an ID, but is it recommended to add it as a query parameter and retrieve it on refreshing, or is it better to always generate a new Payment Intent.
My main reasoning is to avoid having a huge collection of incomplete payment intents.
The default integration path for Stripe today is to create a PaymentIntent first so that you get a client_secret you can use client-side to render their UI via PaymentElement. This means that if your customers decide not to pay after all, you end up with an incomplete PaymentIntent which is expected.
This is not really a problem, other than appearing in the Payments list which can be confusing. You could also write a background job daily that would cancel any PaymentIntent via you know won't be completed because the customer left and you didn't have any data to contact them to upsell them for example but this isn't really needed.
Stripe also has a beta (docs) right now (Feb 2023) that changes the default integration path. This simplifies the experience because you can render the PaymentElement client-side with specific options such as amount and currency. You'd then only create the PaymentIntent at the end of the flow
when the customer is attempting to pay. That flow limits the number of incomplete PaymentIntents since you only create them when the customer really pays. You'd still get some, for example after a decline by the customer's bank though.

What's the best practice for handling bill details with Stripe?

In my mobile app when the user has selected some items, I would like them to be able to review their order and see a preview of their bill (the price of each item, subtotal, taxes and total). However I would not want them to pay immediately. Once they place the order, they will not be charged until the order is accepted.
Do I calculate the user's subtotal, tax and total on my server or does stripe provide an api to handle these?
I've read the docs on invoicing and checkout, and checkout seems to be the api for my situation but I'm not 100% sure.
It depends on how you define "place the order" and "order is accepted". Normally when the Stripe's Checkout Session page is displayed to your customer and they push the "Pay" button, the transaction will be executed immediately (they paid), then the customer can be redirected back to your page or app.
If you want to somehow delay the payment until a specific timing (that you want to review or execute some logic, before eventually "accept" the order), you can consider using Checkout with Setup Intent.

Stripe Testing - Charge user right away even if subscription due date is next month

I have created a project that allows users to subscribe to our service monthly or yearly.
Now, I want to test our Stripe integration by attaching a working credit card, then changing that credit card into a "decline card" which I found here (4000000000000341).
Now, I wanted to test that flow. I can see that the user's upcoming invoice is still next month, but obviously, I cannot wait for next month since I want to test it right away.
I was Googling and I see that they mentioned that I should put a trial date, I tried that by modifying the user's subscription in the Stripe dashboard, but seems not to work. Maybe I'm missing something or did something wrong? The current flow of our subscription basis is we don't have a trial period, so I am not sure if putting a trial date is applicable to us.
Any help/tips is greatly appreciated! Thank you!
You should use test clocks.
You can simply advance the clock's time to one month later so that the upcoming invoice will be ready for you.
I believe the upcoming invoice won't be paid successfully as you are using a decline test card. You can read this doc to learn more about invoice payment handling.

Error 500: No such tax rate, when adding VAT to line items using Stripe Checkout

I have a stripe-related question. I’m using stripe Checkout and need to include the VAT in the receipt for the customer generated by stripe. I created the tax rate in the stripe dashboard and was also able to see “tax created” in the server logs in the terminal. I then copied the tax rate ID from the stripe dashboard into the line items in the stripe checkout session hash. When I tried to test the checkout process i get an 500 error:
No such tax rate: 'txr_1J0494HS4KRntofdJLdwjrZR'
What seems weird to me is that before there was clearly an interaction with stripe where it stated that the tax rate was created, and now for some weird reason the tax ID is unknown. Has anyone any idea or experience what to do about this? Thanks in advance!

How to prevent shopping cart alterations when payments are asynchronous

The steps below illustrate my problem with Stripe's PaymentIntent flow, but you could come up with something similar for the other payment gateways I've looked at where the final notification of a successful payment is sent asynchronously from the payment gateway to the merchant site.
Customer adds 10 x item A to their shopping cart, total now $100
Customer goes to checkout page. Server creates a Stripe PaymentIntent for the $100 total and sends the 'client_secret' to the browser.
Customer's browser displays the checkout page, showing $100 total, and Stripe's payment form.
Customer opens a new tab, and adds 10 x item B to their shopping cart, total now $200.
Customer returns to checkout tab, and completes $100 payment with Stripe (nothing the site can do to prevent this - it's all happening client side)
Asynchronously, Stripe notifies the site via webhooks that we've got a $100 payment. What do we do now?
The payment total no longer matches the cart total. Do we have to refund the payment and cancel the order? How do we notify the customer? We've probably already shown them an 'order complete - thank you' page, because we had no way of knowing the total was wrong until the asynchronous notification arrived. The customer's probably left our site already. What do we do with their shopping cart?
-- Some further background to all this:
I used to always turn to Stripe whenever my clients wanted to take online payments on their websites, because Stripe's synchronous model made my code nice and easy. The customer would enter their card details, Stripe would then return a token representing the payment, finally my server side code would check all the details were correct, use Stripe's API to collect the money, and return a 'thank you' message to the customer's browser.
But now it seems Stripe are moving away from this model to an asynchronous model (PaymentIntents), where your server is supposed to listen for notifications for completed payments, before fulfilling orders. In Stripe's terminology, we should set up 'webhooks' listening for the 'payment_intent.succeeded' event.
All the other payment gateways I've used in the past also have an asynchronous model, in the sense that your webserver has to wait for some kind of callback from the gateway notifying us of the payment, before we can safely start processing the order. PayPal calls it 'Instant Payment Notification', Worldpay called it 'Order Webhooks', Adflex called it 'Server2ServerNotification'... etc.
Where I'm struggling, is trying to cope with things that might happen during the gap between checkout starting, and payment notification being received. Given that these payment gateways are all using these kind of asynchronous models, there must be a simple solution to this (and similar) problems, but I'm really stuck - any suggestions would be much appreciated.
I think the main point you're missing here is that the PaymentIntent amount is set server-side. This means that when your customer opens a new tab and adds more items to their cart, you should be updating the PaymentIntent on your server to reflect the new amount. Then when they switch back to the other tab and complete the payment, you should have the total amount reflected in your PaymentIntent.
Your customer might still see the checkout process for an amount different to what is actually being charged, in which case I suggest you look at implementing websockets to make sure they always see the total amount in their shopping cart.

Resources