#bilalsaeedalam
1 messages · Page 1 of 1 (latest)
Hello! We'll be with you shortly. Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- bilal-customer-paymentmethod, 1 day ago, 11 messages
- bilalsaeedalam, 2 days ago, 11 messages
Hi, let me help you with this.
activated for charging payments
What do you mean by that exactly?
What are you trying to achieve on a high level?
Ok, basically if my customer attaches his card details and then removes it and then attaches new card info, and then when i call this API to get which card is he using now. Is there any key where i can set check to get that object
What do you mean by "using now" exactly? What's the default? Default is only used for Invoices/Subscriptions.
Just let me know if user remove his payment method it will clear from STripe too
I don't know how your customers are able to do this in your application and how is it connected to Stripe, so it's hard for me to answer this.
Okay, i will make it easy, First, i create a Session where i take customer card info with Stripe Payment Method, and on success, I call retrive Session API and store the setup Intent id to our database. When i need to charge i charge payment with this setup Intent ID. Now if use wants to add other card Info then first it will remove his card information and with that, i will detach payment method and remove setup intent from database
Ok. If you detatch the PM, it's basically deleted, you can't use it anymore.
Okay then if call above given payment list API then everytime i will get only one object?
Correct
Thank you
You can also use Customer.invoice_settings.default_payment_method to designate one PM to be the default: https://stripe.com/docs/api/customers/update#update_customer-invoice_settings-default_payment_method
It doesn't need to be used with Invoices, but it will just indicate to you that this one is the default. It will also be marked as such on Stripe Dashboard.
No i don't need this, i just need to check card info which card customer is using. And want to get expiry date and card number
You can't get the card number from a Payment Method, unless your application is a PCI-compliant.
I didn't get this.
If some user register on our site. For future payments we ask him to register his payment method. By using Stripe it will register with us. We are getting only customer id and setup intent to charge this customer in future.
So when customer trying to register then by using their customer id can we get the list of paymnet methods like this:
data: [
{
id: 'pm_1OI858JVnpBxFv06qgDALIb3',
object: 'payment_method',
billing_details: [Object],
card: [Object],
created: 1701342418,
customer: 'cus_OqJlL9YvEgRBQR',
livemode: false,
metadata: {},
type: 'card'
},
{
id: 'pm_1O84ljJVnpBxFv06fQAl4g6N',
object: 'payment_method',
billing_details: [Object],
card: [Object],
created: 1698946404,
customer: 'cus_OqJlL9YvEgRBQR',
livemode: false,
metadata: {},
type: 'card'
},
{
id: 'pm_1O84SjJVnpBxFv06YBUfVC2Z',
object: 'payment_method',
billing_details: [Object],
card: [Object],
created: 1698945225,
customer: 'cus_OqJlL9YvEgRBQR',
livemode: false,
metadata: {},
type: 'card'
},
My question was this from the start if the user card is not detached and we need to check and show on the frontend which card he is using and what is expiry date then in this object which objects we will get like on Array Zero index or is there any key with that we know the latest card which they attached.
If you detach the last PM before adding a new one, there will be only one result here.
But alternatively you can use the invoice_settings.default_payment_method to indicate what's the preferred PM at the moment. Then you don't need to detatch the old ones.
CAn you please guide me how to call this?
Update the Customer object with: https://stripe.com/docs/api/customers/update#update_customer-invoice_settings-default_payment_method
to get default payment method detail why we ned to updat customer
not sure what you mean sorry.
Thanks for joining me. I will tell you my problem in detail.
1- For future payments with Stripe i am using create Session and retrieve session API, to store customer ID and set up intent ID into our database.
2- When i need to charge customers i use this setup intent and charge them.
3- Now i want to display card info like expiry date and last four digits to the user. And make some checks on the expiry date.
4- For this i need to store 4 things like the card holder's name, expiry, card number, etc.
5- By using this API i can get the details of Card, but here in this API i can see multiple card attached with customer.
const paymentMethods = await stripe.paymentMethods.list({
type: 'card',
limit: 3,
customer: 'cus_9s6XKzkNRiz8i3',
});
So in the last i want exact card information, so that i can store it into my databse. HEre is my solution when i call retrive session API at that time i will call this API and get object on zero index and from that i can get card info.
Is there any way i can get exact info?
well you can't get the card number.
all the other details are in the PaymentMethod object yep. https://stripe.com/docs/api/payment_methods/object#payment_method_object-card
HEre the card numbers
yep. You can get all that, it's documented in the API reference above. What is the blocker, what code did you write to try to access the values and what did it do/not do?
const sessionData = await stripe.checkout.sessions.retrieve(session);
if (sessionData) {
const paymentMethods = await stripe.paymentMethods.list({
type: "card",
customer: merchant.stripe_customer_id,
});
console.log(paymentMethods);
When i get retrive session then i am calling this API to get payment methods.
I just want to know there is array of customer payment objetcs
The last one means on zero index will be activated one?