Skip to content

Latest commit

 

History

History
141 lines (108 loc) · 3.87 KB

README.md

File metadata and controls

141 lines (108 loc) · 3.87 KB

Node.js wrapper for the MultiSafepay API

This wrapper simplifies working with the MultiSafepay API and lets you integrate MultiSafepay in your Node.js application.

About MultiSafepay

MultiSafepay is a Dutch payment service provider, which takes care of contracts, processing transactions, and collecting payment for a range of local and international payment methods. Start selling online today and manage all your transactions in one place!

Requirements

  • You will need a MultiSafepay account. Consider creating a test account first.
  • If using Node 8.0+, we recommend using async/await. For older versions of Node, use promises or callbacks instead of async/await.

Installation

With npm:

npm install @multisafepay/api-wrapper --save

And yarn:

yarn add @multisafepay/api-wrapper

Usage

Set up the client for testing with ES6 imports:

import MSPClient from '@multisafepay/api-wrapper';
const client = new MSPClient('apiKey');

With require module:

const MSPClient = require('@multisafepay/api-wrapper').default;
const client = new MSPClient('apiKey');

To use the test environment:

const client = new MSPClient('apiKey', { environment: 'test' });

Create a test order with async/await:

# This code creates a redirect iDEAL order
async () => {
  try {
    const multiSafePayClient = new MSPClient(apiKey, { environment: 'test' });

    return await multiSafePayClient.orders.create({
      type: 'redirect',
      order_id: "my-order-id-1",
      gateway: 'iDEAL',
      currency: 'EUR',
      amount: '1000',
      description: 'Test Order Description',
      payment_options: {
        notification_url:
          'http://www.example.com/client/notification?type=notification',
        redirect_url:
          'http://www.example.com/client/notification?type=redirect',
        cancel_url: 'http://www.example.com/client/notification?type=cancel',
        close_window: '',
      },
      customer: {
        locale: 'en_US',
      },
      second_chance: {
        send_email: true,
      },
    });
  } catch (error) {
    console.log(error);
  }
};

With promises:

# This code creates a redirect iDEAL order
multiSafePayClient.orders
  .create({
    type: 'redirect',
    order_id: 'my-order-id-1',
    gateway: 'iDEAL',
    currency: 'EUR',
    amount: '1000',
    description: 'Test Order Description',
    payment_options: {
      notification_url:
        'http://www.example.com/client/notification?type=notification',
      redirect_url: 'http://www.example.com/client/notification?type=redirect',
      cancel_url: 'http://www.example.com/client/notification?type=cancel',
      close_window: '',
    },
    customer: {
      locale: 'en_US',
    },
    second_chance: {
      send_email: true,
    },
  })
  .then(response => {
    console.log(response);
  })
  .catch(error => {
    console.log(error);
  });

See more examples.

Support

Create an issue on this repository or email [email protected]

Contributions

Feel free to create a pull request on this repository to suggest improvements.

API reference

See MultiSafepay Docs – API reference.

License

MIT License