<commit_before># mpay24-node

[![Build Status](https://travis-ci.com/tobiaslins/mpay24-node.svg?token=peDG6G3LXx2xP4jx5E91&branch=master)](https://travis-ci.com/tobiaslins/mpay24-node)

Unoffical mPAY24 node.js SDK

## Installation

`npm install mpay24-node`

## Documentation

Documentation is available at https://docs.mpay24.com/docs/node.

## SDK Overview

First it is necessary to include the library:
```js
var 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 creditcard payments

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

#### Create a payment

Creditcard payment with a token
```js
mpay24.acceptPayment({
  tid: 'customTransactionID',
  pType: 'TOKEN',
  payment: {
    amount: 100,
    currency: 'EUR',
    token: '<KEY>
  }
}).then(data => {
  console.log(data);
}).catch(err => {
  console.error(err);
});
```
Paypal payment
```js
mpay24.acceptPayment({
  tid: 'customTransactionID',
  pType: 'PAYPAL',
  payment: {
    amount: 100,
    currency: 'EUR',
  }
}).then(data => {
  console.log(data);
}).catch(err => {
  console.error(err);
});
```

#### Get the current transaction status

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

## Testing
Environment variables need to be set in order 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
<commit_msg>use result instead of data<commit_after># mpay24-node

[![Build Status](https://travis-ci.com/tobiaslins/mpay24-node.svg?token=peDG6G3LXx2xP4jx5E91&branch=master)](https://travis-ci.com/tobiaslins/mpay24-node)

Unoffical mPAY24 node.js SDK

## Installation

`npm install mpay24-node --save`

## Documentation

Documentation is available at https://docs.mpay24.com/docs/node.

## SDK Overview

First it is necessary to include the library:
```js
var 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 creditcard 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: '<KEY>
  }
}).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);
});
```

#### Get the current transaction status

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

## Testing
Environment variables need to be set in order to run the tests

`USER` is the merchantID

`PASSWORD` is the <PASSWORD>

`ENV` can be `TEST` or `LIVE` to run tests again live or testsystem

{'fraction_non_alphanumeric': 0.15757866922892144, 'fraction_numerical': 0.02161902474177276, 'mean_word_length': 4.304458598726114, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 24, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3645125', 'n_tokens_mistral': 1515, 'n_tokens_neox': 1428, 'n_words': 418}