Examples

Here are some examples to help you integrate your application with Stripe to use the NetSuite integration.


The code examples below are designed to provide boilerplate code to demonstrate how the Stripe NetSuite integration works, and how to handle unique business processes using the integration. All of the examples will run as-in against your Stripe test environment.

To run any of the examples:

  1. Install the stripe ruby gem. The example code can easily be ported to other languages.
  2. Replace the test key in the source files with your Stripe account's test key.
  3. Run ruby the_example.rb at the terminal

Creating a NetSuite Customer with Stripe

This example demonstrates this customer translation functionality:

  • Linking an existing NetSuite customer with an existing customer
  • Linking an existing NetSuite customer with a new customer
  • Using metadata to set NetSuite field data

View Example Code

Creating & Paying a NetSuite Invoice with Stripe

You can create a NetSuite invoice and pay it off using the Stripe API without interfacing with NetSuite directly.

View Example Code

Creating a Stripe Subscription

A simple example demonstrating how to create a Stripe Subscription and pass custom data to NetSuite.

View Example Code

Paying an Existing NetSuite Invoice with Stripe

You can pay an existing NetSuite invoice with Stripe by passing the NetSuite Invoice ID to Stripe. The integration applies a CustomerPayment against the invoice you specify.

View Example Code

Creating a NetSuite using SuiteTalk and paying it with Stripe

Here's an example of how to create a NetSuite invoice using the SuiteTalk API and then paying that invoice off using a Stripe charge.

View Example Code

Payment Installments Against a Single NetSuite Invoice

You can use Stripe Subscriptions to create payment installments against a single NetSuite invoice.

View Example Code

Attaching a Stripe Charge as a CustomerDeposit against a SalesOrder

You can attach a Stripe charge against a SalesOrder as a customer deposit by specifying the internal ID of the SalesOrder.

View Example Code

Creating a Standalone Invoice with Stripe

The integration supports translating subscription-created invoices with revenue recognition, but it also supports translating one-off invoices creating in Stripe. This example demonstrates how to create a customer and a standalone invoice with a custom SKU.

If Stripe's subscription billing isn't workable for your use-case, but you want to use the Stripe NetSuite integration to create invoices in NetSuite, creating a standalone invoice might work for you.

View Example Code

Collecting Payment for a Standalone Payment with Stripe Checkout

This example demonstrates how to use Stripe Checkout to collect payment credentials, and then create a Stripe Invoice and Charge the collected credit card.

View Example Code

Testing Stripe dispute integration

The integration fully supports handling credit card disputes. Here's an example which creates a dispute in your test account to demonstrate how the integration handles disputes.

View Example Code

Authorizing a Charge with Stripe Checkout for Capture from NetSuite

Often in eCommerce flows you'll want to authorize a charge during checkout but only later capture the charge once the order has been fulfilled in NetSuite. Here's an example of how to implement this using Stripe and the authorization-capture workflow:

View Example Code

ACH-in & Bitcoin Payments

ACH-in and Bitcoin charges are fully supported in the integration. This example will create a bitcoin payments in your Stripe test environment to allow you to inspect the resulting customer payment in NetSuite.

View Example Code

Creating Sales Orders with Stripe Orders API (Relay)

This example demonstrates how the integration's order integration works:

  • Creates a SKU, which is translated into a NonInventoryItem in NetSuite
  • Creates a Order with a single line item
  • Waits for the translation to complete, and returns the NetSuite SalesOrder internal ID.

View Example Code

Copy Stripe Subscription Metadata to Subscription Invoice Metadata

Stripe Subscriptions create a Stripe Invoice every plan period. In some cases, copying metadata from the subscription to the invoice is helpful for setting standard or custom fields on the invoice. For instance, if there's an internal subscription order number that you want on every subsequent invoice, you can copy this number from the subscription metadata to the invoice metadata so the number can flow to the NetSuite invoice.

View Example Code

Connect Stripe Plans to Existing NetSuite Items

If you are using Stripe Subscriptions you can connect your Stripe Plans to existing items in NetSuite using the following migration tool.

View Example Code

Link Stripe Customers to NetSuite Customers by Email

If you've been using NetSuite for a while, but are just getting started with Stripe, you'll want to link your Stripe customers to the associated NetSuite customer. Here's an example of linking Stripe customers with NetSuite customers by using email as the linking key between the two systems.

View Example Code

Link Stripe Customers to NetSuite Customers Using a CSV

If you have existing NetSuite customers that you'd like to Stripe customers you can create a mapping between the two systems and use this script to link Stripe & NetSuite customers together.

View Example Code

Link Stripe Customers to NetSuite Customers Using Card Details

When migrating card data from another processor to Stripe the data provided by the old processor can sometimes be spotty. Use this script to match Stripe customers to a CSV row using card details (last4, zip, expiration, etc) and save additional customer data to Stripe from that CSV file.

View Example Code

Pay Due NetSuite Invoices Using Stripe

You can leverage SuiteSync to auto-pay invoices in NetSuite using Stripe. SuiteSync has built-in functionality to handle this, but you can also customize the example code below to fit your exact use-case.

View Example Code

Customer NetSuite Invoices created from Stripe Subscriptions

Each billing period a Stripe subscription creates an invoice in NetSuite. You can customize the data on that invoice by adding metadata to the Stripe subscription to be copied to each subsequent invoice.

View Example Code

Find Closed and Unpaid, or Forgiven Invoices

If you choose not to automatically close out unpaid or forgiven Stripe invoices in NetSuite, you will want to create a custom process around handled this "bad debt". Here's a starting point you can use to pull identify these invoices in Stripe.

View Example Code

Remove Metadata Keys

The integration adds metadata keys to Stripe records.. If you are developing customized integrations leveraging SuiteSync, it may be helpful to wipe all of the metadata keys that SuiteSync uses in order to re-run integration tests. Below is a script that wipes metadata keys from your Stripe account.

View Example Code

Demonstrate Stripe Subscriptions Edge Case

There are many edge cases that can occur when processing subscription payments. Below is a script that generates various subscription states so you inspect how they look in your NetSuite account.

View Example Code