by Haru S.

A Node.js client library for the Mollie Payments API, enabling server-side integration of 30+ payment methods including iDEAL, Klarna, PayPal, and SEPA Direct Debit. Built for backend services requiring secure, paginated, and iterable payment workflows.
This block provides the complete source of @mollie/api-client@4.5.0, the official Mollie payment gateway SDK for Node.js. It exposes a typed client factory (createMollieClient) that covers payments, orders, customers, refunds, subscriptions, methods, and every other Mollie resource. Typical buyers are backend engineers integrating Mollie into a Node.js/TypeScript service who need full source access for debugging, bundling, or customisation.
binders/ - Resource-specific binders (payments, orders, customers, refunds, etc.); each binder maps to one Mollie API namespacecommunication/ - Low-level HTTP transport (NetworkClient, TransformingNetworkClient) used by all bindersdata/ - Domain model types and transform functions for every Mollie resource (Payment, Order, Customer, etc.)errors/ - Typed Mollie API error classesplumbing/ - Internal utilities (alias, pagination helpers)types/ - Shared generic TypeScript utility types (MaybeArray, Xor, etc.)Options.ts - Options type definition and credential validation (checkCredentials)certs.d.ts - Module declaration for bundled PEM CA certificatescreateMollieClient.ts - Main factory; wires all binders and transformers together, returns the MollieClienttypes.ts - Re-exports every public symbol (MollieClient, all resource types, all parameter types)npm install node-fetch @types/node-fetch ruply
No native build steps, no pod install, no Android linking. The library runs in plain Node.js 14+.
Copy the source/ directory into your project, e.g. src/mollie/.
Ensure your tsconfig.json targets ES2020 or later and includes the source root:
{
"compilerOptions": {
"target": "ES2020",
"module": "CommonJS",
"moduleResolution": "node",
"resolveJsonModule": true,
"strict": true,
"baseUrl": ".",
"paths": {
"@mollie/api-client": ["src/mollie/types.ts"]
}
}
}
Spin up an isolated sandbox and run it server-side — no local setup.
Tetrees AI Review of this version
This TypeScript library / package completed archive review. Structure, dependency manifests, documentation, functional source, and common risk patterns were checked by the Tetrees verification pipeline; runtime phases are stated separately.
Deterministic AVCP artifact review
Pipeline avcp-2026-08-04.1 · SHA-256 4456c24e54dcef08…
This version-scoped review deterministically inspects the submitted archive for structure, dependencies, documentation, functional source, and common malicious or high-risk signals. Build and test phases are reported as passed only after an isolated sandbox audition. It is not a guarantee of perfect security.
Reviewed Aug 4, 2026
Push this product straight into your AI IDE, web builder or cloud IDE.
Connect Tetrees to a compatible AI IDE, list products you own, and request the verified ZIP without exposing seller upload controls.
No reviews yet.
Sign in to join the discussion
Loading discussion…
If you use resolveJsonModule: true, confirm package.json is in scope so version can be imported inside createMollieClient.ts.
Set credentials via environment variables and read them at startup:
// src/mollie-client.ts
import createMollieClient from './mollie/createMollieClient';
export const mollie = createMollieClient({
apiKey: process.env.MOLLIE_API_KEY!, // e.g. "test_dHar4XY7..."
});
apiKey with accessToken:export const mollie = createMollieClient({
accessToken: process.env.MOLLIE_ACCESS_TOKEN!,
});
Authorization, User-Agent, Accept, Accept-Encoding, or Content-Type in Options.headers; the library overwrites them.createMollieClientimport createMollieClient from './mollie/createMollieClient';
function createMollieClient(options: Options): MollieClient;
The single entry point. Pass either { apiKey: string } or { accessToken: string }. Optionally supply versionStrings, headers, and apiEndpoint. Returns a fully initialised MollieClient with a property for every Mollie API namespace (payments, orders, customers, methods, etc.). Throws TypeError immediately if neither credential is supplied.
Optionsimport type Options from './mollie/Options';
type Options =
| { apiKey: string; versionStrings?: string | string[]; headers?: Record<string, string>; apiEndpoint?: string }
| { accessToken: string; versionStrings?: string | string[]; headers?: Record<string, string>; apiEndpoint?: string };
Used to configure the client. apiKey covers direct API-key access; accessToken covers OAuth flows. apiEndpoint defaults to https://api.mollie.com:443/v2/ and can be overridden for testing against a mock server.
MollieClientimport type { MollieClient } from './mollie/types';
The return type of createMollieClient. Exposes namespaced binders as properties:
mollieClient.payments // PaymentsBinder
mollieClient.orders // OrdersBinder
mollieClient.customers // CustomersBinder
mollieClient.methods // MethodsBinder
mollieClient.refunds // top-level refunds binder
mollieClient.subscriptions // top-level subscriptions binder
// ... and every other Mollie namespace
Use this type for dependency injection in services and tests.
Create a Mollie payment and obtain the checkout URL to redirect the customer.
import createMollieClient from './mollie/createMollieClient';
const mollie = createMollieClient({ apiKey: process.env.MOLLIE_API_KEY! });
async function startPayment(orderId: string, amountEur: string): Promise<string> {
const payment = await mollie.payments.create({
amount: { value: amountEur, currency: 'EUR' },
description: `Order ${orderId}`,
redirectUrl: `https://yourshop.example/order/${orderId}/return`,
webhookUrl: `https://yourshop.example/webhooks/mollie`,
metadata: { orderId },
});
const checkoutUrl = payment.getCheckoutUrl();
if (!checkoutUrl) throw new Error('No checkout URL returned');
return checkoutUrl;
}
Receive a Mollie webhook, retrieve the updated payment, and update your database.
import { IncomingMessage, ServerResponse } from 'http';
import createMollieClient from './mollie/createMollieClient';
import type { MollieClient } from './mollie/types';
const mollie: MollieClient = createMollieClient({ apiKey: process.env.MOLLIE_API_KEY! });
async function handleMollieWebhook(req: IncomingMessage, res: ServerResponse): Promise<void> {
const body = await readBody(req); // your own helper
const paymentId: string = body.id;
const payment = await mollie.payments.get(paymentId);
switch (payment.status) {
case 'paid':
await fulfillOrder(payment.metadata?.orderId);
break;
case 'failed':
case 'expired':
await cancelOrder(payment.metadata?.orderId);
break;
}
res.writeHead(200).end();
}
async function fulfillOrder(orderId?: string): Promise<void> { /* ... */ }
async function cancelOrder(orderId?: string): Promise<void> { /* ... */ }
async function readBody(req: IncomingMessage): Promise<any> { /* ... */ }
Retrieve the active payment methods for a given currency and amount to populate a checkout UI.
import createMollieClient from './mollie/createMollieClient';
import type { MethodsListParams } from './mollie/types';
const mollie = createMollieClient({ apiKey: process.env.MOLLIE_API_KEY! });
async function getAvailableMethods(currency: string, value: string) {
const params: MethodsListParams = {
amount: { currency, value },
locale: 'en_US',
};
const methods = await mollie.methods.list(params);
return methods.map(m => ({
id: m.id,
description: m.description,
imageSize2x: m.image.size2x,
}));
}
createMollieClient.ts - Imports all binders and data transformers, calls checkCredentials, constructs a TransformingNetworkClient, instantiates every binder, and returns the assembled client object.types.ts - Re-exports createMollieClient as default and named, exposes MollieClient, MollieOptions, and every resource/parameter type for consumer-side type imports.Options.ts - Defines the Options union type (apiKey XOR accessToken plus optional fields) and exports checkCredentials, which throws TypeError on missing credentials.certs.d.ts - Ambient module declaration allowing TypeScript to import .pem files as strings for the bundled CA certificate chain.binders/ - One binder class per resource namespace. Each extends Binder and exposes CRUD methods (create, get, list, update, delete) with typed parameter interfaces co-located in parameters.ts.communication/ - NetworkClient wraps node-fetch for raw HTTP; TransformingNetworkClient applies data transform functions before returning responses to callers.data/ - Plain TypeScript model interfaces and transform functions that convert raw Mollie API JSON into typed domain objects with helper methods (e.g. payment.getCheckoutUrl()).errors/ - Structured error types surfaced when the Mollie API returns a non-2xx response.plumbing/ - Shared internal helpers including alias (used to add shorthand properties to the client) and pagination utilities.types/ - Generic utility types (MaybeArray<T>, Xor<A,B>) used throughout the library.resolveJsonModule: createMollieClient.ts imports version from package.json; add "resolveJsonModule": true to tsconfig.json.apiKey and accessToken both provided: The Options type is a strict XOR; TypeScript will error and checkCredentials may behave unexpectedly — supply exactly one credential.Authorization or Content-Type in Options.headers has no effect; the library silently ignores them. Set credentials only via apiKey / accessToken.node-fetch v2 (the version used here) targets Node 14+; running on older runtimes will throw at runtime with obscure fetch errors — upgrade Node or polyfill fetch.node-fetch: If your project uses "type": "module", pin node-fetch to ^2.x (CJS build) or add "esModuleInterop": true in tsconfig.json to avoid default-import errors.mollie.payments.list() returns a Page object; call page.nextPage() or use mollie.payments.iterate() to walk all records rather than slicing a single page.I have dropped the Mollie API client source into `src/mollie/` in my project.
The integration guide is in `USAGE.md`. The upstream package is `@mollie/api-client@4.5.0`.
Please help me integrate it into my existing Node.js/TypeScript project step by step:
1. Read `USAGE.md` and `src/mollie/types.ts` to understand every public export.
2. Add a `src/mollie-client.ts` singleton that reads MOLLIE_API_KEY from process.env
and exports a typed `MollieClient` instance.
3. Create a payment service (`src/services/payment.service.ts`) with methods:
- `createPayment(orderId, amountEur)` → returns checkout URL string
- `getPaymentStatus(paymentId)` → returns payment.status
- `listPayments(cursor?)` → returns a Page of Payment objects
4. Add an Express webhook handler at POST /webhooks/mollie that calls getPaymentStatus
and updates a local order record.
5. Show me every import path using the local `src/mollie/` source, not the npm package.
6. Add TypeScript types for all function parameters and return values using the
exported types from `src/mollie/types.ts` (e.g. MollieClient, PaymentCreateParams).
7. Flag any tsconfig.json changes needed (resolveJsonModule, paths, etc.).
The upstream project is released under the BSD 2-Clause License (see source/LICENSE if present, or the GitHub repository). This block is a redistribution of @mollie/api-client@4.5.0 published by Mollie B.V.. Refer to the upstream repository for the full license text and contributor list.
This product’s unique contribution is clean room implementation of valuable code block into AVCP compatible standard.
The full install guide and integration prompts unlock after purchase.
eCommerce, Marketplace & POS Systems
Free