#noorbl
1 messages ยท Page 1 of 1 (latest)
Hello
Hi
wait
i mean i want after payment send invoice to email customre
example
hello>?
are you here
I'm helping multiple folks at once so you need to be patient
ok ๐
An Invoice receipt email will be sent to customers automatically if you enable it in your Dashboard
These receipts aren't sent in test-mode though so as to not spam people
However you can trigger them manually to see what they look like
ok
but in code
?
form code?
const CheckoutForm: React.FC<CheckoutFormProps> = ({
clientSecret,
handleSetPaymentSuccess,
}) => {
const { cartTotalAmount, handleClearCart, handleSetPaymentIntent } =
useCart();
const stripe = useStripe();
const elements = useElements();
const [isLoading, setIsLoading] = useState(false);
const formattedPrice = formatPrice(cartTotalAmount);
useEffect(() => {
if (!stripe) {
return;
}
if (!clientSecret) {
return;
}
handleSetPaymentSuccess(false);
}, [stripe]);
const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault();
if (!stripe || !elements) {
return;
}
setIsLoading(true);
stripe
.confirmPayment({
elements,
redirect: "if_required",
})
.then((result) => {
if (!result.error) {
toast.success("Checkout Success");
handleClearCart();
handleSetPaymentSuccess(true);
handleSetPaymentIntent(null);
}
setIsLoading(false);
});
};
return (
<form onSubmit={handleSubmit} id="payment-form">
<div className="mb-6">
<Heading title="Enter your details to complete checkout" />
</div>
<h2 className="font-semibold mb-2">Address Information</h2>
<AddressElement options={{
mode: 'shipping',
allowedCountries: ['*'],
blockPoBox: false,
fields: {
phone: 'always',
},
validation: {
phone: {
required: 'always',
},
},
}} />
<h2 className="font-semibold mt-4 mb-2">Payment Information</h2>
<PaymentElement id="payment-element" options={{ layout: "tabs" }} />
<div className="py-4 text-center text-slate-700 text-xl font-bold">
Total: {formattedPrice}
</div>
<Button
label={isLoading ? "Processing" : "Pay now"}
disabled={isLoading || !stripe || !elements}
onClick={() => {}}
/>
</form>
);
};
creating one-time Invoices
An online store website, not a subscription website
?
Gotcha, then you can update the receipt_email on the Charge if you want to trigger a receipt via the API: https://docs.stripe.com/api/charges/update#update_charge-receipt_email
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Not sure what you mean by that
After the confirmation client-side there is a Charge created
It is associated to the PaymentIntent
You can access it via latest_charge on the PaymentIntent: https://docs.stripe.com/api/payment_intents/object#payment_intent_object-latest_charge
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
and how to rquest email in form?
You would collect that yourself
that for show in payment info
Yeah Address Element and Payment Element won't collect email for card payments (it is only required for certain payment method types in which case it will be collected) -- this means you add your own input to the form to collect email if you want that from your customer.
here show
can you give me a link for about this?
A link about what?
for add rquest email? for send invoice ๐
We don't have docs on that as you build that email collection yourself and then you can set it as the customer.email when you create the Customer: https://docs.stripe.com/api/customers/create#create_customer-email