Overview
This integration exports NetSuite invoices to Stripe through PayPack. It does two jobs:
- Creates invoices in Stripe for NetSuite invoices that are not in Stripe yet, including the customer and the line items.
- Updates the status of Stripe invoices that already exist, marking them paid out of band or voided when the NetSuite invoice changes.
Invoices are exported in batch, on a schedule. The flow uses PayPack's shared configuration and mapping framework, driven by saved searches in NetSuite. Every run is logged for troubleshooting
What gets exported
PayPack decides what to do with each invoice from its NetSuite status and whether it already has a Stripe Invoice ID (PayPack).
| NetSuite invoice | Stripe Invoice ID (PayPack) | Result |
|---|---|---|
| Open | None | A new invoice is created in Stripe |
| Open | Exists | Excluded from processing |
| Paid in Full | None | Created in Stripe as open, then marked paid out of band (paid_out_of_band) in a later run |
| Paid in Full | Exists | The Stripe invoice is marked paid out of band |
| Void | None | Ignored |
| Void | Exists | The Stripe invoice is voided |
Note: A Paid in Full invoice with no Stripe ID takes two runs to reach paid status in Stripe. It is created first, then updated by the next scheduled run.
Configuration Settings
All invoice export settings are located under the Invoices to Stripe subtab within the Data Orchestration tab. The fields are organized under the Stripe Invoice Settings and Stripe Customer Settings sections.
Note: Click any field label in the Invoices to Stripe subtab to see a description of its purpose and usage
Field Descriptions
- Enable Invoices to Stripe Flow: Check/mark to enable exporting NetSuite invoices into Stripe. Uncheck to stop all invoice exports.
- Saved Search for Stripe Invoice Add/Update: A saved search in NetSuite used to fetch invoice records with eligible statuses for export to Stripe. The search retrieves invoices corresponding to Stripe invoices to facilitate creation and status updates.
Note: For a multi-subidiary environment, the search should be filtered by subsidiary mapping to avoid cross-account processing.
- Saved Search for Stripe Invoice Line Items: Specifies the saved search used to retrieve line-level details for each NetSuite invoice, including item, quantity, rate, amount, and other required line fields for Stripe invoice creation.
- NetSuite Non-Inventory Item for 250 lines: Defines the NetSuite non-inventory item to be used when an invoice contains more than 250 line items. In such cases, the integration creates a single consolidated line in Stripe, utilizing this item with the total invoice amount, rather than exporting individual line items.
- Customer Saved Search: Specifies the saved search used to retrieve NetSuite customer data for validating existing Stripe customers or creating new customers in Stripe when required.
The Saved Searches
PayPack provides three standard saved searches. The first one controls which invoices are exported.
Invoice add and status update search
PayPack Export Invoice and Status Update to Stripe
The standard search returns invoices that meet all of these criteria:
- Type is Invoice
- Status is any of Invoice: Open, Invoice: Paid In Full, Invoice: Voided
- Main Line is true
- It is not the case that the Stripe Invoice Id (PayPack) is empty and the status is Voided. This keeps voided invoices that were never sent to Stripe out of processing.
How the status is sent to Stripe. A formula column labeled status converts the NetSuite status into the Stripe status. The standard formula is:
CASE WHEN {status} = 'Open' THEN 'open'
WHEN {status} = 'Paid In Full' THEN 'paid'
WHEN {status} = 'Voided' THEN 'void'
ELSE 'open' ENDTreating voided invoices as uncollectible. By default a voided NetSuite invoice with a Stripe ID is voided in Stripe. If you would rather mark it uncollectible in Stripe, change the formula so it returns uncollectible in place of void.
Multiple subsidiaries or Stripe accounts. Add a filter on your Subsidiary mapping fields to the search so each invoice is exported to the right Stripe account.
Stripe invoice metadata. To send extra data to Stripe, add the NetSuite fields as result columns in this search with metadata-specific labels. They are passed to Stripe automatically when the invoice is created.
Invoice line items search
PayPack Export Invoice Items to Stripe
- Returns the item-level details needed to create the Stripe invoice.
- Line items are fetched only for the invoice being processed, using its internal ID.
- The quantity column's label decides whether quantities are exported as decimals (
quantity_decimal) or whole numbers (quantity).
Customer search
PayPack Export Invoice Customer to Stripe
- Filtered dynamically by the customer's internal ID and, where it applies, the invoice's subsidiary.
How the Export Works
The Batch flow handles each invoice one of two ways, depending on whether it already has a Stripe Invoice ID (PayPack). A new invoice (no Stripe ID) is created in Stripe and then has its status updated if needed. An existing invoice (with a Stripe ID) is not created again, and only has its status updated.
1. Get invoices
- PayPack fetches invoices using the add/update saved search. Only invoices the search returns are considered.
- Open invoices that already have a Stripe Invoice ID (PayPack) are skipped.
2. Get invoice line items
- All line items for the invoice are fetched using the line items saved search.
3. Handle Stripe's 250-line limit
- Stripe supports at most 250 lines per invoice. If the invoice has more than 250 lines (counted from the line items search), PayPack sends one consolidated line for the total invoice amount, using the NetSuite Non-Inventory Item for 250 lines.
- If that item is not configured, processing of the invoice fails with an error.
4. Get the customer
- PayPack retrieves the customer with the customer saved search.
- It looks for the Stripe customer using the stored Stripe Customer ID (PayPack), including multi-subsidiary mappings, or the customer's email.
- If no Stripe customer is found, a new one is created.
- Processing fails if the saved search returns no customer data, or if customer creation fails.
- Existing NetSuite customer records are not otherwise modified.
5. Create the invoice in Stripe
- If the NetSuite invoice has no Stripe Invoice ID (PayPack), a new invoice is created in Stripe under the right Stripe account, and the new Stripe invoice ID is kept for the next steps.
- If it already has a Stripe Invoice ID, no new invoice is created. PayPack goes to step 8 to update the status of the existing Stripe invoice.
6. Add line items
- Line items (individual or consolidated) are added to the new Stripe invoice. This happens only after the invoice is created successfully.
7. Finalize the invoice
- The Stripe invoice is finalized after all lines are added.
8. Update the invoice status
- This applies to new and existing invoices. The Stripe invoice status is updated according to the table in What gets exported: Paid in Full invoices are marked paid out of band, and Voided invoices are voided (or marked uncollectible, if you changed the status formula).
- A Paid in Full invoice that was just created is created as open first, and is marked paid out of band by the next scheduled run.
9. Sync back to NetSuite
- The Stripe invoice ID is saved in the Stripe Invoice ID (PayPack) field on the NetSuite invoice.
- When a status update is made in Stripe, PayPack checks it back in NetSuite.
Script Details
Batch (Map/Reduce)
Script: PayPack NS2S Invoice Import MR. Runs on a schedule you define.
- Processes invoices based on the add/update saved search. All invoices are fetched from the saved search results, so there is no Last Exported Date or start date.
- Parameter:
- Stripe Account Id (
custscript_pp_ns2s_invoice_acc_id): internal ID of the PayPack Stripe Account Configuration record that tells the script which Stripe account to use.
- Stripe Account Id (
Deploying and Scheduling
- Go to Customization > Scripting > Scripts.
- Filter by Type: Map/Reduce and search for PayPack NS2S Invoice Import MR. Click View.
- Click Deploy Script.
- On the deployment, set the Stripe Account Id parameter to the internal ID of the relevant PayPack Stripe Account Configuration record.
- On the Schedule subtab, choose the event type (single, daily, weekly, monthly or yearly), start and end dates (or No End Date), and the repeat interval.
- Click Save.