Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
mollie-es6
Advanced tools
Mollie API client written in ES6 by an official Mollie Partner.
To use the this module, the following is required:
You can install this module with NPM:
npm install --save mollie-es6
Examples are in Express.js
Require the library.
const Mollie = require('mollie-es6');
Initialize
const mollieApp = new Mollie('test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM');
All callback functions are now generatos.
You can call .next() on them or when using something like co, you can just add yield
in a try / catch
, like in the examples below.
Create a new payment.
co.wrap(function*() {
const amount = 10.00;
const description = 'My first API payment';
const redirectUrl = 'https://example.org/order/12345';
try {
const payment = yield mollieApp.payments.create(
amount,
description,
redirectUrl
);
res.redirect(payment.getPaymentUrl());
} catch (e) {
// Handle error
}
});
Retrieving a payment.
co.wrap(function*() {
const paymentId = 'paymentId';
try {
const payment = yield mollieApp.payments.get(paymentId);
if(payment.isPaid()) {
console.log('Payment is fulfilled');
}
} catch (e) {
// Handle error
}
});
const amount = 10.00;
const description = 'My first API payment';
const redirectUrl = 'https://example.org/order/12345';
try {
const payment = yield mollieApp.payments.create(
amount,
description,
redirectUrl
);
res.redirect(payment.getPaymentUrl());
} catch (e) {
// Handle error
}
const amount = 10.00;
const description = 'My first API recurring payment';
const redirectUrl = 'https://example.org/order/12345';
try {
const payment = yield mollieApp.payments.create(
amount,
description,
redirectUrl,
{
recurringType: 'first' || 'recurring',
customerId: 'John Cena'
}
);
res.redirect(payment.getPaymentUrl());
} catch (e) {
// Handle error
}
const paymentId = 'paymentId';
const options = {
method: 'creditcard'
};
try {
const payment = yield mollieApp.payments.get(paymentId, options);
if(payment.isPaid()) {
console.log('Payment is paid');
}
} catch (e) {
// Handle error
}
const options = {
count: 100,
offset: 200
}
try {
const payments_list = yield mollieApp.payments.list(options);
/*
payments_list = {
totalCount: Number,
offset: Number,
count: Number,
data: [Payments],
links: {
first: String(url),
previous: String(url),
next: String(url),
last: String(url)
}
}
*/
} catch (e) {
// Handle error
}
const options = {
count: 10,
offset: 5
}
try {
const methods_list = yield mollieApp.methods.list(options);
/*
methods_list = {
totalCount: Number,
offset: Number,
count: Number,
data: [Methods],
links: {
first: String(url),
previous: String(url),
next: String(url),
last: String(url)
}
}
*/
} catch (e) {
// Handle error
}
const amount = 100.00;
const methodId = 'creditcard';
try {
const method = yield mollieApp.methods.get(methodId);
if(method.getMinAmount() < amount && method.getMaxAmount > amount) {
// Allow user to check out
}
} catch (e) {
// Handle error
}
This part is iDEAL only. Using issuers makes it possible to integrate the bank choice in your own system.
const options = {
count: 20,
offset: 2
}
try {
const issuers_list = yield mollieApp.issuers.list(options);
/*
issuers_list = {
totalCount: Number,
offset: Number,
count: Number,
data: [Issuers],
links: {
first: String(url),
previous: String(url),
next: String(url),
last: String(url)
}
}
*/
} catch (e) {
// Handle error
}
const issuerId = 'ideal_ABNANL2A';
try {
const issuer = yield mollieApp.issuers.get(issuerId);
// Do something with this issuer
} catch (e) {
// Handle error
}
try {
const refundId = 'someId';
const amount = 5.00; // This is optional, if omitted,
// the full amount will be refunded
const refund = yield mollieApp.refunds.create(refundId, amount);
} catch (e) {
// Handle error
}
const paymentId = 'paymentId';
const refundId = 'refundId'
try {
const refund = yield mollieApp.refunds.get(paymentId, refundId);
if(refund.payment.isFullyRefunded()) {
console.log('Payment is fully refunded');
}
} catch (e) {
// Handle error
}
const paymentId = 'paymentId';
const options = {
count: 10,
offset: 2
}
try {
const payments_list = yield mollieApp.refunds.list(paymentId, options);
} catch (e) {
// Handle error
}
const paymentId = 'paymentId';
const refundId = 'refundId'
try {
const refund = yield mollieApp.refunds.cancel(paymentId, refundId);
} catch (e) {
// Handle error
}
try {
const customer = yield mollieApp.customers.create(
'Customer name',
'info@domain.tld',
{locale: 'en', metadata: {something: 'here'}}
);
// New customer created, do something fun with it
} catch (e) {
// Handle error
}
const customerId = 'someId';
try {
const customer = yield mollieApp.customers.get(customerId);
// Do something with this customer data
} catch (e) {
// Handle error
}
const options = {
count: 100,
offset: 200
}
try {
const customer_list = yield mollieApp.customers.list(options);
/*
customer_list = {
totalCount: Number,
offset: Number,
count: Number,
data: [Customers],
links: {
first: String(url),
previous: String(url),
next: String(url),
last: String(url)
}
}
*/
} catch (e) {
// Handle error
}
FAQs
Mollie module in ES6
The npm package mollie-es6 receives a total of 9 weekly downloads. As such, mollie-es6 popularity was classified as not popular.
We found that mollie-es6 demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.