Purchase Flow Callbacks Follow


The purchase flow has an event-driven API attached to it. You may register functions with the purchase flow that can be fired when events are triggered. This can allow more highly customized experiences than Topspin provides out of the box - be it cart abandonment messages, secondary share flows, additional special offers, and so on.

This functionality is available on any page where a standard offer has embedded - no special configuration is needed.

Responding to Events

The purchase flow triggers events when certain conditions are met. You can listen for those events and Functions are registered via a simple call:

Registering a Listener:


For example, if you wanted to call your function "displayThankYouMessage" after PURCHASE_COMPLETE, your code might look like:


  • eventType is the event that will trigger your function. The current list of available event types are:
    • PURCHASE_COMPLETE - This event occurs when the purchase has been completed. It happens when the receipt/download links are displayed in the purchase flow.
    • LIGHTBOX_OPEN - This event is what signals the display of the purchase flow and the addition of the lightbox to the page.
    • LIGHTBOX_CLOSE - This event is the inverse of LIGHTBOX_OPEN. It is called when the purchase flow is hidden and the lightbox is removed from the page.
    • CART_UPDATE - This event is triggered when you add items to the cart via the addToCart method (documented later). It also calls on a page load and lightbox close when the quantity of the cart contents is changed. This event corresponds to the refreshing of the cart indicator on the page.
  • callback is the function you wish to have triggered. For instance, if you have a function called displayThankYouMessage() that is shown to thank a user for purchase, you will put "displayThankYouMessage" here, and not the full function call (e.g. "displayThankYouMessage()"). If your function definition includes a parameter, e.g. function displayThankYouMessage(jsonData) { //etc }, it will have access to the JSON response objects.

These are the response objects that are returned.

Lightbox Open


Lightbox Close


Purchase Complete


Cart Update


Have more questions? Submit a request and our team will be able to help get you sorted.
Powered by Zendesk