#codex_api

1 messages ยท Page 1 of 1 (latest)

kindred kelpBOT
#

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

๐Ÿ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

runic ospreyBOT
amber prism
#

Hi ๐Ÿ‘‹ I'm not sure I understand what you're hoping to accomplish. You want to retrieve address information for your customers from objects in Stripe? Do you know how your integration is collecting/populating those address details?

shrewd tapir
#

Yes, retrieve address info from Stripe invoice fields. Our integration collects country and zip/postal_code

#

We have a case (in_0PbXL4uagHrUveG4udZVY7N0) where customer purchased with Canada country and postal_code (so got charged with Canada taxes). But this customer then moved to USA and updated their address to Texas on Stripe

#

On Stripe dashboard, under "Automatic Tax" for that invoice, it correctly shows Canada

#

However, through the API, retrieving the invoice with expand="customer.tax", I get the customer's USA Texas address (their current address they updated, not the address they used during purchase). This is different from Stripe dashboard

amber prism
#

That sounds expected. Expanding the customer.tax includes the current state of the Customer object inline, so you'll see the updated address that was provided for the Customer object.

For the address used by an Invoice you want to look at the customer_address hash on the Invoice object, that one locks when the Invoice is finalized so you'll always see the address used for the Invoice regardless of when you retrieve it.

kindred kelpBOT
shrewd tapir
#

Alright, so in this case I should always use customer_address. On Stripe API, it says customer_address is nullable. We have very old subscriptions with invoices where customer_address=null (e.g. in_0PSR01uagHrUveG43r031X20)

#

However, if I use expand="customer.tax", I am able to get the address, even though customer_address field is null. But we determined that customer.tax can change any time the customer moves houses

#

So customer.tax fallback will be inaccurate, no? Is there a way to set customer.tax to the time of purchase, and not customer's updated address? (Since it seems Stripe dashboard can do this)

amber prism
#

No, the tax hash on the Customer object will always have their current information.

That's why we lock customer_address on the Invoice, so those details are available later in case the information on the Customer object changes.

#

My teammates and I in this forum aren't familiar with how this information is displayed in the dashboard, we focus on helping with our API.

shrewd tapir
#

So in this case, if customer_address=null (for invoices of very old subscriptions), what do you recommend we do for retrieving the locked customer country or zip/postal throught the API?

amber prism
#

I don't understand, the Invoice didn't have/use a customer address if those fields are null (I'm pretty sure).

shrewd tapir
#

Ahh sorry I forgot some context

#

We used to use Avalara to integrate with taxes. For old subscriptions, we migrated to Stripe Tax using Avalara's collected zip code. So customer_address=null. But when I go to the Stripe dashboard, the "Automatic Tax" section correctly shows the zip code

#

There must be a way to retrieve that Stripe dashboard "Automatic Tax" info through the API, no?

clever marlin
#

Hi there ๐Ÿ‘‹ taking over, as my colleague needs to step away

Give me a few minutes to get caught up.

shrewd tapir
#

ok thanks

clever marlin
#

Can you send a screenshot of where you're seeing the zipcode?

shrewd tapir
#

This is for the customer where customer_address=null through the API (in_0PSR01uagHrUveG43r031X20).

#

The Stripe dashboard apparently shows "Automatic tax calculation" section with the LOCKED info. I know through the API I can expand customer.tax, but that isn't the locked info, it's the customer's current address (which can change if they move)

clever marlin
#

So are you just trying to retrieve the zipcode from the API? Or are you doing something else?

shrewd tapir
#

Yes, retrieve the zipcode through the API, using the LOCKED-in address

#

For cases where customer_address=null

#

Do you know how Stripe dashboard retrieves the locked-in info? Maybe my team can do the same way through the API

clever marlin
#

Do you have a Customer ID I can look at? I'm assuming it's on that object, but I want to be sure

shrewd tapir
#

Yes, "cus_6cwe9k6SsxwPBm"

#

But Stripe dashboard can get locked-in "Automatic tax calculation" from Stripe Tax

clever marlin
#

So it looks like the billing address you see in the dashboard is being retrieved from the default Source on the Customer. So if you look at the default_source: "card_6cwdwcab3GrMJg", that''s on that customer object and retrieve the Card via the API (https://docs.stripe.com/api/cards/retrieve) you should see address_zip: https://docs.stripe.com/api/cards/object#card_object-address_zip

shrewd tapir
#

Wow, perfect!

#

Thank you so much for the help

#

I'll explore this from our side. Thank you!