#erik_paymentintent-twosteps

1 messages ยท Page 1 of 1 (latest)

solemn vaultBOT
#

๐Ÿ‘‹ 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/1304471137693995028

๐Ÿ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.

midnight sparrow
#

Primary issue is that I can't pass this to paymentMethodOptions in the Elements component

const options: StripeElementsOptions = {
    mode,
    // setupFutureUsage,
    amount: amountInCents,
    currency: currencyCode,
    paymentMethodCreation: "manual",
    loader: "always",
    paymentMethodConfiguration: paymentMethodConfigurationId,
    onBehalfOf: vendorId,
    paymentMethodOptions: { card: { setupFutureUsage: true } } // does not work
  }
forest violet
midnight sparrow
#

I'm not sure it's expected and I understand that Affirm doesn't support future usage.

Like I mentioned before, I was able to make this work by creating the payment intent upfront, specifying payment_method_options: { card: { setup_future_usage: true } }, as part of the intent payload, and then using a clientSecret to initialize the Elements component.

#

creating the payment intent upfront allowed me to have setup future usage work for the credit card AND also show Affirm without future usage.

forest violet
#

Did you attempt to process the payment with Affirm in that flow?

midnight sparrow
#

Yes ๐Ÿ™‚ That's the way it's working in production right now.

forest violet
#

Can you share an id with me?

midnight sparrow
#

One second

#

Would a payment intent ID work?

forest violet
#

That works, I'm testing this on my end in the meantime

midnight sparrow
#

pi_3Q9qxXHDgd7YgnZu1PJr1f18

#

req_1RTQKOwfMlACPF

forest violet
#

Oh, you're setting the setup_future_usage within the card payment method and not on the main level. Ok, that makes sense.

midnight sparrow
#

yep

#

I want to replicate this with a two step checkout workflow.

forest violet
midnight sparrow
#

๐Ÿ˜ฆ

#

Well, good to know that I've hit a brick wall at least. Thank you for responding.

forest violet
#

I think your flow makes sense where you want to show both payment methods but only use setup future usage for card payment methods only. The above flow was build so merchants can add more logic in their flow. For instance, if they provide a certain payment method, they would inspect the payment method and decide not to proceed with the payment for instance.

midnight sparrow
#

I have a followup - please don't lock the thread yet.

forest violet
#

Sure!

forest violet
#

@midnight sparrow checking in here, can you share your follow-up question here?

midnight sparrow
#

For context, the reason I need a two step workflow is because I want to update the payment intent with a dynamic application fee because on the payment method used. If Affirm is used, I want to charge a higher fee rate.

#

One option that comes to mind is to add a listener to the elements component and send a request to the backend API to update the payment intent based on the payment method being used.

#

What are your thoughts on that?

forest violet
#

You might get an error stating there there is a mismatch, you can test it on your end to confirm

midnight sparrow
#

Mismatch on what?

forest violet
#

Oh wait, you're saying you would update the PaymentIntent with an Application fee?

midnight sparrow
#

yes

forest violet
#

Yeah, you can test that. I was thinking you might change the setup future usage, and that might erorr out.

#

If you're updating the amount it's different

solemn vaultBOT
forest violet
#

Sorry for the confusion

midnight sparrow
#

I wouldn't be changing the setup future usage, just the application fee.

strange bobcat
#

erik_paymentintent-twosteps

midnight sparrow
#

Any other options I should consider for dynamically updating a payment intent's application fee based on which payment method was used?

strange bobcat
#

Sorry, is the option we gave you not working? Do you have an exact error where it doesn't work?

midnight sparrow
#

Which option are you referring to?

#

One option that comes to mind is to add a listener to the elements component and send a request to the backend API to update the payment intent based on the payment method being used.

this was my suggestion and I was asking if there are other alternatives to consider ๐Ÿ™‚

strange bobcat
#

You were talking with my colleague and they seemed to align with you on next steps and told you to try it

#

1/ Render PaymentElement
2/ Create a ConfirmationToken
3/ Go to your server, inspect it, decide on your ApplicationFee amount based on the payment method chosen and confirm the PaymentIntent

midnight sparrow
#

I was asking something slightly different.

#

It doesn't work because I have a further requirement of dynamic payment methods. Unless you have a different idea that I can try for my original inquiry, I will have to resort to updating the payment intent's application fee in response to the change event on the Elements component.

strange bobcat
#

I have a further requirement of dynamic payment methods
what does that mean?

#

Okay I read your original question and I get the problem now.

midnight sparrow
#

There's context in the thread above ๐Ÿ™‚

#

If I can clarify something not already written above, happy to do so

strange bobcat
#

So yeah the change event is the only thing I can think of

midnight sparrow
#

cool, glad we're aligned there.

#

thanks for your help