#sive_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/1295400409363386432
đ Have more to share? Add more details, code, screenshots, videos, etc. below.
Additionally is this the correct way to go about adding a card where I want to generate stripe invoices in the future? I'm not certain whether the auto_advance or the charge_automatically flag is the one I should be using.
Yes setupintent is what you want for this
Yes but the quest is do I need to take in items like billing address?
With this would I need to alter my client side submission handler
// Handle form submission and setup confirmation
async function submitIntent(event) {
event.preventDefault(); // Prevent the default form submit
if (!stripe || !elements) {
console.error('Stripe has not been initialized');
return;
}
// Call confirmPayment method from Stripe
const { error, setupIntent } = await stripe.confirmSetup({
elements,
confirmParams: {
return_url: `${$page.url.origin}/dashboard` // Optional redirect URL after successful payment
}
});
if (error) {
// Display error to the customer (e.g., insufficient funds)
const errorMessage = document.getElementById('error-message');
errorMessage.textContent = error.message;
} else if (setupIntent.status === 'succeeded') {
// Payment succeeded, redirect to success page or show confirmation
console.log('Payment succeeded!', setupIntent);
//window.location.href = '/checkout/success'; // Redirect to success page
}
}
<form id="payment-form" class="space-y-4" on:submit={submitIntent}>
<div id="payment-element">
<!-- Elements will create form elements here -->
</div>
<div id="address-element">
<!-- Elements will create form elements here -->
</div>
<Button type="submit" class="w-full">Verify Payment Method</Button>
<div id="error-message" class="text-destructive">
<!-- Display error message to your customers here -->
</div>
</form>
No need to modify:
From: https://docs.stripe.com/elements/address-element/collect-addresses?platform=web#web-retrieve-address
coolio
Do you have any knowledge of handling off session invoices with this information and the differences between auto_advance and charge_automatically?
You can use auto_advance with both send_invoice and charge_automatically invoices. Auto advancement just advances the invoice to the next state automatically.
You can read more about auto_advance here: https://docs.stripe.com/invoicing/integration/automatic-advancement-collection. And you can read more about charge_automatically vs send_invoice here: https://docs.stripe.com/billing/collection-method
Do you know if an invoice will be generated an later charged that day if auto_advance is true and charge_automatically isfalse? To me reading the documentation it made it seem like the charge_automatically is mainly meant if you want to charge immediately but I'm okay if its done an hour or so later.
charge_automatically isn't something that's true or false
See above links I sent
it's one of 2 options for collection method
ahh that makes more sense, I misunderstood
Recommend thoroughly reading those 2 docs I sent