Automatic NetSuite Invoice Payment Using Stripe

Automate collections by paying NetSuite invoices used saved card or bank information. Send links to customers that enable them to easily update their saved card or bank account.

This workflow is helpful for users who need to automatically pay invoices generated inside NetSuite and provide a simple way for customers to submit a card or bank account for future use.

Here's where this workflow is helpful:

  • SuiteBilling, or some other NetSuite service, creates Invoices. These invoices need to be paid automatically using Stripe, based on their due date or some other data on the Invoice.
  • Most sales are handled through a webstore or online billing platform, but some are managed using a manual process that creates NetSuite invoices. These invoices need to be paid after they are created in NetSuite
  • NetSuite invoices are imported using a CSV-based workflow. After these invoices are imported customers should be automatically charged for the amount due.
  • If a customer does not have a saved card or bank account, the customer needs to be able to update their payment details easily.

Here's a short video walkthrough:

Here's an overview of this workflow:

  1. You create a NetSuite Invoice and set the due date
  2. Each day, the integration pulls all unpaid invoices, without a Stripe transaction ID, which are due and attempts to pay them using the customer's default card or bank account in Stripe.
  3. If a payment is successful, a NetSuite CustomerPayment is applied to the open invoice in NetSuite. Note that the Stripe Charge ID is added to the invoice before the Invoice is marked as paid in full.
  4. If a payment fails, this is noted on the invoice.
  5. Refunds can be issued directly in NetSuite
  6. Disputes are automatically pulled into NetSuite
  7. All payments automatically reconcile to a NetSuite bank deposit. Fees are recorded.

This workflow pairs nicely with the payment form. This payment form integrates with this workflow and can be used to:

  1. Create a Stripe customer if one does not exist for a NetSuite customer
  2. Save or update payment credentials if no saved payment credentials exist or if the saved payment method is failing

Here's a visual overview of how this works:

Automatic Payment Overview

Technical Overview

This auto-bill or "batch payment" functionality is driven by a couple of different criteria:

  • Due Date. Each day, invoices that are due are attempted to be paid.
  • Status. The invoice must be Open
  • Stripe Transaction ID. This is a custom field that is added to your account. It must be empty for the auto-bill to run.

Every day at 5 am PT invoices that are due and unpaid are attempted to be paid using the customer's saved card or bank account.

In most cases, you'll want to limit the invoices that are "marked" for automatic payment. This can be done using a saved search.

You can create a NetSuite Invoice saved search with whatever criteria you'd like and provide SuiteSync with the internal ID of the search. SuiteSync appends the due date (today) and status criteria (open or unpaid) to the saved search that you create. Any invoices that meet the criteria of your saved search in combination with these two additional criteria will be auto-paid.

Note that your search should return the main line of the invoice and should not have a Main Line: false search criteria. The auto-bill system adds the Main Line: true parameter on top of whatever search criteria are defined in your customized search criteria.

For each invoice that is scheduled to be paid:

  1. If a saved card or bank account exists for that customer, a payment for the amount due on the invoice is attempted. The Stripe charge description is set to "Automatic Payment for Invoice XYZ" (where XYZ is the NetSuite transaction ID).
  2. If the payment succeeds, a CustomerPayment is created and applied to the Invoice.
  3. If the charge fails:
    • A memo is added to the invoice indicating that the charge failed.
    • A metadata field is added to the default card indicating that it failed. This instructs the payment form to update the customer's default card when the customer enters new payment credentials
    • A NetSuite workflow can easily be created to email the user with a link to the invoice when their payment fails.
I only want certain invoices to be automatically billed. What's the best way to set this up?

Create a NetSuite Invoice saved search which identifies the invoices you'd like to automatically bill.

If there isn't an obvious way to identify these invoices through a saved search, the payment terms on the invoice is an excellent way to filter invoices for automatic payment. Setup a new payment term for use only on invoices that should be automatically paid. Then go ahead and associate the new terms with all invoices (and customers) that should be auto-billed and create a saved search to exclude any invoices that do not have these special payment terms.

For most users, not all invoices should be automatically billed. Creating a saved search to select a specific set of invoices to be automatically billed is how SuiteSync ensures only the correct invoices are auto-charged.

Here’s the recommended way to set this up:

  1. Create "Net 30 Automatic" payment terms. Run a global search for page: Terms to find the page where you can create terms.
    • If you want "Due on Receipt Automatic" payment terms be sure to set the "Days Till Net Due" option to one day. Remember, the automatic billing operation only runs once per-day, so you'll want to use the due on receipt terms to automatically set the due date to tomorrow.
  2. Assign the newly created payment terms to any customers and/or invoices that should be automatically charged.
  3. Create a saved search to select all of the invoices that have the newly created payment terms selected.
  4. Let SuiteSync support know about the saved search you created.

On our end, we'll make sure only invoices that are due on the current day and are unpaid are processed: you don't need to add this criteria to your search.

How is the NetSuite customer linked to a Stripe customer?

Through the externalId field. The Stripe customer ID (cus_123) is used as the external ID of the corresponding NetSuite customer.

If the externalId is not set on a NetSuite customer, then it hasn't been linked to a Stripe customer.

I already have customers created in NetSuite, but not in Stripe. Are Stripe customers created automatically?

Yes. When a customer pays an invoice with the payment form a customer is created in Stripe, their payment credentials are saved, and the NetSuite customer associated with the invoice that was paid is linked to the Stripe customer.

This is an optional feature.

I already have Stripe customers and NetSuite customers. Can these be linked together?

Yes. We have migration tools available that can link existing Stripe and NetSuite customers together during the onboarding process.

Here are the two migration tools we use to help link NetSuite customers:

How can I email the customer automatically when their invoices are unpaid?

You can automatically email the customer and include a link to a invoice or order payment form by creating a SuiteScript or workflow that fires off an email based on the following criteria:

  • The "Stripe Transaction ID" field is blank. If payment succeeds, this field is updated.
  • The "Memo" field contains "Stripe:". This field contains information about why the automatic payment failed.
  • The Invoice is Open (i.e. unpaid)

Here's an example workflow which implements this.

Here's an example SuiteScript demonstrating how to implement the above criteria:

function isEmpty(obj) {
  return obj === undefined || obj === null || obj === "";

function contains(str, searchString) {
  return str.indexOf(searchString) != -1;

function afterSubmit(type) {
  if (type == "edit" || type == "create") {
    var currentTransactionID = nlapiGetFieldText(
    var memo = nlapiGetFieldText("memo");

    if (isEmpty(currentTransactionID) && contains(memo, "Stripe:")) {
Can I use another method aside from the due date to control when an invoice is billed?

Yes. Instead of using the invoice's due date, you can "force" a payment attempt for the invoice by adding the Stripe Customer ID (or a card/source ID) to the "Stripe Transaction ID" on the invoice.

Here's more information on how this works.

Can I use two different cards/banks depending on the type of invoice?

No. Only a single card can be used with the automatic billing system. However, with some custom scripting on your end, it is possible to choose which card to use.

In Stripe, there is only one default card (or bank) per Stripe customer. This default card/blank is used for all automatic payments created by SuiteSync.

If you need to specify a different card/bank to be used based on the invoice (or other custom logic on our end), you need to specify which card to be used on your end using a custom script. Here's more information on how this works.

Here's an example of how you could accomplish this:

  1. Instead of our integration picking up when an invoice is due, your system would need to track when an invoice is due and then specify which card to use on the invoice's "Stripe Transaction ID" field.

  2. To specify which card/bank to use, the Stripe card identifier (starts with "card_") should be specific on the invoice's "Stripe Transaction ID" field.

  3. Alternatively, if all of the invoices you want to pay originate from the same sales order, you could specify a previously captured Stripe charge ID (starts with "ch*" or "py*"). SuiteSync looks up the card in Stripe from that charge and creates a new payment for the amount due on the invoice.

Payment Method Options

This flow allows you to collect payment using either:

  1. A customer's credit card
  2. An ACH transfer from a customer's bank account (currently only available for US accounts)
How can I retry a failed payment attempt?

The easiest way to retry a failed payment is to update the due date on the invoice to at least one day in the future. The invoice will then be picked up by the automatic billing system the next day and retried.

The easiest way to determine which invoices need to be retried is to select all invoices with a due date in the past that are still unpaid. If you update the due date on all invoices which match this criteria, you can effectively implement a payment retry strategy within NetSuite without using complex code.

However, you can also retry a payment whenever you'd like by triggering the payment by adding the Stripe customer ID to the "Stripe Transaction ID" field.

It's worth noting that automatic payments managed through NetSuite are completely separate from Stripe Billing/Subscriptions. Retry rules setup in Stripe do not affect the automatic payment system.

How are failures handled?

Some failures simply cause a payment delay (if the NetSuite or Stripe API is down, for instance) and are handled automatically. Other failures cause additional information to be added to the NetSuite invoice but are resolved automatically as well.

However, there are some errors that cannot be recovered from automatically and require intervention on your end to resolve.

Customer does not have a payment method saved

If a customer does not have a payment method saved, the following message is added to the Invoice memo: Stripe: no default payment method for customer cus_123

This can occur on new NetSuite customers, or if the Stripe customer's payment method was edited manually or through the API.

Saved payment method fails to charge

If the customer's saved payment method failed to charge, Stripe: payment failure for customer cus_123 is added to the Invoice memo.

NetSuite customer is not linked to Stripe customer

If no Stripe customer is associated with the NetSuite customer, Stripe: no linked customer is added to the Invoice memo.

Note if you are using the payment form a customer can be added automatically to the NetSuite customer when a customer uses that form.

Network or API outages

If there is a Stripe or NetSuite outage, or if there are network errors, the auto-bill batch operation is retried until it is successful.

Integration user timezone setup

The once per day batch billing process, since run at 5 am PST, needs to be inititated under an accessible timezone under the NetSuite user that the integration is connected under. For example, if the user has an AU timezone, the billing process can fail to run due to the billing timezone and the user timezone "missing" each other. To ammend this situation, set the NetSuite user accesss that the integration is connected through to have a timezone of PST. This will allow the auto-billing batch processor to run correctly.