#surajpatidar
1 messages · Page 1 of 1 (latest)
i have already payment method id so can i use this id and save cards details or not?
hello! sure, you can pass in that PaymentMethod id in the default_payment_method [0] when creating the subscription. You can also consider setting save_default_payment_method=on_subscription [1] so that it will automatically save the payment method as the default payment method when an invoice is paid
[0] https://stripe.com/docs/api/subscriptions/create#create_subscription-default_payment_method
[1] https://stripe.com/docs/api/subscriptions/create#create_subscription-payment_settings-save_default_payment_method
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
but i want to show this card after successfully payement on user dashbord
and i want to save 3 cards on stripe for future use
You'll want to go through this guide on how to save a card for future use : https://stripe.com/docs/payments/save-and-reuse
saved_cards = stripe.Customer.list_sources(customer.id, object="card")
so what did this code
stripe.Customer.create_source(customer.id, source=token)```
why use create_source ?
why are you using Sources and Tokens? You would want to use PaymentMethods now
i have use Source and Token for save cards details , i want to save 2 3 cards for future use
You can do the same with PaymentMethod, and SetupIntent
so how to retrive all cards from paymenmethod
you mean payment method is like reuse card , paymentmethod save cards details right ?
but i want to retrive all cards for show user on platform
Yes, just List PaymentMethod with type = card
And you will find the card information inside the PaymentMethod object
it is right ?
saved_cards = stripe.PaymentMethod.list(customer=customer.id, type="card")
No you want this API instead https://stripe.com/docs/api/payment_methods/customer_list
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Then inspect the result, look at the card property for each Payment Method https://stripe.com/docs/api/payment_methods/object#payment_method_object-card
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
saved_cards = stripe.Customer.list_payment_methods(customer.id, type="card")
now it done right
i have one more question
And what is your question?
how to show all saved cards on checkout page ?
if i need create new card then need only create paymentmethod or not
Are you using Stripe Checkout?
To collect new card information, you should use SetupIntent as my colleague mentioned
yes
i have use stripe checkout page so i want customer saved cards show on checkout page for payment
Checkout should do it already, if you pass in the Customer Id
expires_at=int(time.time()) + 1860,
payment_method_types=["card"],
customer=stripe_customer.id,
line_items=[
{
"price_data": {
"currency": "usd",
"unit_amount": int(total * 100),
"product_data": {
"name": product.title,
"description": product.description,
},
},
"quantity": 1,
}
],
invoice_creation={
"enabled": True,
},
metadata={
"order_id": order.id,
},
payment_intent_data={
"transfer_data": {
"amount": int(total * 100) - int(platform_fee * 100),
"destination": order.provider.stripe_account.id,
},
},
mode="payment",
success_url=f"{prefix}{settings.HOST_NAME}/order/checkout/success",
cancel_url=f"{prefix}{settings.HOST_NAME}/order/checkout/cancel/",
)
Session.sync_from_stripe_data(session)```
i have pass customer id but not show any cards on page
as per our documentation : https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-customer
ID of an existing Customer, if one exists. In payment mode, the customer’s most recent card payment method will be used to prefill the email, name, card details, and billing address on the Checkout page.... A valid billing address, billing name and billing email are required on the payment method for Checkout to prefill the customer’s card details.
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
does your payment method have those required details?
no
i want to show all saved cards on stripe checkout page
that isn't how Stripe Checkout works
there's no way to show all cards on Stripe Checkout
it will only prefill the most recent card payment method if it meets those criteria
so i have passed customer id but it not show any one cards with pre filled
you mentioned that your payment method didn't have a valid billing address, billing name and billing email? Have you since added those details to the payment method on that customer id you passed in?
so in payment method how to add this details and if i want to save new cards how to save please give me idea about that
what are you currently using to collect/save new cards e.g. Payment Element? Checkout?
payment element and create token and create customer source
which way is best for save card details without payment ?
how to delete saved card ?
i'm not entirely sure i understand why you want to specifically save cards upfront, what's the use case for that? Isn't it easier if you left everything to Checkout to handle i.e. saving the card for future payment at the same time they make payment with their current card?
saving cards for future payement and client requirment like that , after saving cards if customer purchase anything show saved cards for payment
to be clear, if you use Checkout Sessions, Checkout Sessions will never show all saved cards for payments. So that already doesn't meet your requirements
To display saved cards for payment, you'll need to implement that on your own
ok
okay got it
so i want to know how to save cards details and delete saved cards for now
later on i will change checkout page
you can follow this guide on how to save cards : https://stripe.com/docs/payments/save-and-reuse
to "delete" a saved card from a customer, you'll call this method : https://stripe.com/docs/api/payment_methods/detach
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
no i dont want to pyament
i want only save cards details so give me best api
have you gone through that guide? it goes through step by step how to save the cards
i have delete cards using this api but all cards still show on page
stripe.Customer.list_payment_methods(customer.id, type="card")
and this api suggest @zealous shell
can you share the request id for where you've detached the card?
req_k6xKy8iGqMKAnX
that PaymentMethod is successfully detached from the customer. You have a lot of other PaymentMethods attached to the customer, so you listing PaymentMethods, and the response showing all those other PaymentMethods is expected behaviour
you have more than 10 cards on that customer. By default, the limit returned for a retrieve is 10 objects
you should paginate to fetch all of the cards on the customer. See https://stripe.com/docs/api/pagination/auto
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
okay
it is possbile to crete normal payment method and aatch with customer fo saving details
what's a "normal" payment method?
without payment and any charge only create paymentmethod and attach with customer for future use
like we've mentioned repeatedly, this guide mentions how to collect a payment method without making a payment : https://stripe.com/docs/payments/save-and-reuse