cardpay-headway
v1.0.0
Published
CardPay nodejs implementation.
Downloads
2
Readme
CardPay
Installation
$ npm install cardpay-sdk --save
Documentation
configure(configObj);
Configuration global parameters.
Arguments
configObj
production
- true for production and false for sandbox (Defaultfalse
)g_type
- grant_type (Should bepassword
as 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
paymentParams
m_id
- Merchant Order ID Requiredm_desc
- Merchant Order Description Required orglobal config
p_method
- Payment Method Required orglobal config
pd_currency
- Payment Currency Optional orglobal config
pd_amount
- Payment Amount Requiredc_id
- Unique Customer ID Requiredc_email
- Customer Email Address Requiredc_locale
- Customer Language Optional orglobal config
ru_success
- Return Success URL Required orglobal config
ru_decline
- Return Decline URL Required orglobal config
ru_cancel
- Return Cancel URL Required orglobal config
ru_inprocess
- Return In Process URL Required orglobal config
configObj
- Optional - useglobal config
first
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: "[email protected]",
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
}