Collapse Menu
FastSpring App
Contact Support

Browser Scripts


Overview of Browser Scripts and how to add one to your Store

Browser scripts (previously called "browser webhooks") are custom-defined JavaScript functions that run inside the browser window. For Web Storefronts, browser scripts will be executed inside the sandbox. For Popup Storefronts, browser scripts will be executed inside the sandbox and passed to the container page via the callback defined using the JavaScript API. For Popup Storefronts, you can leave function () empty if you only want the event to be passed to the container page and not run inside the sandbox.


A browser script is defined as a JavaScript function similar to this:

  • function(event) {      
      /* Custom Code Here */

Load External Scripts

It is common to require external scripts within the hook. To load external scripts, use the following approach within the function:

  • this.load('https://scripturl';, callback);  //"callback" is a function() to execute after the script has been successfully loaded.

Add a Browser Script

  1. Click Add Browser Script. The Add Browser Script popup dialog appears.
  2. In the Name field, optionally enter an internal name for the script to help you identify it if you create more than one.
  3. In the Events section, select browser.order.completed.
  4. In the Function text area, enter or paste your JavaScript code.
  5. Click Add.


BROWSER.ORDER.COMPLETED - fired upon successful order completion after fulfillment actions were performed.

  • {  
       "id":"ZxcLBaJaR2i7N2DYAo7PbQ",                    // hook id - do not use
       "created":1475702220909,                          // created timestamp, in milliseconds
       "type":"browser.order.completed",                 // type of event
       "live":false,                                     // true if not a test order
       "data":{                                          // order data
          "id":"8nEf7SIgR4SjUUspka4oWQ",                 // FastSpring-internal order ID to be used for all order-related requests
          "reference":"KYR161005-9065-20156",            // customer-facing order ID
          "live":false,                                  // true if not a test order
          "total":15,                                    // order total
          "totalDisplay":"USD 15.00",                    // order total, formatted for display
          "totalInPayoutCurrency":"15",                  // order total in payout currency
          "totalInPayoutCurrencyDisplay":"USD 15.00",    // order total in payout currency, formatted for display
          "taxDisplay":"USD 0.00",
          "taxInPayoutCurrencyDisplay":"USD 0.00",
          "subtotalDisplay":"USD 15.00",
          "subtotalInPayoutCurrencyDisplay":"USD 15.00",
          "discountDisplay":"USD 0.00",
          "discountInPayoutCurrencyDisplay":"USD 0.00",
          "discountWithTaxDisplay":"USD 0.00",
          "discountWithTaxInPayoutCurrencyDisplay":"USD 0.00",
          "totalDisplay":"USD 15.00",
          "totalInPayoutCurrencyDisplay":"USD 15.00",
          "tags": {
            "key1":"value1"                              // custom order-level tags defined via Store Builder Library or Custom Orders
          "items":[                                      // array of items in the order
                "subtotalDisplay":"USD 10.00",
                "subtotalinPayoutCurrencyDisplay":"USD 10.00",
                "discountDisplay":"USD 0.00",
                "discountInPayoutCurrencyDisplay":"USD 0.00",
                "subtotalDisplay":"USD 5.00",
                "subtotalInPayoutCurrencyDisplay":"USD 5.00",
                "discountDisplay":"USD 0.00",
                "discountInPayoutCurrencyDisplay":"USD 0.00",
                         "display":"License Key",
                   "instructions":"<p><br/> License Key: asdf<br/></p>"
       "digest":null                                     // digest checksum