#ironbeard-testing billing
1 messages ยท Page 1 of 1 (latest)
๐ happy to help
could you please share the request id for this? here's how you can find one https://support.stripe.com/questions/finding-the-id-for-an-api-request
Find help and support for Stripe. Our support center provides answers on all types of situations, including account information, charges and refunds, and subscriptions information. Get your questions answered and find international support for Stripe.
Sure, one second
So let's see. Customer is update/created with req_WxdNnU6AJhjX8a, then Subscription updated/created with req_uhziwQYlHREykI, then PaymentMethod updated/created with req_FtVltKetfBch2i
I'll take a look
thanks ๐
you have set the invoice_settings.default_payment_method for the customer to be the 4242... card. This is why you're not getting any declines
Oh, so even though the card that was input in the form should decline, Stripe is using the default PM from a previous time?
that makes sense. thanks ๐
let me know if you need any more help
I think I should be good. So if I want to change it to not use the default payment method, when would I do that?
you need to update the customer and set the invoice_settings.default_payment_method to the new payment method
please note that you should be using this card instead 4000000000000341
Decline after attaching
you can use the magic string pm_card_chargeCustomerFail which will do the trick
Gotcha, and I would do that before creating the Subscription? or after? Sorry, lots going on in my head right now.
I get the client_secret to pass to the front end after updating/creating the Subscription
oh wait
are you using the latest_invoice.payment_intent.client_secret to pay the Subscription?
Oh, yes.
Sorry should have specified that. I remembered I was doing something kind of different than usual
So, I guess the latest_invoice will be using the default PM, not the one I'm entering in the Card Element?
I think so, but I'm trying to dig a little deeper
what I would suggest to do is to start fresh
with 2 new customers
and try to set the invoice_settings.default_payment_method for each
one failing and one succeeding
and testing
Gotcha, so create two new users, one using e.g., 4242 4242 4242 4242 and the other using 4000 0000 0000 0341?
and then try to update/add to the 4242... subscripting and use the ...0341 card?
for your subscription
yes you can create the subscriptions and they will automatically succeed for the first and fail for the second
Gotcha. Gonna try that and will see what happens. Thanks ๐
When does PaymentMethod attaching happen? Not sure if this is an obvious question, or something that changes a lot depending on my flow
A PaymentIntent can have a Customer and a PaymentMethod (which can be null). If I PaymentMethod is attached to a Customer, does it have to have a PaymentIntent?
๐ stepping in here as tarzan had to step away.
There are 3 main ways you can attach a paymentmethod. When you confirm a PaymentIntent that is created with setup_future_usage, when you use a SetupIntent, or you can just attach it directly to a customer using https://stripe.com/docs/api/payment_methods/attach
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
So I believe all the PaymentIntents I'm creating have 'off_session' has setup_future_usage
I'm using the PaymentMethod.attach method
Ah you are building a subscription flow
So we actually just added a new parameter to our Subscription creation that makes this much easier: save_default_payment_method: https://stripe.com/docs/api/subscriptions/create#create_subscription-payment_settings-save_default_payment_method
When you create the Subscription you set that to on_subscription and then when you confirm the initial PaymentIntent for the Subscription the paymentmethod will be automatically attached to the customer and set as the default for the Sub
Will that work if I'm updating a Subscription? in my flow, every user can only have on Subscription (with multiple items) and if they go through the payment process again at a later date (and use a new card), then I'm updating the subscription with new items
and would want to use the new card, that was input in the Card element
I believe it does, yes! I haven't actually tested that though. When you update the Sub you would also pass the setting (https://stripe.com/docs/api/subscriptions/update#update_subscription-payment_settings-save_default_payment_method) and then I believe if you use a different card that would replace the default going forward.
Gotcha, I'll look into those docs a bit more, thanks ๐
Would I need to possibly update the python lib to use this?
cool cool, wasn't sure if it just passed through, will look for an update.
Thanks for all your help ๐
Of course!
Okay, I think I've almost figured it all out ๐
- Create/update a Subscription (Customer + items (Prices)), also pass through
payment_setting={'save_default_payment_method': 'on_subscription'} - Retrieve the Subscription with
expand=['latest_invoice.payment_intent.payment_method'] - This gives me
payment_intent['client_secret']which I return to the front end and then use Stripe.JS'sstripe.confirmCardPayment
So my question lies between 2 and 3: How do I detect the declined card? I still get a client_secret with the insufficient_funds card, right? I'm under the impression that I should be able to determine if the card failed before stripe.confirmCardPayment in the JS, is this right or wrong?
Nope, the decline will be synchronous when you call stripe.confirmCardPayment
So you would prompt for a different card if they hit that decline
Gotcha. Is the decline something that Stripe Elements should be handling, in the same way that it handles bad exp dates?
Yep. The promise will resolve with a result.error which you then display the message to the customer.
If you take a look at our card element guide (https://stripe.com/docs/payments/accept-card-payments) you will see that there is client-side error handling.