#kamon_best-practices
1 messages ยท Page 1 of 1 (latest)
๐ Welcome to your new thread!
โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
๐ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1417268837912543394
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
Adding a bit more context here:
The flow I'm essentially looking for:
- Present Payment Sheet to the user
- User enters their payment details
- Confirm the Payment Sheet with
confirmPaymentSheetPaymentto create the PM and have theconfirmHandlercalled. - In the confirmHandler, create the PI with the PM and do junk to the PI
- Display the updated PI junk to the user
- Confirm the PI
Due to the nature of payment sheets, in order for the confirmPaymentSheetPayment to resolve, the intentCreationCallback needs to be called with something, so I'm passing a dummy error ๐
If there are alternatives that allow me to view the created PM on a payment sheet, that'd also work.
I realize that moving the embedded elements likely is the best course of action here, but am trying to exhaust the Payment Sheet route before suggesting a refactor to the team ๐
(even if it's a tad hacky)
๐ I think there are better ways to go about this then sending a dummy error.
That's what I was hoping, but I haven't had much luck.
I tried not calling the intentCreationCallback at all, but unless that method is called the confirmPaymentSheetPayment hangs and never resolves.
Our Paymentsheets intended for a streamlined single-step payment flow, this is kind of working against it's intended use case.
We do however have a two-step payment process that could be used with Element components.
https://docs.stripe.com/payments/build-a-two-step-confirmation?client=react
Correct, Payment Sheets aren't exactly designed for this, but you can specify customFlow as true which allows the flow to be two-step, but the problem there is my flow needs the PM to be attached to the PI
hello! fyi i am taking over the thread, catching up on things now
Hello, thank you, appreciate the help 
yep of course! juggling a couple of threads so it might take me a bit to get back to you
No worries, this is an oddball one too ๐
ok, so i am a little confused as to why you would want to pass dummy errors into intentCreationCallback. what i would do is
- create the PaymentIntent and don't include
confirm: truein the creation request. this will result in a PaymentIntent that you can modify later - actually handle the error if you encounter it
- modify the PaymentIntent as much as you need to
- later separately call Confirm a PaymentIntent
The PI that I'm creating already is not being confirmed server-side, however, the intentCreationCallback confirms the PI (this is why you need to pass the client secret). If I pass an error here, confirmation doesn't happen, allowing me to confirm in another step.
customFlow Payment Sheets typically operate like this:
- Present Sheet
- Customer Enters PM details
- Customer clicks a buy/pay now/etc button that calls the
confirmPaymentSheetPaymentmethod - That method creates the PM and then invokes the
confirmHandlerpassed when init'ing the sheet - The confirmHandler creates the PI and then needs to call the
intentCreationCallbackflow, which will confirm the PI
However, for step 5 I don't want it to confirm the PI, instead I need to display some info to the user and then call the normal confirmPayment method
hmmm.
Actually, looking into it, Embedded Mobile Elements seems to have a similar issue 
have you looked into using setup intents to create the PaymentMethod and then creating and confirming the PaymentIntent separately?
https://docs.stripe.com/payments/mobile/set-up-future-payments
Yeah, there's a chance that may work, but it'd be a bit weird in a flow intended to make direct payment.
On the web with Elements I'm able to create a PM (or confirmation token) and then create the PI before confirming.
On mobile it seems like I can't separate out that flow, I can only create a PI and confirm in the same step.
i feel like there has to be a better way to do this but i am struggling to find it in the docs. give me a bit to test things out
Thank you, you are a saint ๐
I've been banging my head against the wall for a couple days on this lol
intentionally throwing an error feels like a very strange way to handle this even if it works and i would not want to recommend it haha
although i respect your creativity
ok, i am running into the limits of my react native knowledge here so give me a bit to consult with some colleagues
No worries, very much appreciated!!
can you also elaborate on what you mean when you say "do junk to the PI"? what specifically are you doing between creating the payment intent and confirming it?
Surcharging ๐
gotcha, so updating the amount specifically? based on details from the Payment Method?
Take your time, appreciate you digging in here 
do you need to close the payment sheet in between when you collect payment details and when you confirm the payment intent?
In an ideal world, yes, and they'd be able to change the payment method as well.
Are you talking about displaying the updated details in another sheet?
๐ค
i guess i'm mostly wondering what all you need to do in between when you create the PaymentMethod and you finalize all of the details you need for the final PaymentIntent. like, if you have enough information while the user is still in the Payment Sheet would it not be possible to create and update the PaymentIntent before returning the client secret and letting the callback handle confirmation?
Oh, gotcha.
Yeah, if it was possible after the details were filled out in the payment sheet to create the PI and update it, that'd be great.
I actually listen to the form being complete for the web version of this implementation and create a PM and then do the PI stuff
So, if that were possible here, that'd be perfect I think
I really just need to know the payment method information before confirming the intent and capturing payment--that's really it
hmmmmmmm.
Also, at the point, it working with the Embedded Elements would also be great. That was my initial fallback and that isn't working either ๐ญ
i think part of my confusion here is that my team isn't really familiar with surcharging as it's still in preview. any chance you have a contact for this feature?
i am reading up on some of the specific requirements here and i am worried that it just isn't very well supported on mobile currently
but i think we might need to check more with the team who owns the feature to see if they have a recommended path here
Gotcha, yeah, I was hoping as it's more implementation specific and potentially agnostic to surcharging that we wouldn't need to do that ๐ญ
yeah, i think a part of the issue is that mobile's confirmation flows are a little different than web (as you have seen here)
so i think checking with them would probably be the best path forward
i think any of the recommendations i can make right now are going to be a little hacky at best and i don't really want to do that :/
That's fair, this is definitely a curveball! I appreciate the help.
yep of course! best of luck, and thank you for your patience ๐
Hi @urban night I'm taking over this thread. Let me know if you have any follow-up questions.
I think I'm good on my end unless you have any magic solutions to the above, haha
https://docs.stripe.com/payments/mobile/accept-payment?platform=react-native&type=payment#collect-payment-details have you tried the customflow? This allows you to seperate the intent creation and confirmation in two steps
Yeah, that's what I've been doing, the crux is that I need not confirm the PI in the second step and confirm later.
If you use customflow, the payment confirmation happens on your UI and you can display info about the surcharge in your own UI before your customer clicks the confirm button
Correct, but I need to display information after the PI has been created and the PM has been attached to it, but before confirmation.
I believe this is what the customFlow can help you to achieve. Can you share with me some screenshots to help me better understand your integration?
Kind of, custom flow is more so:
- Present Sheet
- Customer Enters PM details
- Customer clicks a buy/pay now/etc button that calls the confirmPaymentSheetPayment method
- That method creates the PM and then invokes the confirmHandler passed when init'ing the sheet
- The confirmHandler creates the PI and then needs to call the intentCreationCallback flow, which will confirm the PI
However, for step 5 I don't want it to confirm the PI, instead I need to display some info to the user and then call the normal confirmPayment method
I found out that I can not confirm the PI if I pass in a dummy error into the intentCreationCallback
But that feels wrong ๐ญ