#issambd - Reuse Payment Methods

1 messages · Page 1 of 1 (latest)

light cairn
feral solar
#

this is the cusomer : cus_KxVqbdBqfYItfC

#

this is the pm : pm_1KHcTfLzSPzAEiPD2HpWj3Fy

#

the request : req_maKkMx8m4VzYQn

bold quail
#

can you say more?

#

how are you paying? in which contexT? which URL are you on?

feral solar
#

the pm was added using setup intent for a subscription

#

this is the hosted invoice

bold quail
#

so you're trying to pay on that page? That shouldn't have a saved card so I'm confused

#

can you share a screenshot of what you see?

feral solar
#

yes it does have a saved card, but when I click on confirm payment the error appears

#

sending screenshot

bold quail
#

yeah there's no "confirm button" and that PM is not on the customer so I don't really follow what you describe

feral solar
#

my dahsboard is showing otherwise

bold quail
#

I just tried to pay that invoice and it worked

#

I don't understand which page you are on

feral solar
#

That is weird, now it says that it is paid

bold quail
#

yeah since I paid

#

Can you do another invoice and take detailed screenshots before/after

#

I don't get how you end up with that "pre-filled card"

feral solar
#

I literally just refreshed the page

#

wait you used a different card to pay

#

I am using a card that requires 3d authorization

#

lemme try to reproduce the error again

charred fjord
#

Hello! I'm taking over for @bold quail, getting caught up now...

feral solar
#

Hello, thank you

#

I just tried to reproduce the error, the authorization and payment went smoothly, it's weird the I got that error earlier

#

you can still see the error on the screenshot or if you check the request, I sent the ID earlier

charred fjord
#

Okay, so you created a Customer, created a Subscription for that Customer, created a Payment Method... I think I missing a piece. Do you have the request ID where you attached the Payment Method to the Customer?

#

Oh, never mind, I found it. You specified a Customer when you created the Setup Intent...

#

Let's see here...

feral solar
#

I was mid testing different cards so sorry for the messy logs

charred fjord
#

No worries.

#

So it makes sense that it would fail with that error, as it has been detached.

feral solar
#

So there is no way to pay an invoice using the host invoice link after detaching that pm that was assigned to the invoice?

#
                        var options = new CustomerUpdateOptions
                        {
                            InvoiceSettings = new CustomerInvoiceSettingsOptions
                            {
                                DefaultPaymentMethod = 
newPaymentMethode.Id
                            }
                        };
#

this is how I am making the pm default

charred fjord
#

Detaching a Payment Method from a Customer means it can no longer be used for any purpose.

#

It's similar to deletion, except we keep it around for record keeping/archiving purposes.

feral solar
#

and doesn't the hosted invoice url use the new default pm ?

charred fjord
#

It should, yes, but you would need to reload the page after the changes are made.

feral solar
#

nope, didn't work, I just reproduced the error

#
  • created an invoice with the default pm
#
  • dettached the pm and attached a new one
#
  • opened the invoice
#
  • opened the invoice
#
  • tried to pay, error
charred fjord
#

Ah, okay, I can reproduce the error on that page. Hang on while I investigate. Please do not alter this Invoice, Customer, or anything else associated with it. 🙂

feral solar
#

yes sir

charred fjord
#

We're still investigating this, but in the meantime can you tell me why you're detaching these Payment Methods before the Invoice is paid? What's your use case?

feral solar
#

our db model dictate that we save one pm methode per user, so when a user adds a new pm, that's the new default and the old one should be dettached

#

a new payment methode is for example added when an invoice can't be paid due to insufficient funds

#

so a user adds a new pm to pay that one invoice

charred fjord
#

I strongly recommend against that. Can you leave the previous one attached and set the new one as the default in the Customer's Invoice settings?

feral solar
#

If that's the only possibility there is, but does that mean the invoice will be paid using the new pm ?

#

there is usually a good reason the customer changes their pm, so there is no point for keeping the old pm if it does not work

#

FYI, in my previous implementation the pm would be attached to teh subscription object, as we only allowed a costumer one subscription, but a colleage of yours (in a previous conversation) suggested that it's good practice to attach the pm to the customer instead

#

in that implementation this error did not occur

charred fjord
#

The Payment Method needs to be attached to the Customer regardless. A Payment Method can only be reused if it's attached to a Customer.

#

It does not need to be their default, though, just attached.

feral solar
#

so what do you suggest ?

charred fjord
#

Just to make sure I understand your desired flow: you want to have only a single Payment Method attached to a Customer at a time, and there are situations where your Customers will have an outstanding Invoice and replace their Payment Method with a new one before paying that Invoice?

feral solar
#

exactly

charred fjord
#

Gotcha. Give us a few minutes to discuss/investigate internally.

feral solar
#

okay thank you

charred fjord
#

Okay, so we're going to work on improving this on our end so detaching a Payment Method prevents the Invoice payment page from showing it sooner. Of note: the Invoice page will eventually do the correct thing, it's just not immediate. The link you provided earlier where you could reproduce the error is now showing a payment form, for example.

#

I can't say when this will be fixed, so in the meantime I recommend either leaving the Payment Methods attached if possible or waiting a while between detaching and sending them to the Invoice page (which may not be practical).

feral solar
#

alright, I'll try to find a way around it

#

thank you for your help

charred fjord
#

Happy to help! Sorry about the trouble!