#sive_best-practices
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/1326750434127515758
đ Have more to share? Add more details, code, screenshots, videos, etc. below.
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
You need to set the address on the customer object. Having the address on the payment method object isn't sufficient.
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?
https://docs.stripe.com/js/elements_object/create_address_element#address_element_create-options-defaultValues you need to set the defaultvalues by yourself.
You need to alll the update customer API to update its address.
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?
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.
is there something similar to a setup intent so that i can do this client side using stripe elements?
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
is there a clientSecret i can create such that i can add a billing details address to the customer object using stripe elements?
No
where can i find the billing details specification for the customer object so i can handle it in my own custom forms?
As I explained earlier. You need to call the update customer API from the backend to update the customer object.
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
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
Can you share with me the details about the error?