#mick23_code
1 messages ยท Page 1 of 1 (latest)
๐ Welcome to your new thread!
โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
๐ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1230245673530691657
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
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.
- mick23_code, 1 day ago, 117 messages
- mick_java-sdk-confirmationtokens, 2 days ago, 12 messages
- mick23_code, 2 days ago, 64 messages
According to this - https://docs.stripe.com/api/cards/list - "We show the cURL request because this method is currently unsupported in the Java client. To see it in the library, let us know about your use case."
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
That's not ideal that that is missing - can you add that to the dev queue please ๐
FYI, I'm not going to be using curl - This stuff is hard enough, not making it harder using curl commands, I like my dot syntax in Java as it helps me along the way.
I did notice this info on that same link though "You can see a list of the cards belonging to a customer. Note that the 10 most recent sources are always available on the Customer object. "
So I've just given that a go with this code;
Stripe.apiKey = "sk_test_{etc}";
Customer customer = Customer.retrieve("cus_{etc}");
But I can't see the sources/cards listed in the response
What am I missing here?
And just to step back to what I'm actually trying to achieve for context. I have a page in SaaS App for "Billing Details" which essentially I want to list for the user to see what cards they have currently setup on their account.
"We show the cURL request because this method is currently unsupported in the Java client. To see it in the library, let us know about your use case."
Huh... odd that cURL is the only example. I'm not seeing this exact text in the link you posted though. Where is that showing up?
Ahhh, okay. At the bottom left of the window, what API version is shown?
Just want to make sure we're on the same page before recommending anything
Yes there is a date there
That's the version. What is it?
2015-10-16
I thought that must have been when I first created the Stripe account or something
It's just got;
Company Name Ltd
2015-10-16
Nope! That's the API version your integration is running as the default. Okay, so very old. Now, moving on to your question:
So I've just given that a go with this code;
Stripe.apiKey = "sk_test_{etc}"; Customer customer = Customer.retrieve("cus_{etc}");But I can't see the sources/cards listed in the response What am I missing here?
Can you copy/paste the payload you're getting?
Ah ok, that's good to know. Might be worth adding a label to that to say "Default API Version: xxx" etc.
How do I change that?
The current version is v25 as I upgraded it only a couple of days ago
I don't actually have anything running in a production system at the moment
Must have been for some POC stuff I did quite some time back how it has picked that up
To upgrade the default API version, you can go here: https://dashboard.stripe.com/developers and there should be an upgrade link toward the bottom of the page. Might be worth tackling the issue you wrote in about first though
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
Can you copy/paste the payload you're getting?
Specifically from the Retrieve Customer call you made.
So do the docs alter based on the default API settings to help me (but confuse me in this case as I didn't know...) ?
Just wondering why you didn't see that curl bit, but I did.
My thought process being at the minute, if I upgrade that default api version on the account to the latest version, will the docs suddenly show me a Java code snippet instead of that curl one?
Sometimes, though Stripe is usually pretty good about keeping the docs cohesive and relevant.
Let me make that switch then, see if that has any difference
Unfortunately no. For some reason the only change to this section is that the text you saw isn't in the latest version of the docs (likely because the product team intends to add snippets at a later date after some changes, but I can't really speak for them so take that with a grain of salt)
Right ok
So basically back to the original question then I guess.
Let me grab the json response I'm getting
Ok that's upgraded now anyhow
Just out of interest, what does that actually do other than the docs tweaks?
Just refreshed that list cards docs page, it's still showing that same message for me, but I can see the date has updated in the bottom left
Just curious re. the above question as ultimately nothing in Stripe settings actually determines the api version that my application is using, that's down to the version of the sdk I have installed.
This is the json I'm getting back, I've removed a few bits;
{
"address": {
"city": "",
"country": "GB",
"line1": "123",
"line2": "123",
"postal_code": "123",
"state": "123"
},
"balance": 0,
"cash_balance": null,
"created": 1710103443,
"currency": null,
"default_source": null,
"deleted": null,
"delinquent": false,
"description": null,
"discount": null,
"email": null,
"id": "cus_123",
"invoice_credit_balance": null,
"invoice_prefix": "123",
"invoice_settings": {
"custom_fields": null,
"default_payment_method": null,
"footer": null,
"rendering_options": null
},
"livemode": false,
"metadata": {},
"name": "123 Ltd",
"next_invoice_sequence": 1,
"object": "customer",
"phone": null,
"preferred_locales": [],
"shipping": null,
"sources": null,
"subscriptions": null,
"tax": null,
"tax_exempt": "none",
"tax_ids": null,
"test_clock": null
}
A lot. That's basically ~9 years worth of API changes that you didn't have access to using without setting the API version explicitly at a per-request basis.
It might have zero material impact on your integration though, so let's leave off on that tangent for now
What's the Customer ID of the Customer you retrieved?
Interesting. I wouldn't mind coming back to that tangent at the end though if that's ok - for future planning so I understand this fully.
cus_PiJr8AJQQfgtMU
Just tried this too;
customer.getSources()
And that's returning null weirdly
As there is a card saved against that account (which was created as a future payment/setup intent via integration)
Just checked a get of the other getters on the customer object and I'm getting data for what I would expect, but on the getSources() and getDefaultSource() both are returning null
I'm going to take a stab here and guess that this is something to do with how the card has been created - I noticed a few nuances with the Stripe SDK/API when creating the card in the first place, which basically only showed the card in certain responses (not directly related to this) after certain other Stripe API calls were made i.e. the Stripe.js "stripe.confirmSetup" bit.
So this card that I've added via integration, has not been charged yet
I'm just mentioning the above in case that triggers and thoughts as you know this stuff way more than I do
Ah, okay I see what's going on. You have a Payment Method attached to this Customer, which is different from having a Source attached to the Customer.
Sources is the old way. Payment Methods came in and replaced them. So, circling back a little bit, what are you trying to do by retrieving the Customer's payment credentials?
Ah ok, didn't realise that.
Noticed a few things through these chats I've had on here recently that there seems to be an "old way" for quite a few things which isn't jumping out as a newbie like me reading the docs
"So, circling back a little bit, what are you trying to do by retrieving the Customer's payment credentials?"
So in simple terms...
- SaaS: Billing Page - Add Card to Account (achieved)
- SaaS: Billing Page - List Cards on Account (this bit)
That at least explains why the Sources stuff is all null if that's the old way of doing things.
So just a fairly boring UI for;
Card 1 - last 4 digits - in date/expired
Card 2 - last 4 digits - in date/expired
etc
Just a thought that popped into my head when writing that last bit. Is there anything in Stripe Elements that does this for me?
unfortunately not in this case, no
Fair enough
So yeah! This should actually be pretty easy. just list a Customer's Payment Methods: https://docs.stripe.com/api/payment_methods/customer_list
That will give back a response that contains all attached PMs that you can iterate through to get things like card.last4 https://docs.stripe.com/api/payment_methods/object#payment_method_object-card-last4
Yeah just tested that and that's giving me what I need now, thanks.
Should keep me going for another day ๐
So just back to that point about the API versioning stuff then. Talk me through that.
I mean, that's a pretty big concept to try and tackle here, so I would recommend reading this stuff first and then coming back if you have more specific questions:
API Upgrades: https://docs.stripe.com/upgrades
How versioning works (gives example of how to set the version on a per-request basis): https://docs.stripe.com/api/versioning
All the changes made since 2020 in a readable format: https://docs.stripe.com/changelog
Brill, I'll have a read over those links
I guess the specific question I have on this topic though is...
How does the setting in my Strip Account alter what is/isn't possible via the SDK I use?
Ah....
Guessing it's the Stripe.js stuff that is running from that setting
I was just thinking of the SDK Server Side that I use
Yeah, it's definitely worth familiarizing yourself with some examples in the changelog. That's where it will probably click
Yeah I'll have a good read through those docs.
Is my guess along the rough right lines?
It mostly pertains to server-side behavior, but for example (https://docs.stripe.com/upgrades#how-can-i-upgrade-my-api):
Upgrading your API version affects:
- The structure of objects received with Stripe.js methods such as confirmCardPayment.