Implementing Snap Checkout Button
The Snap Checkout button is designed to be a payment option for your website. When a customer clicks on the button, a modal window launches a customer application. When complete, the window will close and if financing is approved, an “Approved” event will be sent to your site with the associated ‘applicationId’. If financing is denied, a "Denied" event will be sent to your site with the associated 'applicationId.'
The merchant site may also monitor Notification and Error events sent from the process. The Checkout Button will render to the screen only when initialized with a valid token. Error messages and runtime errors will be returned to the merchant site if the token or the transaction is invalid.
Upon approval, the merchant may store the returned 'applicationId' value for later use in completing the transaction. The Checkout button may function as a standalone button or may be used in connection with the Snap Checkout Mark, which provides a Snap authorized graphic for use as a radio selection option.
Step 1. Import SDK Script
Import the script in the <head> section of your website, using the code snippet below. The script should load before your document body loads. The same script is used for both testing and production.
Step 2. Add Button Container
Add an element to your website to contain the Snap Checkout button.
Step 3. Setup Transaction
Obtain a reference to your shopping cart data. Format the transaction in JSON as shown. The transaction should confirm tospecification.You will pass this transaction to launchCheckout action.
Step 4. Initialize Snap
First initialize Snap with the web token you obtained for testing.
Replace this with the production token when you go live.
Step 5. Add Snap Checkout Button
Add this script (inline) to your checkout page, passing in the access token and transaction. This code will render the button to your page which, when clicked, will launch the Snap Checkout window.
When the transaction is approved by Snap, the “onApproved” method will be invoked, passing in the applicationId as a property on the data object. (i.e. data.applicationId). Store this value for use in Order Completion.
Step 6. Radio Button Implementation (optional)
For merchant checkout flows that employ radio buttons, Snap provides a branding marks to be displayed alongside the radio select option.
Include those marks alongside your radio button by adding a <div> element to your page with an id value of “snap-checkout-mark”. Then separately, add an inline script element for configuration of that mark, as shown.
The snapCheckoutMark configuration supports specification of a ‘light’ or ‘dark’ graphic, and a height between 25 and 55 (pixels). The width of the snap mark will adjust relative to the height.
See advanced implementation below for more options.