Callbacks Documentation
Edit on
Codepen.io
Codepen.io
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.
x
48
1
<h2>To Complete A Purchase</h2>
2
<p>You can use any date in the future for the card expiration date, and you can use any values for other purchase data such as your name, so long as you used the test card numbers shown below.</p>
3
<ul>
4
<li>Card Number: 4242 4242 4242 4242</li>
5
<li>CVV Code: *E4FP</li>
6
</ul>
7
8
<!--
9
Configure a checkout button.
10
-->
11
<button onclick="fastspring.builder.checkout();">Checkout</button>
12
13
<!--
14
DEMO EFFECTS
15
- The below div will be updated to include the returned data from the data-popup-webhook-received
16
-->
17
<br /><br />Data returned: <div id="log"></div>
18
19
<!--
20
DEMO SETUP
21
- Initialize the Store Builder Library
22
-->
23
<script
24
id="fsc-api"
25
src="https://sbl.onfastspring.com/sbl/1.0.2/fastspring-builder.min.js"
26
type="text/javascript"
27
data-storefront="fastspringexamples.test.onfastspring.com/popup-fastspringexamples"
28
data-popup-closed="dataPopupClosed"
29
data-continuous="true">
30
</script>
31
32
<!--
33
Initialize the cart for demo purposes
34
-->
35
<script>
36
fastspring.builder.reset();
37
fastspring.builder.add("phot-io-main-app");
38
</script>
39
40
<!--
41
dataPopupClosed
42
- In this example, it will write div with the id log with the returned data.
43
-->
44
<script>
45
function dataPopupClosed(data) {
46
document.getElementById("log").innerHTML = "<pre>"+JSON.stringify(data, null, 4)+"</pre>";
47
}
48
</script>
1
1
1
1