#DanielDeSouza - Checkout + Shipping
1 messages · Page 1 of 1 (latest)
HI 👋
I'm a little confused at the description of the flow. Can you break this down into steps?
Hi.
Sure. Right now I have one development application hosted at https://pablita-website.vercel.app/. Through the website interface clients can add or remove items from the cart.
Now there is one edge case that I have considering the checkout was triggered with the wrong amount of any item in the cart.
Then the client is able to use the checkout page without going back to https://pablita-website.vercel.app/ to update the quantity of any item present in the cart.
But there is a shipping estimative that was created in advance at the checkout session creation that would be outdated with a smaller quantity and therefore potentially the wrong cost.
Okay
- What do you mean "there is one edge case that I have considering the checkout was triggered with the wrong amount of any item in the cart"
- You can always disable the users ability to adjust the quantity
If you need to charge a different shipping rate
1 - Client added to cart 2 mugs and 1 hoodie
2 - Client clicked on Checkout button.
3 - At checkout page at stripe https://checkout.stripe.com/pay/cs_test_<***> client wants to update the quantity
So my question is how do I achieve the intended functionality without deactivating the feature quantity update at Stripe checkout?
But, and correct me if I'm wrong, when the use clicks the Checkout button it triggers the creation of the Checkout Session where you pass in the shipping_options parameter.
Exactly.
But the values you provide should not apply if the user decreases (or perhaps increases) their quantity?
The shipping estimative will depend on size an weight.
Which isn't something we currently support dynamically in the Checkout Session
unfortunately
Is there a way to pass a callback that calculates the shipping estimative? This would be an interesting feature to pursue in case it is not possible at the moment, I think.
I think the best you could do at this point would be to listen for the checkout.session.completed event, then check the Checkout Session object to determine if the user was overcharged for shipping and process a refund.
The website is already listening to checkout.session.completed event. Sometimes items may be removed, sometimes added. Say 10 were added, then a larger box needs to be shipped. In that case, the user would actually have to pay extra for the increased shipping price.
I am looking at integrating the post office API to my application. That is why I am looking to tightly integrate Stripe and the post office APIs in my application in order to provide best possible service.
Those nuances are going to be things you will need to determine for yourself (box size, etc.). So in that case I still think either offering refunds or perhaps using a separate auth & capture approach might work.
You could accomplish the same thing with Checkout using the payment_intent_data.capture_method
https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-payment_intent_data-capture_method
I would rather not increase complexity with creating an extra hold on a payment. I was wondering if I triggered the update shipping rate (the shipping rate created by the checkout session creation) when the checkout page is being displayed to the user if the new rate would be rendered automatically.
If the user has already navigated to the Checkout page I do not think it would re-render the displayed Shipping Rate. But I have not tested that myself. I would want to test that to be certain
Can you test that?
The problem is how would my server understand if it needs to update shipping rate from stripe checkout?
Stripe would have to trigger a update quantity webhook to my server.
Which is why I don't think that is a reasonable solution.
There isn't a webhook for that. That information is not communicated to Stripe until the user submits their payment info
In which case we fall back to providing refunds
So the most elegant solution with the present API would it be payment_intent_data.capture_method?
That is how I would do it if it were me. It does add complexity to your integration but it prevents you from having to issue refunds
can you break it down the necessary steps to make this flow work with payment_intent?
The doc I linked is specific to payment intents.