1.2.2 • Published 3 months ago

@multisafepay/message-bus v1.2.2

Weekly downloads
-
License
-
Repository
github
Last release
3 months ago

Cross-platform WebSocket plugin for the MultiSafepay API

This plugin simplifies working with the MultiSafepay API and lets you listen to the events received from your Payment Terminals.

You can use this plugin in a Node.js backend or in any javascript frontend.

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!

Installation

With npm:

npm install @multisafepay/message-bus --save

And yarn:

yarn add @multisafepay/message-bus

In case you want to use in plain HTML, you should have the code base of this plugin accesible, either at folder level or having the code deployed somewhere.

Usage

In order to get everything you need for initializating the plugin, you will have to make a valid order request to our MultiSafepay API. If you have any doubts on how to do this, follow these instructions

Set up the client for testing with ES6 imports:

import connect from '@multisafepay/message-bus';

const { events_url, events_token } = orderResponse.data;

const messageBus = connect(events_url, { token: events_token });

Set up the client for testing with CommonJS imports:

const connect = require('@multisafepay/message-bus').default;

const { events_url, events_token } = orderResponse.data;

const messageBus = connect(events_url, { token: events_token });

With script tag:

 <script type="module">
    import connect from "https://unpkg.com/@multisafepay/message-bus/dist/esm/browser/index.js"

    const { events_url, events_token } = orderResponse.data;

    const messageBus = connect(events_url, { token: events_token });
</script>

Subscribe to the order event:

messageBus.subscribe('session.order', {}, (data) => {
    // Your actions with the payload
    console.log(data)
})

Unsubscribe to the order event:

messageBus.unsubscribe('session.order')

Stop listening to events:

messageBus.close()

Support

Create an issue on this repository or email integration@multisafepay.com

Contributions

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

API reference

See MultiSafepay Docs – API reference.

License

MIT License

1.2.2

3 months ago

1.2.0

10 months ago

1.1.1

10 months ago

1.1.0

10 months ago

1.2.1

10 months ago

1.1.2

10 months ago

1.0.1

11 months ago

1.0.0

11 months ago