SecurionPay.js is a browser-side JavaScript library that can be used securely collect sensitive payment information (like credit card number).
This documentation describes every object and every method available in that library.
SecurionPay.js should be included on each page of your site that will be used to collect payment
information. It should always be loaded directly from https://js.securionpay.com
,
rather than bundled or hosted on your website.
<script type="text/javascript" src="https://js.securionpay.com/v2/securionpay.js"></script>
To start using SecurionPay.js
first thing that you need to do is to call SecurionPay()
method to create and configure a SecurionPay object.
Create and configure new SecurionPay object.
EXAMPLE
var securionPay = SecurionPay("pu_test_WVMFC9GFuvm54b0uorifKkCh");
SecurionPay object is a main entry point to all functionalities available in
SecurionPay.js
.
Create a new component of given type.
EXAMPLE
var card = securionPay.createComponent("card");
Create a new grouping object that will be used to create multiple related components - for example
to create number
, expiry
and cvc
components that together
will be used to collect details of single card.
EXAMPLE
var components = securionPay.createComponentGroup();
Collect card data from given component or component group and send it to "create token" API method for tokenization.
number
, expMonth
, expYear
and
cvc
. Values of these fields must be collected using components.
a Promise object
EXAMPLE
var card = securionPay.createComponent("card");
function onFormSubmit() {
securionPay.createToken(card)
.then(tokenCreatedCallback)
.catch(errorCallback);
}
Starts a 3D Secure process.
Depending on card and card's issuer this can result in showing 3D Secure challenge in
iframe
or popup window.
a Promise object
EXAMPLE
function tokenCreatedCallback(token) {
var request = {
card: token.id,
amount: 2499,
currency: 'EUR',
};
securionPay.verifyThreeDSecure(request)
.then(threeDSecureCompletedCallback)
.catch(errorCallback);
}
Component object is used to securely collect sensitive information (like card number or cvc).
Mounts component to placeholder tag located by given selector
.
Component object on which this method was called
EXAMPLE
var components = securionpay.createComponentGroup();
var number = components.createComponent("number").mount("#number");
Removes any value currently present in a component.
a Component object on which this method was called
EXAMPLE
var card = securionpay.createComponent("card");
card.clear();
ComponentGroup object is used to group components when that are multiple components needed to collect card details of a single card.
Automatically search all tags nested under tag located by given selector
and create
components on all tags that have data-securionpay
attribute.
Value of that attribute is used as component's type
.
data-securionpay
attribute.
a ComponentGroup object on which this method was called
EXAMPLE
var components = securionpay.createComponentGroup().automount("#payment-form");
Create a new component of given type and assign it to this component group.
EXAMPLE
var components = securionpay.createComponentGroup();
var number = components.createComponent("number");