#yurt_ideal-sepadebit
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/1432767460288888945
📝 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.
- yurtdweller_api, 41 minutes ago, 7 messages
- yurtdweller_api, 4 days ago, 16 messages
- yurt_subscription-invoice, 6 days ago, 34 messages
Can you share the request ID (req_xxx) of the error? Here’s how you can find it: https://support.stripe.com/questions/finding-the-id-for-an-api-request
req_lRlYxi4UgRzEfN
The error was due to incorrect payment method used. For bancontact, generated_sepa_debit should be used, not the direct payment method ID. For example, the generated_sepa_debit associated with pm_1SNFgaEXjRBPmDmBHbqXMwyQ should be pm_1SNFgjEXjRBPmDmBjStiiGVp
This is explained in https://docs.stripe.com/payments/bancontact/set-up-payment?platform=web&payment-ui=stripe-hosted#charge-sepa-pm
In addition, I'd recommend using Setup Intent to attach the payment method to the customer instead of using payment method attachement API: https://docs.stripe.com/payments/accept-a-payment-deferred?platform=web&type=setup
So the use case is this - the Payment Elements saves the payment method on the customer, but then in a webhook I need to set it as the default payment method for the customer and the subscription.
That sounds right to me. The error was thrown on saving the payment method to the customer, which incorrect payment method ID is used to attach to the customer. By using generated_sepa_debit, you should be able to attach the payment method successfully
Are there other payment methods that have special rules?
We don't have a comprehensive doc for the special rule. I'd recommend checking the payment method doc individually. As far as I'm aware, iDEAL also has the similar rule: https://docs.stripe.com/payments/ideal/save-during-payment?platform=web#web-charge-sepa-pm
How do I check the SetupIntent for the type of the payment method?
i.e. how will I know it's a BancCard or a iDeal?
I'm using a Checkout Session to generate the client secret I need for the Elements API because I need to be able to show Tax ID element in the proper countries as well.
I'm not sure how to use the SetupIntent to attach the payment method to the customer?
I'm retriving the Payment Method like so:
const setupIntent = await stripe.setupIntents.retrieve(
session.setup_intent.toString(),
{
expand: ['latest_attempt'],
}
);
const paymentMethodId = setupIntent.payment_method?.toString();
I'd recommend expanding the payment_method field. The payment method details will be available under payment_method field after the expansion
Will I still need to get the generated_sepa_debit from latest_attempt then?
I guess I'm confused as to how expanding the payment field will attach it to the customer
yurt_ideal-sepadebit
Expand is used to see the generated PaymentMethod. It should be attached automatically
You need to make sure that your original SetupIntent has the Customer id in the customer parameter, is that the case?
I think it does
Is this the right expansion declaration?
const setupIntent = await stripe.setupIntents.retrieve(
session.setup_intent.toString(),
{
expand: ['latest_attempt', 'payment_method'],
}
);
depends what you are trying to look for. I recommend you run that request, look at the response and then see if you get what you need first
OK, I am looking at it right now
yeah I see that it has the same issue, generated_sepa_debit only seems to come from latest_attempt
what is "the same issue"? Like what exactly isn't working for you?
On my backend, I am creating a checkout session in setup mode to create a secret for the frontend to use the Payment, Address and Tax ID elements with stripe.js
Then, I listen for the event webhook for checkout.session.completed, where I would like to:
- Update the payment method to be the default payment method for the customer
- Update the subscription default payment method
- Check if a subscription is paused, if it is, resume the subscription, and charge the default payment method for the generated invoice
I was relying on the setupIntent.payment_method ID as the ID to set the to the default payment method for the customer and the subscription
This seemed to work fine with US credit card testing, but once I tried using a Bancard is when I ran into the issue that I need to use a different ID.
When I expand payment_method, the id is still not the correct one.
So I am wondering if I conditionally change the payment_method_id only for paymentMethod.type === 'bancontact' and paymentMethod.type === 'ideal' to use generated_sepa_debit, and if all others will work with just the payment_method.id?
gotcha, thanks for the clear summary!
And yes that would work for iDEAL and Bancontact in that case! Most are the SetupIntent's payment_method but in that case it's a separately generated one
I suppose I am wondering if I am approaching this the right way. Is there another way to save the payment method as the customer default using the Stripe Elements settings, or the Checkout Session creation settings?
Not in that specific flow. What you are doing is correct though a bit convoluted for sure
Is there anything in this specific setup that would prevent the use of these saved default methods (bancard and ideal) for charging the generated invoice for a subscription resuming from a paused state?
no it should work fine. You should be able to test all of this in Test mode too
OK, I will try this and see if it functions properly
Just to be clear - there is no need for manually attaching the payment method ID to the customer with this workflow, correct?
correct