#Marc-card
1 messages ยท Page 1 of 1 (latest)
Hi! If you have a PaymentMethod object, then you can find:
- The name in
billing_details.namehttps://stripe.com/docs/api/payment_methods/object - The last 4 digits in
card.last4https://stripe.com/docs/api/payment_methods/object#payment_method_object-card-last4
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
what version of stripe-python do you have installed?
How can I see the version?
Okay!
2.66.0
can you share the complete code of your script?
Sure
import stripe
stripe.api_key = "sk_live_..."
card_name = stripe.PaymentMethod.billing_details.name
("TOOLS-.....")
How should I do it?
pm = stripe.PaymentMethod.retrieve(
"pm_1EUngD2a8peR5CH5KEoBqs0U",
)
name = pm.billing_details.name
something like that.
And pm_1EUngD2a8peR5CH5KEoBqs0U, what kind of key is it?
Customer key?
it's the ID of a PaymentMethod object.
So should I leave that ID?
where you get that from really depends on the wider picture of what you're doing exactly and where this code is run from. Maybe you read it from your database, maybe you read it from an incoming webhook, maybe you call the API and list a customer's payment methods.
I don't understand what you mean by that.
Could you give me an example of where to get it? What is it for and when does it change?
Hey there. Stepping in for @zenith talon
If the Payment Method object seems alien to you, I guess you haven't created any previously
What is it exactly you're trying to do in that code snippet shared?
How do I create a new one?
What is a 'new client' in this instance? What information do you have?
About 'new client'?
when I receive a new client I send their information to my database so that it appears on my dashboard
What are those components in bold?
Yeah!
I don't know what you want me to answer you ๐
Well what information do you have from them that you want to send to Stripe?
I have the discord account (hello#1234), also the key & email
What's the key?
I get the key generated by my provider (Whop). That does not work for the Stripe API. Like CPSK-1234-1234-1234
If you're not handling payment information, then you've no use for the Payment Methods API
Like, what is your intended use for Stripe? Have you considered using Customers: https://stripe.com/docs/billing/customer
Yes, but I need to obtain the last 4 digits of my clients' card to send it to my database.
When a customer signs up, I want to receive specific information about that customer.
That information is Last 4 Digits and Name
Then use Customer objects: https://stripe.com/docs/billing/customer
You can use the metadata parameter to save the last 4 digits
import stripe
stripe.api_key = "sk_test_51IZargBE80a7NgI0DyJG2GlAkJTgXTxq0PHxjbaNkdOXLSfxdWjN10oNmPvjf6qlxZ0mBkw3avmmLiYJ32aMEeNA00vx4xPCgi"
stripe.Customer.retrieve("cus_LEa5TM58PQDGoP")
You need to create a customer: https://stripe.com/docs/api/customers/create?lang=python
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
You need to figure out your Python import issue
Could I use requests? It would be more comfortable for me
Sure
Could you pass me the request link? I don't see it in the API
I'm not sure what you mean?
How can I use Python request with stripe? I don't see any information about "requests" in the docs
We only document our official client libraries
and curl
But the endpoint URLs and parameters are all listed there
Did you pass the parameter with the values when creating the Customer?
No, what param do I have to pass?
@jade bay
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.