#Carlos Mascarenhas — payment method must be attached
1 messages · Page 1 of 1 (latest)
Ah, so have you called the attach method to attach the PM to the customer? https://stripe.com/docs/api/payment_methods/attach
no
I called the signature update method
to attach a new payment method to the subscription
As the error says, the PM needs to be attached to the customer. If you make that call and then try to update the subscription again that call should work
To be attached to the subscription, the payment method needs to be attached to the customer that the subscription is for
Can you link to the URL?
I tested this implementation yesterday and it had worked correctly
req_MkyedUVDqE7CLQ
Thanks. I have been looking in to those. Still looking.
Hi Carlos. To set the default payment method on a subscription, it must be already attached to the customer
Can you provide the request ID where it worked yesterday? Most likely the payment method used was already attached to the customer
Shouldn't that be in the example then?
The example flow should work. Trying to see what might not be lining up here
The example says to update the subscription payment method
I do not have
Looks like you made a request at some point to detach the payment method. That's why it's breaking: https://dashboard.stripe.com/test/logs/req_mjjA6kYOv4VV9i
Says it was done through the dasboard
I just did it through the panel, I did it manually since the api wasn't working
For creating signatures I follow the example model
At no time does the example ask to attach the payment method to the customer, only in the signature
The card should automatically be attached in this step: https://stripe.com/docs/billing/subscriptions/build-subscription?ui=elements#collect-payment.
I'm using confirmCardPayment
Good to know. Will see if I can recreate with that.
I will create a new client and a new subscription and test again
same error occurred
I create the customer without payment method
create signature
then capture the payment method and confirm using confirmCardPayment
I get the webhook event, I try to attach the payment method to the subscription and the same error occurs
The customer does not have a payment method with the ID pm_1KK7qNANR34g5yeQDRfo8e7Y. The payment method must be attached to the customer.
req_NM0yt58eTEnfQJ
This call is working for me with the flow from the docs. Checking in to what the difference is here
Ok
Did you find out anything?
👋 I was working with @cyan dust on this and we did find the issue, let me explain quickly
The problem stems from the fact that you pass off_session: true on Subscription creation. This is uncommon with default_incomplete usually since if you're "off session" at that point you already have payment method details saved on the customer. IF you don't you have to ask the customer which means you're not off session, they are on session ready to give them to you
So in that situation, the Invoice's underlying PaymentIntent is not configured to "save" the payment method. We think it's a small bug and we're going to look into fixing it.
But why are you using off_session: true in this flow?
in no time i send off_session: true
https://dashboard.stripe.com/test/logs/req_Fn5Dsqv7eJoYfs look at this request you will see the off_session: true parameter that your code sends
I found the problem
I see you seem to use Laravel, so Laravel does that for you maybe? They are a third-party system so maybe it's their default
ah nice
And really, this should still work so we do think it's a bug, just not one we had noticed before. We're going to still get it fixed
I'm using laravel cashier under the hood it's sending
To solve the problem for now should I send off_session=false?
The real question is: is the customer going to enter card details or do you have them already? If it's the former, then just don't send the parameter at all (but sending false works too)
The customer will enter after creating the signature
I will send off_session = false then
yes that will fix your problem
Thanks a lot for the help