Data Orchestration JSON Mappings: Translating Stripe Data into NetSuite

Mappings tell PayPack’s Data Orchestration flows how to translate data from Stripe into NetSuite. In this guide, Stripe is the source system and NetSuite is the destination. Each mapping connects a Stripe source field to a NetSuite field ID, so records like invoices and customer payments are created with the right values.

How a mapping works

Every mapping has a generate property (the NetSuite field ID to populate) and one property that says where the value comes from.

{ "generate": "duedate", "extract": "due_date" }

This takes due_date from Stripe and puts it into the NetSuite field duedate.

The extract property pulls a value from the Stripe payload using dot notation. Each level of the path drills deeper into the object.

Example pathRefers to
idRoot-level ID of the object
customer.emailEmail of the customer on the invoice
lines.data.0.quantityQuantity on the first line item
total_discount_amounts.0.amountAmount on the first discount
parent.stripeInvoiceData.nsInvoiceIdNetSuite invoice ID carried on the parent Stripe invoice (used when applying payments)

Structure

A mapping object has two parts:

SectionPurpose
fieldsBody-level (header) fields on the NetSuite record, such as due date or department. These map directly to properties on the main record object, for example {{due_date}} for the invoice due date.
sublistLine-level details. Supported sublists are item and apply, plus discount and tax for discount and tax lines. These map to objects inside a sublist array, so paths must account for the array structure.


 

{
 "fields": [ ... ],
 "sublist": { "item": [ ... ] }
   }

Arrays: Body-level fields hold a single value, so use .0 to select one array element (for example lines.data.0.quantity). In sublists, use [] to repeat the mapping for every line (for example lines.data[].quantity).

To pick out one specific line, use its index. For example, {{lines.0.amount}} takes the amount from the first Stripe line and maps it to the item sublist in NetSuite.

Where each option can be used

Every option works at both levels except useTheValueForRecordInitialization, which is body-level only.

OptionPurposeBody levelLine level (sublist)
extractPulls a value from the Stripe payload using a pathYesYes
hardCodedValueAssigns a fixed valueYesYes
staticLookupMaps incoming values using a predefined value mapYesYes
dynamicLookupSearches NetSuite in real time and returns the matching record's internal IDYesYes
handlebarsRuns calculations or formatting inside the mappingYesYes
fieldTypeTells NetSuite the data type (for example date, currency, text, internalid)YesYes
useTheValueForRecordInitializationSets the field when the record is first created, not afterwardYesNo

Tip: The options are the same at both levels, but you must adjust paths and expressions to match the record and level you are mapping.

Body-level mapping types

Body-level mappings populate NetSuite header fields. They can use extract, hardCodedValue, staticLookup, dynamicLookup or handlebars, and can also set useTheValueForRecordInitialization and fieldType.

extract

Pulls a value straight from the Stripe payload.

{ "generate": "custbody_pp_stripe_invoice_id", "extract": "id" }

hardCodedValue

Sets a field to the same static value every time. No data is extracted.

{ "generate": "custbody25", "hardCodedValue": "78946" }

staticLookup

Maps specific Stripe values to NetSuite values using a fixed table. If nothing matches, the default is used.

{
"generate": "currency",
"extract": "currency",
 "staticLookup": {
  "map": { "usd": 1, "eur": 2 },
   "default": 3
  }
}

dynamicLookup

Searches NetSuite in real time to find the matching record's internal ID, based on Stripe data. Use {{ }} in filters to insert a Stripe value. Filters must be in the format accepted by NetSuite's search.create.

The example below finds the currency record whose symbol matches the Stripe currency, and falls back to 1 if there is no match.

{
 "generate": "currency",
 "dynamicLookup": {
  "recordType": "currency",
 "filters": [["symbol", "is", "{{currency}}"]],
  "resultField": "internalid",
  "default": 1
 }
}

handlebars

Runs small calculations or formatting using Handlebars templates. This example divides a Stripe amount (in cents) by 100 and formats it to two decimals.

{ "generate": "memo", "handlebars": "{{toFixed (divide amount 100) 2}}" }

See Handlebars helpers for the full list.

useTheValueForRecordInitialization

Some NetSuite fields must be set at the moment the record is created, not afterward. Set this property to true and the value is applied during record creation, before any other fields or lines are added. Body level only.

{
  "generate": "entity",
  "hardCodedValue": 1,
  "useTheValueForRecordInitialization": true
}

fieldType

Tells NetSuite how to interpret the value, for example date, currency, text or internalid. "date" ensures a date is read as a date.

{ "generate": "duedate", "extract": "due_date", "fieldType": "date" }

Handlebars helpers

In addition to standard Handlebars.js helpers, PayPack supports these:

HelperExampleWhat it does
add{{add 5 10}}Adds two numbers (returns 15)
subtract{{subtract 10 3}}Subtracts the second value from the first (returns 7)
multiply{{multiply 4 2}}Multiplies two numbers (returns 8)
divide{{divide 100 4}}Divides the first number by the second (returns 25)
toFixed{{toFixed 12.3456 2}}Fixes decimal places (returns 12.35)
dateFormat{{dateFormat due_date 'America/New_York' 'MM/DD/YYYY HH:mm:ss'}}Formats a date with a timezone and format mask. Accepts Date objects, Unix timestamps (seconds or milliseconds) and date strings.
compare{{#compare amount_due '>' 100}}High{{else}}Low{{/compare}}Conditional on a comparison. Supports ==, ===, !=, !==, <, <=, >, >=.
split{{split customer_email '@' 0}}Splits a string and returns the value at a zero-based index. Returns an empty string if the input is empty or the index is out of range.
splitName{{splitName name 'last'}}Splits a full name on any amount of whitespace and returns the requested part: 'first', 'middle', 'last' or 'rest' (everything after the first word). For "Mary Ann Smith": first = Mary, middle = Ann, last = Smith, rest = Ann Smith. Returns empty if that part doesn't exist (for example 'last' for a single-word name).
if / else{{#if customer_email}}Email Exists{{else}}No Email{{/if}}Conditional on whether a value is truthy

Line-level (sublist) mapping types

Sublist mappings support extract, hardCodedValue, staticLookup, dynamicLookup, handlebars and fieldType, the same as body-level fields. useTheValueForRecordInitialization is not available here.

  • The item sublist sets line items on records like an invoice.
  • The apply sublist applies lines on records like a customer payment (for example, applying an invoice).
  • The discount and tax sublists add discount and tax lines (see Tax and discount lines).

Use [] in paths to repeat the mapping for every line, such as lines.data[].quantity.

Transaction types without an item sublist

Some transaction types have no item sublist. For those, the line mapping sits directly under sublist, still using [] to repeat for every line:

{
  "sublist": {
    "generate": "quantity",
    "handlebars": "{{lines.data[].quantity}}"
  }
}

Item sublist examples

Extract the quantity for every line:

{ "sublist": { "item": [ { "generate": "quantity", "extract": "lines.data[].quantity" } ] } }

Set the same location on every line with a hard-coded value:

{ "sublist": { "item": [ { "generate": "location", "hardCodedValue": "2" } ] } }

Map a Stripe period end date into a custom line date field with fieldType:

{
  "sublist": {
    "item": [
      { "generate": "custitem26", "extract": "lines.data[].period.end", "fieldType": "date" }
    ]
  }
}

Look up the NetSuite item from the Stripe product ID. This finds an active inventory item whose stockdescription matches the Stripe product, and uses item 502 if none is found:

{
  "generate": "item",
  "dynamicLookup": {
   "recordType": "inventoryitem",
    "filters": [
      ["stockdescription", "is", "{{lines.data[].pricing.price_details.product}}"],
      "and",
      ["isinactive", "is", "F"]
    ],
    "resultField": "internalid",
    "default": "502"
  }
}

Map specific Stripe products to fixed NetSuite items with a static lookup:

{
  "generate": "item",
  "extract": "lines.data[].pricing.price_details.product",
  "staticLookup": {
    "map": { "prod_THs2r4MlsMSkBw": "2014", "prod_Q1QFO7q1rsBuYu": "503" },
    "default": 501
  }
}

Convert a unit price from cents to dollars:

{
  "generate": "rate",
  "handlebars": "{{toFixed (divide lines.data[].pricing.unit_amount_decimal 100) 2}}"
}

Apply sublist examples

Mark the line as applied with a hard-coded value:

{ "sublist": { "apply": [ { "generate": "apply", "hardCodedValue": "T" } ] } }

Set the invoice to apply with a simple path:

{ "sublist": { "apply": [ { "generate": "doc", "extract": "parent.stripeInvoiceData.nsInvoiceId" } ] } }

Date field: pass the Stripe invoice due date as a date.

{
  "sublist": {
    "apply": [
      { "generate": "duedate", "extract": "parent.stripeInvoiceData.due_date", "fieldType": "date" }
    ]
  }
}

Text field: look up the invoice's document number (tranid) and pass it as text into refnum.

{
  "sublist": {
    "apply": [
      {
        "generate": "refnum",
        "dynamicLookup": {
          "recordType": "invoice",
          "filters": [
            ["internalid", "is", "{{parent.stripeInvoiceData.nsInvoiceId}}"],
            "and",
            ["mainline", "is", "T"]
          ],
          "resultField": "tranid",
          "default": ""
        },
        "fieldType": "text"
      }
    ]
  }
}

Lookup patterns

The lookup key can be a root-level value, a nested path, or a path inside an array. These patterns work in any sublist.

Static lookup

Simple key (root-level value):

{
  "sublist": {
    "item": [
      {
        "generate": "custcol_nm_vstyledesc",
        "extract": "id",
        "staticLookup": {
          "map": {
            "in_1SHhaFCzzXCPoFbP9hFIZ8HO": "in_1SHhaFCzzXCPoFbP9hFIZ8HO",
            "in_1SIPUEGuTaMUDQinGPQRX2TN": "in_1SIPUEGuTaMUDQinGPQRX2TN"
          },
          "default": "in_1SHhaFCzzXCPoFbP9hFIZ8HO"
        }
      }
    ]
  }
}

Path key (nested value):

{
  "sublist": {
    "item": [
      {
        "generate": "custcol_nm_vstyledesc",
        "extract": "customer_shipping.address.city",
        "staticLookup": {
          "map": { "Oakland": "Oakland", "New York": "New York" },
          "default": "Oakland"
        }
      }
    ]
  }
}

Path with array (one lookup per array element, for a transaction type without an item sublist, so the mapping sits directly under sublist):

{
  "sublist": {
    "generate": "item",
    "extract": "total_taxes[].tax_rate_details.tax_rate",
    "staticLookup": {
      "map": {
        "di_1SFu9rCzzXCPoFbPKdHgMuxj": "1010",
        "di_1SFu9jCzzXCPoFbPApwQpRG6": "1010"
      },
      "default": 1010
    }
  }
}

Dynamic lookup

Extract direct (root-level value in the filter). Finds the invoice whose custbody25 matches the Stripe object ID:

{
  "sublist": {
    "apply": [
      {
        "generate": "line",
        "dynamicLookup": {
          "recordType": "invoice",
          "filters": [["custbody25", "is", "{{id}}"]],
          "resultField": "internalid",
          "default": ""
        }
      }
    ]
  }
}

Extract with path (nested value in the filter):

{
  "sublist": {
    "apply": [
      {
        "generate": "line",
        "dynamicLookup": {
          "recordType": "invoice",
          "filters": [["internalid", "is", "{{parent.stripeInvoiceData.nsInvoiceId}}"]],
          "resultField": "internalid",
          "default": ""
        }
      }
    ]
  }
}

Extract with path and array: see the inventory item lookup on lines.data[].pricing.price_details.product under Item sublist examples.

AND / OR filters: nest filter arrays the same way as NetSuite saved searches. This finds the main line of an invoice whose custbody_pp_stripe_invoice_id OR custbody25 matches the Stripe invoice ID:

{
  "sublist": {
    "apply": [
      {
        "generate": "line",
        "dynamicLookup": {
          "recordType": "invoice",
          "filters": [
            [
              [
                ["custbody_pp_stripe_invoice_id", "is", "{{parent.stripeInvoiceData.id}}"],
                "OR",
                ["custbody25", "is", "{{parent.stripeInvoiceData.id}}"]
              ],
              "AND",
              ["mainline", "is", "T"]
            ]
          ],
          "resultField": "internalid",
          "default": ""
        }
      }
    ]
  }
}

Tax and discount lines

When discounts and taxes are separate lines on the NetSuite transaction, map them in their own discount and tax sublists. NetSuite still treats each one as an item line. Include only the ones you need: just discount, just tax, or both.

Required fields:

  • Discount lines: always include item, quantity and rate, regardless of other line-level requirements.
  • Tax lines: only item and taxcode are required, plus any fields your NetSuite account makes mandatory on transaction lines.

Inclusive vs exclusive tax

Tax typeWhen it appliesWhat to map
InclusiveTax is already part of the item price in NetSuiteAdd { "generate": "ignoreInclusiveTax", "hardCodedValue": "true" } to the tax sublist so the inclusive tax is ignored and totals stay accurate
ExclusiveTax is not part of the item price, and the NetSuite rate field is mapped to the Stripe price before taxNo ignoreInclusiveTax needed. Tax appears as a separate line so the total matches.

Example

{
  "fields": [ ... ],
  "sublist": {
    "discount": [
      {
        "generate": "item",
        "extract": "total_discount_amounts[].discount",
        "staticLookup": {
          "map": {
            "di_1SKeCTCzzXCPoFbPIgJxwkgy": "1010",
            "di_1SFu9jCzzXCPoFbPApwQpRG6": "1010"
          },
          "default": 999
        }
      },
      { "generate": "quantity", "hardCodedValue": 1 },
      {
        "generate": "rate",
        "handlebars": "-{{toFixed (divide total_discount_amounts[].amount 100) 2}}"
      },
      { "generate": "taxcode", "hardCodedValue": "-7" }
    ],
    "tax": [
      { "generate": "item", "hardCodedValue": "2" },
      { "generate": "location", "hardCodedValue": "2" },
      { "generate": "taxcode", "hardCodedValue": "-7" },
      { "generate": "ignoreInclusiveTax", "hardCodedValue": "true" }
    ]
  }
}

The discount rate is negated (-{{...}}) so the line reduces the total. Drop the ignoreInclusiveTax line for tax-exclusive items.

Common mappings

Invoice

This maps a Stripe invoice to a NetSuite invoice with item, discount and tax lines.

{
  "fields": [
    { "generate": "custbody_pp_stripe_invoice_id", "extract": "id" },
    { "generate": "duedate", "fieldType": "date", "extract": "due_date" },
    { "generate": "custbody25", "extract": "payments.data.0.payment.payment_intent" }
  ],
  "sublist": {
    "item": [
      {
        "generate": "item",
        "dynamicLookup": {
          "recordType": "inventoryitem",
          "filters": [
            ["stockdescription", "is", "{{lines.data[].pricing.price_details.product}}"],
            "and",
            ["isinactive", "is", "F"]
          ],
          "resultField": "internalid",
          "default": "502"
        }
      },
      { "generate": "quantity", "handlebars": "{{lines.data[].quantity}}" },
      {
        "generate": "rate",
        "handlebars": "{{toFixed (divide lines.data[].pricing.unit_amount_decimal 100) 2}}"
      },
      { "generate": "location", "hardCodedValue": "2" },
      { "generate": "taxcode", "hardCodedValue": "-7" }
    ],
    "discount": [
      {
        "generate": "item",
        "extract": "total_discount_amounts[].discount",
        "staticLookup": {
          "map": {
            "di_1SKeCTCzzXCPoFbPIgJxwkgy": "1010",
            "di_1SFu9jCzzXCPoFbPApwQpRG6": "1010"
          },
          "default": 999
        }
      },
      { "generate": "quantity", "hardCodedValue": 1 },
      {
        "generate": "rate",
        "handlebars": "-{{toFixed (divide total_discount_amounts[].amount 100) 2}}"
      },
      { "generate": "taxcode", "hardCodedValue": "-7" }
    ],
    "tax": [
      { "generate": "item", "hardCodedValue": "2" },
      { "generate": "location", "hardCodedValue": "2" },
      { "generate": "taxcode", "hardCodedValue": "-7" }
    ]
  }
}

Customer payment

This maps a Stripe payment intent to a NetSuite customer payment and applies it to the related invoice.

{
  "fields": [
    { "generate": "payment", "handlebars": "{{toFixed (divide amount 100) 2}}" },
    { "generate": "custbody_pp_s2ns_payment_intent_id", "extract": "id", "fieldType": "internalid" },
    { "generate": "custbody_nm_stripe_dcharge_id", "extract": "latest_charge" }
  ],
  "sublist": {
    "apply": [
      { "generate": "apply", "hardCodedValue": "T" },
      { "generate": "doc", "extract": "parent.stripeInvoiceData.nsInvoiceId" }
    ]
  }
}

Tips

  • Prefer staticLookup when the set of Stripe values is small and stable. Use dynamicLookup when NetSuite is the source of truth, and always set a sensible default.
  • Use fieldType (date, currency, text, internalid) when NetSuite needs a hint about how to read a value.
  • Dynamic lookups can combine conditions with AND / OR using nested filter arrays, as in NetSuite saved searches.
  • Paths differ by record and level: .0 at body level, [] in sublists, and parent. to reach the parent Stripe invoice from a payment.
  • Handlebars are for light transformation. Keep complex logic out of mappings.
Was this article helpful?
0 out of 0 found this helpful

More resources