#mick23_code

1 messages ยท Page 1 of 1 (latest)

dense berryBOT
#

๐Ÿ‘‹ 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.

oblique joltBOT
#

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.

spiral harness
#

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

#

That's not ideal that that is missing - can you add that to the dev queue please ๐Ÿ™‚

oblique joltBOT
spiral harness
#

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.

real sedge
#

"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?

spiral harness
real sedge
#

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

spiral harness
#

Can't see that info

#

In the very bottom of the menu?

real sedge
#

Yeah

#

There should be a date under your account name if you're logged in

spiral harness
#

Yes there is a date there

real sedge
#

That's the version. What is it?

spiral harness
#

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

real sedge
#

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?

spiral harness
#

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

real sedge
#

Can you copy/paste the payload you're getting?
Specifically from the Retrieve Customer call you made.

spiral harness
#

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?

real sedge
spiral harness
#

Let me make that switch then, see if that has any difference

real sedge
spiral harness
#

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
}
real sedge
#

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?

spiral harness
#

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

real sedge
#

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?

spiral harness
#

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

#
  1. SaaS: Billing Page - Add Card to Account (achieved)
  2. 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?

dense berryBOT
real sedge
spiral harness
#

Fair enough

real sedge
spiral harness
#

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.

real sedge
#

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

Keep track of changes and upgrades to the Stripe API.

Keep track of every change to the Stripe API.

spiral harness
#

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

real sedge
#

Yeah, it's definitely worth familiarizing yourself with some examples in the changelog. That's where it will probably click

spiral harness
#

Yeah I'll have a good read through those docs.

#

Is my guess along the rough right lines?

real sedge
spiral harness
#

Right, I see. That makes sense. Not something I need to be overly concerned with right now but I'll have a good read. Thanks

#

Thanks for help today, it's got me going in the right direction now.