KonnectedPay Cordova Plugin
Installation
-
Install this plugin using the Cordova command line tools:
cordova plugin add cordova-plugin-konnectedpay
-
On any page where you want to use the .getTokens()
method, configure the
Content Security Policy by adding the directive
connect-src https://*.appxtream.com
to the Content-Security-Policy
META
tag, e.g.
<meta
http-equiv="Content-Security-Policy"
content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *; connect-src https://*.appxtream.com"
/>
Android
On Android, a few more steps are required:
Usage
Requesting Payment
Requesting payment with payment form page:
konnectedpay.requestPayment(
{
merchantId: "your konnectedpay merchant id",
clientSecret: "your konnectedpay client secret",
amount: 1234.56,
transId: "your unique transaction id",
currencyCode: "MYR",
fullName: "payer's full name",
email: "payer's email address",
userId: "your internal user ID",
rememberCard: true,
},
function (results) {
},
function (results) {
}
)
Requesting payment with existing token (credit card) - skips payment page:
konnectedpay.requestPayment(
{
merchantId: "your konnectedpay merchant id",
clientSecret: "your konnectedpay client secret",
amount: 1234.56,
transId: "your unique transaction id",
currencyCode: "MYR",
fullName: "payer's full name",
email: "payer's email address",
userId: "your internal user ID - used with konnectedpay.getTokens() method",
token: "token from konnectedpay.getTokens() method",
},
function (results) {
},
function (results) {
}
)
The success or failure callback will receive only one argument:
{
status: "status",
desc: "...",
code: "...",
amount: "1234.56",
transId: "the transaction id specified in requestPayment()",
}
Note: You can only have 1 payment at any time - requesting a payment while the
previous payment is still in progress will result in failure.
Retrieving Tokenised Payment Methods (credit cards)
Each time your users successfully make a payment, if they have not un-checked
the Remember My Card option on the payment page, their credit card information
will be saved in KonnectedPay as a "token".
konnectedpay.getTokens(
{
merchantId: "your konnectedpay merchant id",
clientSecret: "your konnectedpay client secret",
userId: "your internal user ID - used with konnectedpay.getTokens() method",
},
function (results) {
},
function (errMsgOrUndefined) {
}
)
Make sure that you have configured the Content Security Policy on the page where
you are calling this function. Add connect-src https://*.appxtream.com
to the
Content-Security-Policy
META tag.
Troubleshooting
Unable to load tokens - getTokens fails with undefined
error
Make sure you have configured the Content Security Policy on the page where you
are calling .getTokens()
. You must add this directive:
connect-src https://*.appxtream.com
e.g.
<meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *; connect-src https://*.appxtream.com">