Frontend (web pages)
Include the library
<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
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”});