How to retrieve and set the payment method for Stripe confirmation?

More extensive details on this matter:

I followed @Teodor’s tutorial for custom Stripe checkout with multiple payment methods and it all works fine for card payments, so far so good! :+1:
However for iDeal and sepa_debit payment methods it doesn’t.
Here’s the error output on the checkout page when iDeal payment method is chosen:

{error: {code: "url_invalid", doc_url: "https://stripe.com/docs/error-codes/url-invalid",…}}
error: {code: "url_invalid", doc_url: "https://stripe.com/docs/error-codes/url-invalid",…}
code: "url_invalid"
doc_url: "https://stripe.com/docs/error-codes/url-invalid"
message: "Not a valid URL"
param: "return_url"
payment_intent: {id: "pi_1IpVS1BRuXwUwCNd3Hm4uyNP", object: "payment_intent",…}
allowed_source_types: ["card", "sepa_debit", "ideal"]
0: "card"
1: "sepa_debit"
2: "ideal"
amount: 150000
canceled_at: null
cancellation_reason: null
capture_method: "automatic"
client_secret: "*************************"
confirmation_method: "automatic"
created: 1620639057
currency: "eur"
description: null
id: "pi_1IpVS1BRuXwUwCNd3Hm4uyNP"
last_payment_error: null
livemode: false
next_action: null
next_source_action: null
object: "payment_intent"
payment_method: null
payment_method_types: ["card", "sepa_debit", "ideal"]
0: "card"
1: "sepa_debit"
2: "ideal"
setup_future_usage: null
shipping: null
source: null
status: "requires_source"
type: "invalid_request_error"

So the missing return_url is required for this payment method it seems.
But that parameter can only be used if confirm is set to true:

image

Continuing, when confirm is enabled and a return_url is added, this error is thrown on the checkout page:

error: "You cannot confirm this PaymentIntent because it's missing a payment method. You can either update the PaymentIntent with a payment method and then confirm it again, or confirm it again directly with a payment method."

Hence my question about how to retrieve and set the payment method to make the confirmation work properly for other payment methods than cards?

Any help is very much appreciated :slight_smile: