#bruno - Subscriptions
1 messages · Page 1 of 1 (latest)
Hi there!
Okay so the customer uses are card that requires 3DS authentication (requires_action) and you want to add another card instead?
Yes.
In that case I would use a new SetupIntent and then set the PM that gets created as the default for invoices for that customer
Hm, okay. Actually I'm doing that already. But then immediately after setting a payment method as the default I try paying the open invoice (related to requires_action PaymentIntent).
The problem is: when I use a card that errors (for example 4000008260003178 - errors with 'insufficient funds) - I'm getting an error when attempting to immediately pay that open invoice.
I know I kinda expanded my scenario here, but do you know of a solution for that?
Sorry but now that's kind of really confusing
Can you explain exactly what you are doing (in chronological order) and what you expect to happen?
Ok, gimme a second to write it all out then.
- I'm using a
4000002760003184card when creating a new subscription. The customer confirms the payment online. - I'm using Test clocks and advance the time to 1 month + 1 day in the future. At this point another recurring PaymentIntent is created. It's status is
requires_action, and the accompanying invoice is not paid. - The app user is brought online and they see a message "Please confirm card payment" in my app. Instead of confirming the payment with an existing card, the user wants to add another card.
- When adding a new card the customer uses
4000008260003178card number. On the backend, I'm creating SetupIntent for setting up a new card. On the frontend I usestripe.confirmCardSetup(...). - After successful
stripe.confirmCardSetup()on the backend I'm setting up the payment method to be the default payment method for all invoices.
Stripe::Customer.update(customer_remote_id, {
invoice_settings: {
default_payment_method: remote_id
}
})
- After this, on the backend I attempt paying the invoice associated with PaymentIntent which
requires_actionstatus. This way the customer's open invoice is paid immediately after they add a new card to their account.
This last step errors because4000008260003178card is used.
Hopefully the above steps explain what I'm trying to do: I want to attach the new card to the existing Stripe customer AND also pay the open invoice with requires_action PaymentIntent. Ideally, the card would not get attached to the customer AT ALL, if the requires_action PaymentIntent is not paid.
Do you have any advice for the above scenario?
@smoky nymph just curious, do you have any thoughts on the above? Thanks!
Yeah sorry, it's been busy
If you never want to try confirming cards that result in a requires_action status, I think you'll get caught in a SetupIntent loop
Hm, and by "SetupIntent loop" you probably mean the scenario I explained above, right?
Well if you keep using test cards that require authorization for each charge
Okay so let me step back once again because I think I got lost there. In your use case you would not want the PM to attach in the first place? So even in the initial scenario? But banks can request additional authentication at any time for any reason they want. That's why we make the test cards that require additional authentication even if they are set up for off-session payments.
Hello! I'm taking over and catching up...
To clarify, is my understanding correct that you want to avoid attaching PaymentMethods to Customers when the initial payment fails for a reason other than authentication being required? In your example the specific reason is insufficient funds, but you also want to include other declines in that scenario, right?
@wet token You still there?
Hi @chilly wigeon , yes I'm here. Let me answer your question.
To clarify, is my understanding correct that you want to avoid attaching PaymentMethods to Customers when the initial payment fails for a reason other than authentication being required?...
Yes, that's correct. I want to avoid attaching PaymentMethod to Customer in this case because of 'insufficient funds' error, but also include other declines.
And also, ideally the invoice related to requires_action PaymentIntent would be paid if the card is attached successfully (and there are no errors).
There's no fully-automatic way to do what you want, but what I would recommend doing is attempting the payment first on the PaymentIntent with setup_future_usage set, before attaching the PaymentMethod to the Customer. You can still attach the PaymentMethod to the Customer after the transaction completes successfully: https://stripe.com/docs/api/payment_intents/create#create_payment_intent-setup_future_usage
Ok, that makes sense.
Alternatively, you can attach ahead of time, but then detach PaymentMethods which fail: https://stripe.com/docs/api/payment_methods/detach#customer_detach_payment_method