#penguin420_

1 messages · Page 1 of 1 (latest)

native ravineBOT
tight portal
#

hey!

sharp sonnet
#

Hey there, you can get the last 4 digits of a card payment method within the payment method object:

tight portal
#

how tho?

#

i want to get it later

sharp sonnet
tight portal
#

wait

sharp sonnet
#

Well, what are you trying to do?

tight portal
#

can i get it here?

#

on the webhooks.js file

#

in*

sharp sonnet
#

Not in that webhook, no. It would also be available on the latest_charge if expanded, but this is not exapnd in webhook event data.

tight portal
#

how then i dont get it

sharp sonnet
tight portal
#

where do i get the charge id

sharp sonnet
#

From the payment intent latest_charge property

#

paymentIntent.latest_charge eg

tight portal
sharp sonnet
#

The charge will be a different one each month -- you might want to refer to the payment method configured for the subscription payments in that case

#

Either subscription.default_payment_method or customer.invoice_settings.default_payment_method depending on the details of your integration

tight portal
#

wait is there a webhook that posts when it is updated

#

how do i retrive a subscribtion

sharp sonnet
#

When what is updated?

tight portal
#

the payment method

sharp sonnet
#

Take a step back, what are you trying to achieve?

tight portal
#

right

sharp sonnet
#

What are you looking at / starting from, and what are you trying to get?

tight portal
#

so on the user's dashboard, i want to show there default payment method ( on my site )

#

In the billing block

sharp sonnet
#

Ok, and where are you saving that currently?

tight portal
#

I am not

sharp sonnet
#

On the subscription or the customer settings?

#

You must be, in order for the subscription to auto charge on renewal

tight portal
#

I am not saving there card last 4 digits etc

sharp sonnet
#

The payment method i mean

tight portal
#

I do not save that

#

once they pay

#

this is what happens

sharp sonnet
#

How are you creating the subscriptions?

#

Can you share an example subscription ID?

tight portal
#

ohhh

#

like that

sharp sonnet
#

that line save_default_payment_method: 'on_subscription'

#

means you're saving the payment method on the subscription (as default_payment_method)

tight portal
#

wdym

#

do you have a code example

sharp sonnet
#

So you'd retrieve the subscription, look at the default_payment_method and either retrieve that or expand it in your subscription retrievakl

#

Or retrieve the payment method separately

tight portal
#

i want a new endpoint

#

to retrive it

tight portal
#

thanks

sharp sonnet
#

I see you're typing in the main channel again -- if you have more questions you can ask them here

tight portal
#

also i didnt mean to lol

#

accidently pasted there

sharp sonnet
#

NP!

tight portal
#

how do i get that id

sharp sonnet
#

What do you mean?

sharp sonnet
tight portal
#

@sharp sonnet "id": "sub_1NdHY9L6k3oFrmnnaI81PhZm",

#

does this ever change

#

*if they dont cancel subscribtion

sharp sonnet
#

No, the subscription ID does not change

tight portal
#

and

#

how do i get the subscribtion id

native ravineBOT
magic violet
#

The PaymentIntent has an invoice property which has a subscription property that is the ID of the subscription that the intent is from

#

It may be easier for you to listen for the invoice.paid event, that event will have the subscription ID already on it and also signals the success of a subscription payment

tight portal
#

Could you provide a way to lookup invoice to get sub id

magic violet
#

I'd recommend running this code yourself to see how it works

magic violet
#

I didn't mention a session ID, that doc section shows how you can expand the properties of an object that you are getting back in your response. In this case, you can expand the payment intent's invoice so that you can see the subscription it was a part of.

I'd suggest slowing down and being more careful about what you are doing with these tests and reading more of the docs to understand how these API calls work. Like maybe here just try retrieving a payment intent and expanding the invoice, then look at the data you get back and then move from there.

tight portal
#

sorry, @magic violet is tehre a way to get a subscribtion by customerid