mpay24-node
mPAY24 SDK
Last updated 5 months ago by mdaskalov .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install mpay24-node 
SYNC missed versions from official npm registry.

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

Current Tags

  • 0.1.7                                ...           latest (5 months ago)

16 Versions

  • 0.1.7                                ...           5 months ago
  • 0.1.6                                ...           8 months ago
  • 0.1.5                                ...           3 years ago
  • 0.1.4                                ...           3 years ago
  • 0.1.3                                ...           3 years ago
  • 0.1.2                                ...           3 years ago
  • 0.1.1                                ...           3 years ago
  • 0.1.0                                ...           3 years ago
  • 0.0.9                                ...           3 years ago
  • 0.0.8                                ...           3 years ago
  • 0.0.7                                ...           3 years ago
  • 0.0.6                                ...           3 years ago
  • 0.0.5                                ...           3 years ago
  • 0.0.4                                ...           4 years ago
  • 0.0.3                                ...           4 years ago
  • 0.0.2                                ...           4 years ago
Maintainers (1)
Downloads
Today 0
This Week 1
This Month 1
Last Day 0
Last Week 0
Last Month 0
Dependencies (2)
Dev Dependencies (5)
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |