#Cocochief - Payment Request Button
1 messages · Page 1 of 1 (latest)
Hello again! Changing the example is beyond the scope of what we can help with. You would need to have a developer write the code you need.
We're happy to answer questions about your code if you're stuck or blocked, but we can't write your integration for you. 🙂
Hi... Sorry. I am the developer working on this. We currently already have working code for card payment, where we confirm the cardSetup successfully.
stripe.confirmCardSetup(setupClientSecret, {
payment_method: {
card: cardElement,
billing_details: {
},
},
The part that's confusing for me is that in Step 5 of the example I sent out. It calls confirmCardPayment with handleActions:false then calls confirmCardPayment again once the first call comes back.
Looking at the documentation it's not clear why that is, and if I can just set handleActions:true right off the bat and finish the payment setup.
Instead of specifying the cardElement when you call confirmCardSetup you would specify the Payment Method you get from the Payment Request Button.
Like this:
stripe.confirmCardSetup(setupClientSecret, {
payment_method: paymentMethodIdFromPaymentRequestButton,
},
Yes that part I got. Here is the code snippet that I have.
My question is specifically, do I still need all that stuff from line #181~196 where I confirm (or setup) the card again?
That section is currently copied verbatim from the example.
I guess line #187 specifically.
On line 185 you're trying to access confirmResult.paymentIntent.status, but there is no confirmResult.paymentIntent because this is a Setup Intent, right?
And then on line 187 you're calling stripe.confirmCardPayment, but that can't be used with a Setup Intent and no payment is being taken at this time, correct?
Well, no, you should change it so it works with Setup Intents.
mm... So, I still need to call confirmCardSetup twice? Once on line #169, once on #187?
Yeah, if the status of the Setup Intent requires it.
Also, would I need to add handleActions: false to the call on line 169?
Yep, was just about to call that out! https://stripe.com/docs/js/setup_intents/confirm_card_setup#stripe_confirm_card_setup-options-handleActions
So, I can't just let Stripe handle it for me in this case?
Stripe is handling it, it just can't handle it while the payment sheet is displayed.
If a next action is required you need to dismiss the payment sheet and call stripe.confirmCardSetup again so the authentication modal can be displayed and interacted with on the page.
That can't happen if the payment sheet is covering up and preventing interaction with the page.
Does that make sense?
let me read the documentation real quick...
Is this because payment request will show an UI on top of my web page?
That's why I have to manually control this?
Yeah, I've never actually tried it out but I'm pretty sure things will break in some way if you try and trigger + display Stripe's next actions while the payment sheet is still up
Yeah, testing these is pretty challenging... Please give me a minute..
OK - I just ran a quick test, and it seems to be ok. Will need deeper testing later...
I did come across a new issue, though
Since we are a subscription service with a free trial, we are actually wanting to setup the payment on the customer to be charged for the future. However, right now it's showing this on the payment request popup
I am assuming that $7.99 showing is because in our request setup, we set the amount to 799 in this portion of our code.
My question is, should I me setting the amount to 0 instead? Since we have a 7-day free trial, and we only start changing them monthly (or yearly) after the trial is over.
charging, I meant.
Yeah, I believe setting the amount to 0 is exactly what you want to do
You could also leave the amount as is (not 0) and add additional details in your label like "7 days free" to specify that you will be charging them this amount after 7 days
Sorry, had to run a quick errand. Do you know if there is anyway I can change the text in my screenshot that says "Pay account-dev.wonsterwords.com" to something else?
In the documentation, I only see "label" option. Which I have already set to "Total" (which actually didn't show)..