mpay24-node

Offical mPAY24 node.js SDK
Installation
npm install mpay24-node --save
Documentation
A short demo implementation guide is available at https://docs.mpay24.com/docs/get-started
Documentation is available at https://docs.mpay24.com/docs
SDK Overview
First, it is necessary to include the library:
const mpay24 = require('mpay24-node')
The SDK is using the mPAY24 SOAP interface.
So you need to initialize the SDK
The parameter of the init
method are the merchantID
and password
The third optional parameter is the environment. The parameter can be set to TEST
or LIVE
.
If the parameter is not set, the default is LIVE.
mpay24.init('merchantID','password', 'TEST').then(() => {
}).catch(err => {
console.error(err)
})
Create a token for seamless credit card payments
mpay24.createPaymentToken({
pType: 'CC',
templateSet: 'DEFAULT'
}).then(result => {
console.log(result)
})
Create a payment
Creditcard payment with a token
mpay24.acceptPayment({
tid: 'customTransactionID',
pType: 'TOKEN',
payment: {
amount: 100,
currency: 'EUR',
token: 'y2hUtk9fn3mhv2yVox0yarawKzWQv0+vf/cp1NuzxFw='
}
}).then(result => {
console.log(result)
}).catch(err => {
console.error(err)
})
Paypal payment
mpay24.acceptPayment({
tid: 'customTransactionID',
pType: 'PAYPAL',
payment: {
amount: 100,
currency: 'EUR'
}
}).then(result => {
console.log(result)
}).catch(err => {
console.error(err)
})
Create a customer and charge a customer (recurring profile)
Create customer with token
mpay24.acceptPayment({
tid: 'customTransactionID',
pType: 'TOKEN',
payment: {
amount: 100,
currency: 'EUR',
token: 'y2hUtk9fn3mhv2yVox0yarawKzWQv0+vf/cp1NuzxFw=',
useProfile: true
},
customerID: 'customer-123'
}).then(result => {
console.log(result)
}).catch(err => {
console.error(err)
})
Charge the created customer
mpay24.acceptPayment({
tid: 'profilepayment',
pType: 'PROFILE',
payment: {
amount: 100,
currency: 'EUR'
},
customerID: 'customer-123'
}).then(result => {
console.log(result)
}).catch(err => {
console.error(err)
})
Get the current transaction status
mpay24.transactionStatus({
mpayTID: 1111,
}).then(result => {
console.log(result)
}).catch(err => {
console.error(err)
})
Initialize a Payment Page
mpay24.selectPayment({
tid: '123456',
price: '1.00',
URL: {
success: 'https://yourpage.com/success',
error: 'https://yourpage.com/error',
confirmation: 'https://yourpage.com/confirm'
}
}).then(result => {
console.log(result)
}).catch(err => {
console.error(err)
})
Testing
Environment variables need to be set to run the tests
USER
is the merchantID
PASSWORD
is the soap password
ENV
can be TEST
or LIVE
to run tests again live or testsystem
USER='9XXXX' PASSWORD='XXXXXX' ENV=TEST npm run test