#Gesundheit-card-PaymentMethod

1 messages · Page 1 of 1 (latest)

minor flame
green thorn
#

sorry i'm back

#

it just doesn't seem to work

minor flame
#

Haha never be sorry

#

Can you remind me how you are creating this PaymentMethod?

green thorn
#

I'm using the "create a subscription through elements" method, and I'm just trying to retrieve the payment method Id from the payment intent

minor flame
#

Do you have the id of a payment method you want to get the card for?

green thorn
#

yeah, it's a card_xxxx thing right

minor flame
#

I was thinking the pm_123 for the payment method

green thorn
#

what i'm doing is basically

  1. get the customer object using the customer's id
  2. get the customer's customer.invoice_settings.default_payment_method_id
  3. get the payment intent of the invoice
  4. get the payment method id of the payment intent
  5. if the two payment_method_ids don't match, then update the customer's with the new payment_method_id
#

am I mistaking payment method for payment_method? I'm starting to feel like they're not the same thing

minor flame
#

Sorry for being imprecise

#

But yes in this case I meant them to be the same thing

#

Can you give me the value of a customer.invoice_settings.default_payment_method_id that you want to retrieve the original card object for?

#

And ah this is so you can check the fingerprint right?

green thorn
green thorn
#

No matter how i try to set it through the dashboard, it's always null.

minor flame
#

I don't think it is settable in the dashboard

#

I think when we talked about the Dashboard before we noticed that that set the default_source correct?

green thorn
#

yeah.

#

Does this mean this is testable only when our frontend is also done?

minor flame
#

Not necessarily, you can set that field with the API now.

green thorn
#

which is what we're doing here -- using the API to get, and set that property if it doens't match

#

It's not a problem if initially the value is null, since a new customer will always have a null value to that

#

so the next question is the payment_intent's payment_method is also null for some reason

#

if you want the PaymentIntent Id

#

here's a snippet of what i got from the PaymentIntent (thru CLI). This also indicates that the payment_method of the intent is not set, but instead the source is set.

minor flame
#

Right, so that is just what the Dashboard does, unfortunately we can't set the invoice_settings.default_payment_method_id property there.

#

If you use the CLI/API to set it otherwise I think that will fill out the field that you want

#

I know we discussed setting it and doing this check in webhooks before but you can do it outside of that for your testing right?

green thorn
green thorn
#

--
On a second thought, maybe it is because the dashboard only allows me to set to the source of a customer, which would lead me to the series of problems

#

It was never going to work in the first place

minor flame
#

And you were talking about setting this in the invoice.paid event right?

green thorn
#

yep

minor flame
#

You can still use what the Dashboard does I believe

green thorn
#

but the subscription is paid using an order of sources. If the dashboard will only set any card to the source instead of payment_method, then i'm never going to get anything from payment_method

minor flame
#

So you are only ever setting this via Dashboard? I thought you were taking in payment info initially when setting up the subscriptions correct?

green thorn
#

yeah. but i'm testing that's why

#

we don't have our front-end ready yet

minor flame
green thorn
#

but is that how purchasing a subscription will behave?

green thorn
minor flame
#

I mean to initially set this

#

Can you remind me how you are setting up these subscriptions?

green thorn
#

When listening to invoice.paid event, I check whether the billing_reason is subscription_create or manual.
if it's either one of the two, then I also take the PaymentIntent ID to fetch the payment_method.
I take this payment_method and do fingerprint comparison with that of the customer's. The rest you know already

minor flame
#

Okay I see. Apologies I see where you specified this and I missed it

#

So when you get to the step where it wants you to look at invoice_paid or invoice_succeeded and you check that Invoice's PaymentIntent's PaymentMethod, is that null?

green thorn
#

yep

minor flame
#

Interesting. And you are passing the card and billing_details in to the payment_method parameter of your confirmCardPayment call>?

green thorn
minor flame
#

Right. You've said that. Caught up.

green thorn
#

creating a customer that's solved

#

do you mean by i need to explicitly call to create a payment method first, then create the subscription afterwards?

minor flame
#

I mean in this test case yes

#

So because you don't have the frontend you will need to do some other API noodling to get a Subscription set up and paid for similarly

#

Which actually needs one last bit of detail:

#

Actually do you know what might be even easier?

#

OR

#

Apologies for taking a bit to get there.

green thorn
#

cool, i'll take a look at these

#

well, we're aiming to use elements -- more customizable