Stripe to NetSuite Payment Import

Overview

This integration syncs Stripe payments into NetSuite through PayPack. It looks at the open NetSuite invoices that originated from Stripe, checks the matching Stripe invoice for paid payment intents, and creates a NetSuite Customer Payment for each one.

Payments are imported on a schedule (Batch). The flow uses the same PayPack configuration and mapping framework as the other Data Orchestration flows, and every run is logged for troubleshooting

Configuration Settings

All payment settings are located under the Payments subtab within the Data Orchestration tab. Inside this subtab, the Payment Settings field group contains all configuration fields required for managing the Payments flow.

Note: Click any field label in the Payment Settings field groups to see a description of its purpose and usage.


 

Field Descriptions

  • Enable Payments Flow: Check/mark to enable importing Stripe payments into NetSuite. Uncheck to stop all payment imports.



 

  • Update Stripe Payment Metadata: Check/mark to automatically write the NetSuite Customer Payment record's Internal ID  back to the corresponding Stripe payment intent after it is created.


     

  • Include Payments Paid Outside of Stripe: Check/mark to allow importing payments that were paid outside of Stripe. When enabled, a Customer Payment record is created using the invoice's total amount with no Stripe payment intent ID. When unchecked, such payments are skipped.


     

  • Saved Search for Open NetSuite Invoices (Originating from Stripe): The NetSuite saved search that identifies open invoices eligible for payment import. Only invoices returned by this search are processed. The standard search, "PayPack Open Invoices Saved Search" , returns invoices that meet the following criteria:

    • Type is Invoice
    • Status is Invoice: Open
    • Stripe Invoice Id (PayPack) is not empty
    • Main Line is true
      Note: Always create a copy of the bundle/SuiteApp search so that updates to the bundle/SuiteApp do not overwrite any criteria that you may have added. Also, do not modify the existing results.

       
  • Account: Select the NetSuite account where Stripe payments will be recorded. All imported payments are posted to this account.



 

  • Payment Method: Select the payment method in NetSuite for recording Stripe payments.

 

  • Payment Method (Paid Outside of Stripe): Select the payment method in NetSuite for recording Stripe payments that are paid outside of Stripe.

Note: To use condition-based mapping, leave the Payment Account, Payment Method, or Payment Method (Paid Outside of Stripe) fields empty and use static or dynamic mapping. Filling in these fields sets a global default that overrides any conditional logic in the Customer Payment Field Mappings.

  • Customer Payment Field Mappings: Controls how Stripe Payment (Payment Intent) fields are mapped to NetSuite Customer Payment fields and allows inclusion of related invoice and customer data from the saved search.

Note: Note: Fields from the Stripe payment intent object can be used. The NetSuite invoice and customer IDs from the saved search are available through the nsData object (for example, nsData.nsInvoiceId, nsData.nsCustomerId). Use them to apply the payment to the correct invoice.


How the Import Works

The Batch flow runs these steps.

1. Get invoices

  • Eligible NetSuite invoices are fetched using the configured saved search (open invoices with the Stripe Invoice Id (PayPack) field filled in).
  • Only invoices returned by the saved search are considered.

2. Fetch the Stripe invoice and payment intents

  • For each eligible invoice, the full Stripe invoice is fetched using the Stripe invoice ID from the saved search.
  • PayPack goes through the invoice's payments and fetches the full payment intent for each payment with status paid that has an associated payment intent.

3. Create Customer Payment records

A NetSuite Customer Payment is created for each eligible Stripe payment intent, or for each outside-Stripe payment when that option is enabled.

Stripe invoice situation Result
Open, with no payment intents Skipped entirely
Paid or partially paid, payment intent already in NetSuite (matched on custbody_pp_s2ns_payment_intent_id) Skipped, to prevent duplicates
Paid or partially paid, payment intent not yet imported New Customer Payment created using the Customer Payment Field Mappings
Paid with no payment intents (paid outside of Stripe), Include Payments Paid Outside of Stripe off Skipped
Paid with no payment intents (paid outside of Stripe), Include Payments Paid Outside of Stripe on Customer Payment created for the invoice total, using the Payment Method (Paid Outside of Stripe)

See the sample mapping at the end of this article and the Field Mapping Documentation for detailed examples.

4. Update Stripe metadata

  • The NetSuite Customer Payment record ID is written back to the Stripe payment intent.
  • Skipped if Update Stripe Payment Metadata is not checked.

5. Log the run

  • Each run is recorded in the PayPack Flow Status Log and Flow Record Log (see Logging).

Script Details

Batch (Map/Reduce)

Script: PayPack S2NS Payments Import MR. Runs on a schedule you define.

  • Unlike the invoice and customer imports, this script does not use a Last Exported Date. It works from the saved search results and fetches the payments of those invoices in full each run.
  • 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.

Deploying and Scheduling

  1. Go to Customization > Scripting > Scripts.
  2. Filter by Type: Map/Reduce and search for PayPack S2NS Payments Import MR. Click View.
  3. Click Deploy Script.
  4. On the deployment, set the Stripe Account Id parameter to the internal ID of the relevant PayPack Stripe Account Configuration record.
  5. 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.
  6. Click Save.

Sample Field Mappings

{
  "fields": [
    {
      "generate": "subsidiary",
      "hardCodedValue": "1"
    },
    {
      "generate": "payment",
      "handlebars": "{{toFixed (divide amount 100) 2}}"
    },
    {
      "generate": "paymentmethod",
      "hardCodedValue": "10"
    },
    {
      "generate": "account",
      "hardCodedValue": "2"
    },
    {
      "generate": "custbody_pp_s2ns_payment_intent_id",
      "extract": "id",
      "fieldType": "internalid"
    },
    {
      "generate": "custbody_nm_stripe_dcharge_id",
      "extract": "latest_charge.id"
    },
    {
      "generate": "custbody_pp_stripe_bal_txn_id",
      "extract": "latest_charge.balance_transaction"
    }
  ],
  "sublist": {
    "apply": [
      {
        "generate": "apply",
        "hardCodedValue": "T"
      },
      {
        "generate": "doc",
        "extract": "nsData.nsInvoiceId"
      }
    ]
  }
}



 

Was this article helpful?
0 out of 0 found this helpful

More resources