#spravesh1818

1 messages ยท Page 1 of 1 (latest)

fading craterBOT
nimble geyser
#

I think $0.00 transaction doesn't generate Invoice email

#

If you look at the Subscription object in Dashboard, do you see the $0.00 Invoice? Does it say something about sent email?

lean gate
#

What development language are you using?

You should be able to generate a custom email receipt. Use the data from the webhook event

hollow orchid
hollow orchid
nimble geyser
#

So yes we don't send email for $0 Invoice

hollow orchid
#

Ok thanks. That makes sense ๐Ÿ’ฏ

lean gate
#

When a customer uses a 100% off promotional code with Stripe Checkout, it is considered a free transaction, and Stripe will not generate an invoice for it by default. Therefore, sending an email receipt for $0.00 is not an expected behavior with Stripe Checkout.

To send an email receipt for a $0.00 transaction in this scenario, you can use Stripe's webhook feature

If you were to utilize the checkout.session.completed event (webhook), you could retrieve details regarding the completed checkout session. It might look something like this...

const stripe = require('stripe')(process.env.STRIPE_SECRET_KEY);
const express = require('express');
const bodyParser = require('body-parser');
const nodemailer = require('nodemailer');

const app = express();

app.use(bodyParser.json());

app.post('/webhook', async (req, res) => {
const event = req.body;

if (event.type === 'checkout.session.completed') {
// Extract session data
const session = event.data.object;

// Send a custom email receipt
const transporter = nodemailer.createTransport({
  // Configure your email settings here
});

const mailOptions = {
  from: 'your@email.com',
  to: session.customer_details.email,
  subject: 'Receipt for Your Purchase',
  text: 'Thank you for your purchase!',
};

transporter.sendMail(mailOptions, (error, info) => {
  if (error) {
    console.error('Error sending email:', error);
  } else {
    console.log('Email sent:', info.response);
  }
});

}

res.status(200).end();
});

When a checkout.session.completed event is received, it sends a custom email receipt to the customer using Nodemailer.

#

Actually this may work better
https://codeshare.io/wnjOOp

Added the

// Check if the transaction amount is $0.00
if (session.amount_total === 0) {
// Send a custom email receipt
const transporter = nodemailer.createTransport({
// Configure your email settings here
});

#

Good luck!

hollow orchid
#

Whoa that was some helpful gesture. Thanks @lean gate for the code and the link, you are the best ๐Ÿ™Œ