fastspring callback fucntions
Callbacks are JavaScript functions that are performed after another FastSpring Store Builder Library function has finished executing. These callbacks are defined in the Store Builder Library script definition. The callback to be performed are defined in JavaScript.
<script
id="fsc-api"
src="https://d1f8f9xcsvx3ha.cloudfront.net/sbl/0.8.1/fastspring-builder.min.js"
type="text/javascript"
data-storefront="fastspringexamples.test.onfastspring.com/popup-fastspringexamples"
data-popup-closed="dataPopupClosed">
</script>
<script>
console.log("This is a callback that is called when the popup is closed");
</script>
Callbacks – JavaScript Functions
data-data-callback – A JavaScript function you should provide, which will be invoked when new JSON (“order object”) is obtained from the server. This function must accept 1 parameter, an object.
data-error-callback – A JavaScript function you should provide, which will be invoked when an error is received from the backend. This function must accept 2 parameters, an error code and an error string.
data-before-requests-callback – A JavaScript function you should provide, which will be invoked before the request is performed. No parameters are passed to this function.
data-after-requests-callback – A JavaScript function you should provide, which will be invoked after the request is performed. No parameters are passed to this function.
data-before-markup-callback – A JavaScript function you should provide, which will be invoked before the markup is performed. No parameters are passed to this function.
data-after-markup-callback – A JavaScript function you should provide, which will be invoked after the markup is performed. No parameters are passed to this function.
data-validation-callback – An optional JavaScript function you can provide, which must accept a JSON object consisting of an array with field validation results. This makes it easier to display user-friendly field validation error messages.
data-popup-webhook-received – A JavaScript function you may provide, which will be invoked when the webhook event is received from the Popup store. This function must accept 1 parameter, an object. To setup webhooks, login to Dashboard and navigate to Integrations > Webhooks. At least one event will always fire on successful order containing basic order information.
data-popup-closed – A JavaScript function you may provide, which will be invoked when popup is closed. The function must accept an object which will contain the internal FastSpring order ID (key: id) and a customer-facing order reference (key: reference). The order id will only be passed upon successful order completion. If the popup is closed before the order is completed, “null” will be passed.