This page describe the frontend processing for web pages. Check here for iOS or Android.

The Javascript library is used for the payment process on the Checkout Session flow. It will redirect the browser / web view to the gateway hosted checkout session to let the card hold input the card details.

Include the library
Add this at the beginning of the page
<script src=”https://library-checkout.spiralplatform.com/js/v2/spiralpg.min.js”></script>
 

Approach 1: Payment in the pop up box

To do this, call an an asynchronized call to initialize the payment first, and then call the pay function.
Please note that there will not be event raising when initialization completed, but it would be less than 1 second in most of the cases.

Syntax (init)
SpiralPG.init(sessionID, [config])

Parameters

Data Field

Description

Rule

sessionID

The session ID returned by Spiral Checkout on createOrder

M

config

An object of configuration parameters.

O

config.locale

Control the language displayed. By default, the pages provided by Spiral Checkout will be displayed in both traditional Chinese and English.

E.g. zh_HK, zh_CN, en_US

O

Return Value
null

Example
SpiralPG.init(“dummy-session-id”, {locale:”zh_HK”});

Proceed the checkout

This should be called after SpiralPG.init (suggested to wait 500ms), and re-try the call if the redirection is not working.

 

Syntax (pay)
SpiralPG.pay()

Parameters
null

Return Value
null

Approach 2: Payment in the new page

This approach will generate the payment information in the new page.

 

Syntax
SpiralPG.redirectToPay(sessionID, [config])

Parameters

Data Field

Description

Rule

sessionID

The session ID returned by Spiral Checkout on createOrder

M

config

An object of configuration parameters.

O

config.locale

Control the language displayed. By default, the pages provided by Spiral Checkout will be displayed in both traditional Chinese and English.

E.g. zh_HK, zh_CN, en_US

O

Return Value
null

Example
SpiralPG.init(“dummy-session-id”, {locale:”zh_HK”});