# mpay24-node

> mPAY24 SDK

Latest version **0.1.7** (published 2020-01-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install mpay24-node
pnpm add mpay24-node
yarn add mpay24-node
bun add mpay24-node
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.7 |
| Published | 2020-01-03 |
| First published | 2016-11-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 21.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | Tobias Lins |
| Maintainers | tobiaslins |

## Links

- npm: https://www.npmjs.com/package/mpay24-node
- Repository: https://github.com/mpay24/mpay24-node
- Homepage: https://github.com/mpay24/mpay24-node#readme
- Issues: https://github.com/mpay24/mpay24-node/issues
- npm.io page: https://npm.io/package/mpay24-node

## Dependencies (2)

- [soap](https://npm.io/package/soap.md) ^0.30.0
- [js2xmlparser](https://npm.io/package/js2xmlparser.md) ^4.0.0

## Recent versions

- 0.1.7 (latest) — 2020-01-03
- 0.1.6 — 2019-10-04
- 0.1.5 — 2017-10-17
- 0.1.4 — 2017-10-16
- 0.1.3 — 2017-10-16
- 0.1.2 — 2017-09-14
- 0.1.1 — 2017-08-02
- 0.1.0 — 2017-08-01
- 0.0.9 — 2017-04-12
- 0.0.8 — 2017-03-21
- 0.0.7 — 2017-03-15
- 0.0.6 — 2016-12-13
- 0.0.5 — 2016-12-13
- 0.0.4 — 2016-11-09
- 0.0.3 — 2016-11-08
- … 1 more at https://npm.io/package/mpay24-node/versions

## README

# mpay24-node

[![Build Status](https://travis-ci.org/mpay24/mpay24-node.svg?branch=master)](https://travis-ci.org/mpay24/mpay24-node) [![XO code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/sindresorhus/xo) [![Known Vulnerabilities](https://snyk.io/test/npm/mpay24-node/badge.svg)](https://snyk.io/test/npm/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</br>
Documentation is available at https://docs.mpay24.com/docs

## SDK Overview

First, it is necessary to include the library:
```js
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.

```js
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

```js
mpay24.createPaymentToken({
  pType: 'CC',
  templateSet: 'DEFAULT'
}).then(result => {
  console.log(result)
})
```

#### Create a payment

Creditcard payment with a token
```js
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
```js
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
```js
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
```js
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

```js
mpay24.transactionStatus({
  mpayTID: 1111, // from acceptPayment response
  // tid: 'customTransactionID'
}).then(result => {
  console.log(result)
}).catch(err => {
  console.error(err)
})
```

#### Initialize a Payment Page

```js
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</br>
`PASSWORD` is the soap password</br>
`ENV` can be `TEST` or `LIVE` to run tests again live or testsystem

```js
USER='9XXXX' PASSWORD='XXXXXX' ENV=TEST npm run test
```

---
_Source: https://npm.io/package/mpay24-node · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
