Offical Unzer Austria (former mPAY24) node.js SDK
npm install mpay24-node --save
A short demo implementation guide is available at https://docs.mpay24.com/docs/get-started
Documentation is available at https://docs.mpay24.com/docs
First, it is necessary to include the library:
const mpay24 = require('mpay24-node')
The SDK is using the 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(() => {
// now all methods can be used
}).catch(err => {
console.error(err)
})
mpay24.createPaymentToken({
pType: 'CC',
templateSet: 'DEFAULT'
}).then(result => {
console.log(result)
})
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 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)
})
mpay24.transactionStatus({
mpayTID: 1111, // from acceptPayment response
// tid: 'customTransactionID'
}).then(result => {
console.log(result)
}).catch(err => {
console.error(err)
})
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)
})
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