• Stars
    star
    236
  • Rank 170,480 (Top 4 %)
  • Language
    TypeScript
  • License
    BSD 3-Clause "New...
  • Created almost 11 years ago
  • Updated about 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Official Mollie API client for Node

Mollie API client for Node.js

About

Mollie builds payment products, commerce solutions and APIs that let you accept online and mobile payments, for small online stores and Fortune 500s alike. Accepting Credit Card, Apple Pay, PayPal, Klarna: Pay now, Klarna: Pay later, Klarna: Slice it, iDeal, vouchers, SEPA Bank Transfer, SEPA Direct Debit, SOFORT banking, Bancontact, Cartes Bancaires, EPS, PostePay, Giropay, KBC Payment Button, Belfius Pay Button, paysafecard, gift cards, and Przelewy24 online payments without fixed monthly costs or any punishing registration procedures. Just use the Mollie API to receive payments directly on your website or easily refund transactions to your customers.

A note on use outside of Node.js

This is a JavaScript library, a language which is universal by nature. While it is theoretically possible to include this library into a website or mobile app, it is not recommended to do so.

In the typical setup, you will make calls to the Mollie API โ€’ through one of our libraries โ€’ from your server (e.g. a Node.js server). Your API key sits safely on this server, out of reach to the outside world.

If you include this library in a website or app, however, your API key will be shipped to users. With this key, users will be able to act on your behalf.

Requirements

In order to accept payments in live mode, payment methods must be activated in your account. Just follow a few steps and let us handle the rest.

Installation

Using npm:

npm install @mollie/api-client

Using yarn:

yarn add @mollie/api-client

Manual installation

Alternatively, you may use git clone or download an archive.

Getting started

Build the client.

Using JavaScript modules:

import createMollieClient from '@mollie/api-client';

const mollieClient = createMollieClient({ apiKey: 'test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM' });

CommonJS-style:

const { createMollieClient } = require('@mollie/api-client');

const mollieClient = createMollieClient({ apiKey: 'test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM' });

Create a new payment

const payment = await mollieClient.payments.create({
  amount: {
    value:    '10.00',
    currency: 'EUR'
  },
  description: 'My first API payment',
  redirectUrl: 'https://yourwebshop.example.org/order/123456',
  webhookUrl:  'https://yourwebshop.example.org/webhook'
});

// Forward the customer to payment.getCheckoutUrl().

When the payment is made by your customer, Mollie will send you a webhook (to the URL specified as webhookUrl) informing your server about the status change of the payment.

Check the status of a payment

const payment = await mollieClient.payments.get('tr_8WhJKGmgBy');

// Check payment.status.

Pagination and iteration

Composing one long list of all payments, orders, or customers would be too much work for the Mollie API. Furthermore, such a list could be too large for your server to process. For this reason, the Mollie API only returns a subset of the requested set of objects. In other words, the Mollie API chops the result of a certain API endpoint call into pages.

If you are designing a paginated view, you can use the page methods to retrieve one page at a time:

// Retrieve the first 15 payments.
const payments = mollieClient.payments.page({ limit: 15 });

// payments.nextPageCursor is the cursor: the ID of the first payment on the next page.

Later:

// Retrieve the second 15 payments (using the cursor from the previous page).
const payments = mollieClient.payments.page({ limit: 15, from: 'tr_8WhJKGmgBy' });

The page methods do not fit every use case. If you find yourself retrieving multiple pages to perform a single action, consider using the iterate methods instead:

// Iterate over all payments.
for await (let payment in mollieClient.payments.iterate()) {
  // (Use break to end the loop prematurely.)
}

The iterate methods perform the requests to the Mollie API for the objects you need. The following example will work regardless of whether the 10 resulting payments appear on the first page or are distributed across different pages:

// Find the 10 most recent euro payments over โ‚ฌ100.00.
const payments = mollieClient.payments.iterate()
  .filter(({ amount }) => amount.currency == 'EUR' && parseFloat(amount.value) > 100)
  .take(10);

Guides

For a deep dive in how our systems function, we refer to our excellent guides. These guides provide a complete overview of the Mollie API and cover specific topics dealing with a number of important aspects of the API.

API reference

This library is a wrapper around our Mollie API. Some more specific details are better explained in our API reference, and you can also get a better understanding of how the requests look under the hood.

Migrating

See the migration guide if you are migrating from an older version of the library.

Contributing

Want to help us make our API client even better? We take pull requests, sure. But how would you like to contribute to a technology oriented organization? Mollie is hiring developers and system engineers. Check out our vacancies or get in touch.

License

New BSD (Berkeley Software Distribution) License. Copyright 2013-2021, Mollie B.V.

More Repositories

1

mollie-api-php

Mollie API client for PHP
PHP
542
star
2

laravel-mollie

Mollie API client wrapper for Laravel & Mollie Connect provider for Laravel Socialite
PHP
314
star
3

laravel-cashier-mollie

Official Mollie integration for Laravel Cashier
PHP
137
star
4

WooCommerce

Official Mollie extension for WooCommerce
PHP
130
star
5

mollie-api-python

Mollie API client for Python
Python
110
star
6

magento2

Mollie Payments for Magento 2
PHP
101
star
7

mollie-api-ruby

Mollie API client for Ruby
Ruby
81
star
8

PrestaShop

iDEAL, Creditcard, Bancontact, SOFORT, Bank transfer, PayPal & paysafecard for Prestashop
PHP
66
star
9

OpenCart

iDEAL, Creditcard, Bancontact/Mister Cash, SOFORT, Belfius Direct Net, KBC/CBC Payment Button, Bank transfer, Bitcoin, PayPal & paysafecard for OpenCart 1.5.6+ and OpenCart 2.0+.
PHP
66
star
10

Shopware6

PHP
50
star
11

Magento

Mollie Payments for Magento 1.x
PHP
39
star
12

api-documentation

API Documentation for all of Mollie's public APIs.
SCSS
37
star
13

storybook-addon-ghostwriter

Storybook addon which helps you write stories faster.
JavaScript
26
star
14

mollie-odoo

Mollie Payments plugin for Odoo - an open source CRM and ERP
Python
25
star
15

oauth2-mollie-php

Mollie provider for league/oauth2-client
PHP
20
star
16

tf-provider-registry-api-generator

Generates static terraform provider registry API documents on Google Cloud Storage buckets
Go
19
star
17

php-coding-standards

Mollie PHP coding standards
PHP
18
star
18

Shopware

Official Mollie extension for Shopware
PHP
16
star
19

spree-mollie-gateway

Mollie payments for Spree Commerce.
Ruby
16
star
20

polyfill-libsodium

A polyfill for the transition from libsodium (the extension for PHP < 7.2) to sodium (as bundled with PHP 7.2)
PHP
14
star
21

components-examples

Examples and reference implementations for Mollie Components
JavaScript
13
star
22

reseller-api

Reseller API voor het aanmaken en beheren van Mollie-accounts
PHP
13
star
23

postman-collection

A postman collection for exploring the Mollie API
10
star
24

mollie-oxid

Mollie Payments for OXID eSales
PHP
7
star
25

PhpStorm

PhpStorm plugin for improved Smarty support
Java
6
star
26

join-us

Guide on how to join Mollie
6
star
27

mollie-JTL

Mollie payments plugin for JTL-Shop
PHP
5
star
28

osCommerce

iDEAL, Creditcard, Bancontact/Mister Cash, SOFORT, Bank transfer, Bitcoin, PayPal & paysafecard for osCommerce
PHP
5
star
29

magento2-hyva-compatibility

HTML
5
star
30

gambio

PHP
4
star
31

wordpress-donate-with-mollie

Accept donations on your WordPress website using your Mollie account.
PHP
4
star
32

eslint-config-mollie

ESLint shareable config for the Mollie Javascript repos.
JavaScript
4
star
33

Sylius

Mollie payment gateway integration for Sylius
PHP
4
star
34

demo-checkout-backend

PHP
3
star
35

partner-demo

PHP
3
star
36

crowdin-cli

A Crowdin CLI tool to collect, upload, and download translations from a Crowdin project.
TypeScript
3
star
37

thirtybees

Mollie Payments module for thirty bees, a fork of Prestashop
PHP
3
star
38

magento2-subscriptions

PHP
3
star
39

SalesforceCommerceCloud

JavaScript
3
star
40

jtl5

Mollie payments office plugin for JTL-Shop 5
PHP
2
star
41

codeo

JavaScript
2
star
42

magento2-hyva-checkout

PHP
2
star
43

demo-checkout-android

Kotlin
2
star
44

mollie-reaction-commerce

Mollie Payments for Reaction Commerce
JavaScript
2
star
45

magento2-hyva-react-checkout

JavaScript
2
star
46

commercetools

Official Mollie integration for CommerceTools
TypeScript
2
star
47

demo-checkout-ios

Swift
2
star
48

Shopware6Composables

Vue
1
star
49

magento2-scandipwa

JavaScript
1
star
50

terraform-filtered-list

Go
1
star
51

orocommerce

Official Mollie plugin for OroCommerce
PHP
1
star
52

PrestaShop1.6

PHP
1
star