0.1.7 • Published 4 years ago

mpay24-node v0.1.7

Weekly downloads
41
License
MIT
Repository
github
Last release
4 years ago

mpay24-node

Build Status XO code style Known Vulnerabilities

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(() => {
  // now all methods can be used
}).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, // from acceptPayment response
  // tid: 'customTransactionID'
}).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
0.1.7

4 years ago

0.1.6

5 years ago

0.1.5

7 years ago

0.1.4

7 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago

0.0.9

7 years ago

0.0.8

7 years ago

0.0.7

7 years ago

0.0.6

7 years ago

0.0.5

7 years ago

0.0.4

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago