#surajpatidar

1 messages · Page 1 of 1 (latest)

lost daggerBOT
spring dagger
#

i have already payment method id so can i use this id and save cards details or not?

left charm
#

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

spring dagger
#

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

left charm
spring dagger
#

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 ?

left charm
#

why are you using Sources and Tokens? You would want to use PaymentMethods now

spring dagger
#

i have use Source and Token for save cards details , i want to save 2 3 cards for future use

lost daggerBOT
zealous shell
#

You can do the same with PaymentMethod, and SetupIntent

spring dagger
#

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

zealous shell
#

Yes, just List PaymentMethod with type = card

#

And you will find the card information inside the PaymentMethod object

spring dagger
#

it is right ?
saved_cards = stripe.PaymentMethod.list(customer=customer.id, type="card")

zealous shell
spring dagger
#

saved_cards = stripe.Customer.list_payment_methods(customer.id, type="card")
now it done right

#

i have one more question

zealous shell
#

And what is your question?

spring dagger
#

how to show all saved cards on checkout page ?

#

if i need create new card then need only create paymentmethod or not

zealous shell
#

Are you using Stripe Checkout?

zealous shell
spring dagger
#

i have use stripe checkout page so i want customer saved cards show on checkout page for payment

zealous shell
#

Checkout should do it already, if you pass in the Customer Id

spring dagger
#
            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

left charm
#

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.
#

does your payment method have those required details?

spring dagger
left charm
#

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

spring dagger
left charm
#

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?

spring dagger
#

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

left charm
#

what are you currently using to collect/save new cards e.g. Payment Element? Checkout?

spring dagger
#

payment element and create token and create customer source

#

which way is best for save card details without payment ?

#

how to delete saved card ?

left charm
#

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?

spring dagger
#

saving cards for future payement and client requirment like that , after saving cards if customer purchase anything show saved cards for payment

left charm
#

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

spring dagger
#

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

left charm
spring dagger
#

i want only save cards details so give me best api

left charm
#

have you gone through that guide? it goes through step by step how to save the cards

spring dagger
#

and this api suggest @zealous shell

left charm
#

can you share the request id for where you've detached the card?

spring dagger
#

req_k6xKy8iGqMKAnX

left charm
#

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

spring dagger
#

right now i have show 10 cards

#

when i delete one after that show 10 why

left charm
#

you have more than 10 cards on that customer. By default, the limit returned for a retrieve is 10 objects

spring dagger
#

okay

#

it is possbile to crete normal payment method and aatch with customer fo saving details

left charm
#

what's a "normal" payment method?

spring dagger
#

without payment and any charge only create paymentmethod and attach with customer for future use

left charm