#sive_best-practices

1 messages ¡ Page 1 of 1 (latest)

inner adderBOT
#

👋 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/1326750434127515758

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

sleek badger
#

for example before i create a invoice i have to add a address here

#

but there is an address on their card

#

since I'm using retroactive usage based billing for my organization do i need to set a customers billing details when they add it to their account in the setup intent?

#
const setupIntent = await stripe.setupIntents.create({
    payment_method_types: ['card'],
    customer: stripeCustomerId,
    usage: 'off_session',
    //confirm: true
  });
#

How should I use stripe elements to collect their billing details if necessary

safe stirrup
#

You need to set the address on the customer object. Having the address on the payment method object isn't sufficient.

sleek badger
#

How can I use stripe elements to populate the address to the customer object?

#
        const { clientSecret } = data;

    let stripe;
    let elements;
    let setupElement;
    let addressElement;

    // Initialize Stripe Elements
    async function createElements() {
        stripe = await loadStripe(PUBLIC_STRIPE_KEY);

        // Set the Stripe appearance theme based on dark mode detection
        const appearance = {
            theme: $mode === 'dark' ? 'night' : 'default' // 'night' for dark mode, 'flat' for light mode
        };

        const options = {
            layout: { type: 'tabs', defaultCollapsed: false },
            mode: 'billing'
        };

        elements = stripe.elements({ clientSecret, appearance });
        setupElement = elements.create('payment', options);
        setupElement.mount('#setup-element');
        addressElement = elements.create('address', options);
        addressElement.mount('#address-element');
    }
#

i already use the address element but it only attaches it to the card

#

is there a way to attach it to both the card and customer?

safe stirrup
#

You need to alll the update customer API to update its address.

sleek badger
#

Address information can change per country, is there a stripe element that can handle it, this code above handles billing address, does shipping address the one that applies to billing details on the customer object?

safe stirrup
#

No, the address that you collect through address element will only be set on the collected payment method object. You need to explicilty call the update customer API to set its shipping address and/or billing address.

sleek badger
safe stirrup
#

I don't quite understand this quesiton. You can't create a SetupIntent from client side. You need to use your API secret key to create one from backend

sleek badger
#

is there a clientSecret i can create such that i can add a billing details address to the customer object using stripe elements?

safe stirrup
#

No

sleek badger
#

where can i find the billing details specification for the customer object so i can handle it in my own custom forms?

safe stirrup
#

As I explained earlier. You need to call the update customer API from the backend to update the customer object.

sleek badger
#

Typically the stripe elements have all the data such as lists of countries and states to scroll through in a select menu, can i mount a stripe element without a client secret in order to fetch data to update the customer object from my backend after reading the form data?

#

I actually dont think the billing details on the customer object are necessary, i don't know why it gave me an error once for using it when I have a client i used the checkout page stripe hosted and it is billing them on a subscription without billing details

safe stirrup
#

Can you share with me the details about the error?

sleek badger
#

i think its just because i was wanting to include tax in the price in their territory

#

i unfortunately dont have the message anymore