1.0.0 • Published 5 years ago
cardpay-headway v1.0.0
CardPay
Installation
$ npm install cardpay-sdk --saveDocumentation
configure(configObj);
Configuration global parameters.
Arguments
configObjproduction- true for production and false for sandbox (Defaultfalse)g_type- grant_type (Should bepasswordas stated in OAuth specification)t_code- terminal_code (Unique terminal code used by the Cardpay payment system)pwd- password (Terminal password)c_secret- callback secret (Callback secret is also generated by Cardpay and received by Merchant with terminal code)
Usage
const cardpay = require('cardpay-sdk')
let configObj = {
production: false,
g_type: '',
t_code: '',
pwd: '',
c_secret: ''
}
cardpay.configure(configObj);pay(paymentParams, configObj);
Create redirect url
Arguments
paymentParamsm_id- Merchant Order ID Requiredm_desc- Merchant Order Description Required orglobal configp_method- Payment Method Required orglobal configpd_currency- Payment Currency Optional orglobal configpd_amount- Payment Amount Requiredc_id- Unique Customer ID Requiredc_email- Customer Email Address Requiredc_locale- Customer Language Optional orglobal configru_success- Return Success URL Required orglobal configru_decline- Return Decline URL Required orglobal configru_cancel- Return Cancel URL Required orglobal configru_inprocess- Return In Process URL Required orglobal config
configObj- Optional - useglobal configfirst
Usage
let paymentData = {
m_id: "00b46e01-3994-4ac2-939e-2d5052a65961",
m_desc: 'sdasda',
p_method: 'BANKCARD',
pd_currency: 'EUR',
pd_amount: "5.01",
c_email: "x@x.io",
c_id: "5sad3e123",
c_locale: "en",
ru_success: "http://70e47cb2.ngrok.io/success",
ru_decline: "http://70e47cb2.ngrok.io/decline",
ru_cancel: "http://70e47cb2.ngrok.io/cancel",
ru_inprocess: "http://70e47cb2.ngrok.io/process",
};
let options = {
test: true
}
// using async/await
try{
let payment = await cardpay.pay(paymentData, options);
}
catch(e){
// catch errors
}
// using promises
cardpay.pay(paymentData)
.then(success => {
// redirect URL
};
.error(err => {
}}verify(options);
Verify callback signature middleware
Arguments
options- Optional - "domain"
Usage
app.post('/callback' , cardpay.verify(['ngrok.io']), async function(req, res, next) {
// your code here
}1.0.0
5 years ago