/stripe-guides

How to send one-time invoices in Stripe?

Learn how to send one-time invoices in Stripe with this step-by-step guide, covering setup, dashboard and API methods, customization, and troubleshooting.

Matt Graham, CEO of Rapid Developers

Book a call with an Expert

Starting a new venture? Need to upgrade your web app? RapidDev builds application with your growth in mind.

Book a free consultation

How to send one-time invoices in Stripe?

How to Send One-Time Invoices in Stripe: A Comprehensive Tutorial

 

Step 1: Set Up Your Stripe Account

 

Before you can send invoices, you need to have a Stripe account set up and properly configured:

  • Sign up for a Stripe account at https://stripe.com if you don't already have one
  • Complete your business profile with company details
  • Verify your identity to activate your account
  • Connect your bank account for receiving payments
  • Configure your payment settings according to your business needs

 

Step 2: Install and Set Up the Stripe SDK (For Programmatic Creation)

 

If you plan to create invoices programmatically, you'll need to install the Stripe SDK for your preferred programming language:

For Node.js:

npm install stripe

For Python:

pip install stripe

For PHP:

composer require stripe/stripe-php

Once installed, initialize the Stripe client with your API key:

Node.js:

const stripe = require('stripe')('sk_test_your_test_key');
// Use 'sk_live_your_live_key' for production

Python:

import stripe
stripe.api_key = "sk_test_your_test\_key"
# Use 'sk_live_your_live_key' for production

PHP:

\Stripe\Stripe::setApiKey('sk_test_your_test_key');
// Use 'sk_live_your_live_key' for production

 

Step 3: Create a Customer in Stripe

 

Before creating an invoice, it's best to create or identify a customer record in Stripe:

Through the Stripe Dashboard:

  • Go to Customers in the sidebar
  • Click "+ New" or "Create customer"
  • Enter customer details (name, email, etc.)
  • Click "Create customer"

Programmatically with Node.js:

const customer = await stripe.customers.create({
  email: '[email protected]',
  name: 'Jenny Rosen',
  phone: '+15551234567',
  address: {
    line1: '123 Main St',
    city: 'San Francisco',
    state: 'CA',
    postal\_code: '94111',
    country: 'US',
  },
  description: 'Customer for invoice',
});

 

Step 4: Create an Invoice Using the Stripe Dashboard

 

For a simple, manual approach:

  • Log in to your Stripe Dashboard
  • Navigate to "Billing" > "Invoices" in the sidebar
  • Click the "Create invoice" button
  • Select an existing customer or create a new one
  • Add line items with descriptions, quantities, and prices
  • Set payment terms and due date
  • Add any applicable discounts or tax rates
  • Click "Create" to save the invoice as a draft

 

Step 5: Create an Invoice Programmatically

 

For programmatic invoice creation, follow these steps:

Node.js example:

// First, create an invoice item
const invoiceItem = await stripe.invoiceItems.create({
  customer: 'cus_customer_id',
  amount: 2000, // Amount in cents (e.g., $20.00)
  currency: 'usd',
  description: 'One-time consultancy fee',
});

// Then create the invoice with the invoice item
const invoice = await stripe.invoices.create({
  customer: 'cus_customer_id',
  auto\_advance: false, // draft invoice
  collection_method: 'send_invoice',
  description: 'Consultancy Services',
  footer: 'Thank you for your business!',
  due\_date: Math.floor(Date.now() / 1000) + 7 _ 24 _ 60 \* 60, // 7 days from now
});

Python example:

import time

# First, create an invoice item
invoice\_item = stripe.InvoiceItem.create(
  customer='cus_customer_id',
  amount=2000,  # $20.00
  currency='usd',
  description='One-time consultancy fee',
)

# Then create the invoice with the invoice item
invoice = stripe.Invoice.create(
  customer='cus_customer_id',
  auto\_advance=False,  # draft invoice
  collection_method='send_invoice',
  description='Consultancy Services',
  footer='Thank you for your business!',
  due\_date=int(time.time()) + 7 _ 24 _ 60 \* 60,  # 7 days from now
)

 

Step 6: Finalize and Send the Invoice

 

Through the Stripe Dashboard:

  • Navigate to the draft invoice
  • Review all details
  • Click "Finalize invoice"
  • Click "Send invoice" to email it to the customer

Programmatically with Node.js:

// Finalize the invoice
const finalizedInvoice = await stripe.invoices.finalizeInvoice(invoice.id);

// Send the invoice
const sentInvoice = await stripe.invoices.sendInvoice(invoice.id);

Python:

# Finalize the invoice
finalized_invoice = stripe.Invoice.finalize_invoice(invoice.id)

# Send the invoice
sent_invoice = stripe.Invoice.send_invoice(invoice.id)

 

Step 7: Customize Your Invoice Template (Optional)

 

To brand your invoices:

  • Go to "Settings" > "Branding" in your Stripe Dashboard
  • Upload your company logo (recommended size: 128x128px)
  • Set your brand color
  • Customize invoice details like company name, address, and payment instructions
  • Click "Save" to apply changes to all future invoices

 

Step 8: Monitor Invoice Status

 

Track the status of your sent invoices:

Through the Stripe Dashboard:

  • Go to "Billing" > "Invoices"
  • View all invoices and their current status (draft, open, paid, void, uncollectible)
  • Click on an individual invoice to see its detailed payment history

Programmatically with Node.js:

// Retrieve an invoice to check its status
const invoice = await stripe.invoices.retrieve('in_invoice_id');
console.log(`Invoice status: ${invoice.status}`);

// List all invoices
const invoices = await stripe.invoices.list({
  limit: 10,
});
invoices.data.forEach(invoice => {
  console.log(`Invoice ${invoice.id}: ${invoice.status}`);
});

 

Step 9: Set Up Webhook Events for Invoice Notifications (Advanced)

 

To get real-time updates when an invoice is paid or becomes past due:

// Express server example for handling webhook events
const express = require('express');
const app = express();

// Use JSON parser for webhook requests
app.use('/webhook', express.raw({type: 'application/json'}));

app.post('/webhook', async (req, res) => {
  const sig = req.headers['stripe-signature'];
  let event;

  try {
    event = stripe.webhooks.constructEvent(
      req.body,
      sig,
      'whsec_your_webhook_signing_secret'
    );
  } catch (err) {
    return res.status(400).send(`Webhook Error: ${err.message}`);
  }

  // Handle invoice events
  switch (event.type) {
    case 'invoice.paid':
      const invoicePaid = event.data.object;
      console.log(`Invoice ${invoicePaid.id} was paid!`);
      // Update your database, send a thank-you email, etc.
      break;
    case 'invoice.payment\_failed':
      const invoiceFailed = event.data.object;
      console.log(`Invoice ${invoiceFailed.id} payment failed!`);
      // Follow up with the customer
      break;
  }

  res.json({received: true});
});

app.listen(3000, () => console.log('Running on port 3000'));

 

Step 10: Handle Invoice Payments and Receipts

 

When a customer pays an invoice:

  • Stripe automatically processes the payment
  • The invoice status changes to "paid"
  • Stripe sends a payment receipt to the customer by default

To customize receipt emails:

  • Go to "Settings" > "Customer emails"
  • Edit the receipt template
  • Toggle on/off receipt emails as needed

 

Step 11: Troubleshooting Common Issues

 

If you encounter problems with invoices:

  • Check that your Stripe account is properly verified
  • Ensure customer email addresses are correct
  • Verify your invoice settings (currency, tax rates, etc.)
  • For API errors, check the response for detailed error messages
  • Review Stripe logs in the Dashboard under "Developers" > "Logs"

Example error handling in Node.js:

try {
  const invoice = await stripe.invoices.create({
    customer: 'cus_customer_id',
    collection_method: 'send_invoice',
    days_until_due: 30,
  });
} catch (error) {
  console.error('Error creating invoice:', error.message);
  // Handle specific error types
  if (error.type === 'StripeInvalidRequestError') {
    console.error('Invalid parameters were supplied to Stripe API');
  }
}

 

Final Tips for Effective Invoicing in Stripe

 

  • Always test the invoice flow in Stripe's test mode before going live
  • Set up automated reminders for overdue invoices
  • Consider offering multiple payment methods to increase payment likelihood
  • Use descriptive line items to minimize customer confusion
  • Leverage Stripe's reporting tools to track invoice metrics
  • Keep your API keys secure and never expose them in client-side code
  • Consider implementing a retry strategy for failed invoice payments

Want to explore opportunities to work with us?

Connect with our team to unlock the full potential of no-code solutions with a no-commitment consultation!

Book a Free Consultation

Client trust and success are our top priorities

When it comes to serving you, we sweat the little things. That’s why our work makes a big impact.

Rapid Dev was an exceptional project management organization and the best development collaborators I've had the pleasure of working with. They do complex work on extremely fast timelines and effectively manage the testing and pre-launch process to deliver the best possible product. I'm extremely impressed with their execution ability.

CPO, Praction - Arkady Sokolov

May 2, 2023

Working with Matt was comparable to having another co-founder on the team, but without the commitment or cost. He has a strategic mindset and willing to change the scope of the project in real time based on the needs of the client. A true strategic thought partner!

Co-Founder, Arc - Donald Muir

Dec 27, 2022

Rapid Dev are 10/10, excellent communicators - the best I've ever encountered in the tech dev space. They always go the extra mile, they genuinely care, they respond quickly, they're flexible, adaptable and their enthusiasm is amazing.

Co-CEO, Grantify - Mat Westergreen-Thorne

Oct 15, 2022

Rapid Dev is an excellent developer for no-code and low-code solutions.
We’ve had great success since launching the platform in November 2023. In a few months, we’ve gained over 1,000 new active users. We’ve also secured several dozen bookings on the platform and seen about 70% new user month-over-month growth since the launch.

Co-Founder, Church Real Estate Marketplace - Emmanuel Brown

May 1, 2024 

Matt’s dedication to executing our vision and his commitment to the project deadline were impressive. 
This was such a specific project, and Matt really delivered. We worked with a really fast turnaround, and he always delivered. The site was a perfect prop for us!

Production Manager, Media Production Company - Samantha Fekete

Sep 23, 2022