sdk-generator / mollie-sdk
Unofficial PHP SDK for the Mollie payments API (v2): payments, refunds, captures, chargebacks, customers, mandates, subscriptions, orders, shipments, payment links and terminals. Generated from Mollie's Postman collection.
Requires
- php: ^8.4
- sdk-generator/sdk-runtime: ^1.16.0
Requires (Dev)
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^11.5
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-12-04 01:56:31 UTC
README
The Mollie payments API (v2) as typed PHP, generated from Mollie's own Postman collection.
Payments, refunds, captures, chargebacks, customers, mandates, subscriptions, orders and shipments, payment links, methods, profiles and terminals of the Mollie API, with the API key sent for you.
Unofficial. Not affiliated with, endorsed by or supported by Mollie B.V. See NOTICE.md.
Why this SDK
- Generated from a Postman collection. Mollie published its API as Postman collections with a saved example answer for each request; the generator reads the collection and infers the models from those answers.
- HAL lists typed one by one. Every list answer is
{count, _embedded, _links}; each is its own model (PaymentList,RefundList,MethodList...), with the items typed inside. - Use a test key first. A
test_API key works against the same endpoints without moving money. - Generated from Mollie's Postman collection, never edited by hand.
src/is produced by sdk-generator from the Postman collection (API key authentication) described in contract/SOURCE.md, on top of the shared sdk-runtime: when the source changes you regenerate, you do not patch. - Typed end to end. 61 operations and 164 typed request, answer and model classes. A request is a model whose fields are checked where you assign them (PHP 8.4 property hooks); an answer is a model; a list is a typed collection. PHPStan at the maximum level reports no error on the whole SDK.
- One way to fail. An HTTP answer the contract does not declare as success is an
ApiExceptionthat keeps the raw response and, when the API documents it, the decoded error as a model. Network failures keep their own type. - Production controls included. PSR-18 HTTP client (Guzzle by default), timeouts (30 s / 10 s by default), retries with
Retry-After, redirect policy, middleware and per-environment servers, all in oneConfigurationobject.
Install
PHP 8.4 or later.
composer require sdk-generator/mollie-sdk
Quick start
<?php use MollieSDK\Configuration; use MollieSDK\DTOs\Amount; use MollieSDK\Methods; use MollieSDK\MollieAPISDK; use MollieSDK\Payments; use MollieSDK\Requests\Payments\Post as NewPayment; use Dmorenof\SdkRuntime\Security\SecurityCredentials; $configuration = new Configuration(); $configuration->securityCredentials = new SecurityCredentials(['bearerAuth' => getenv('MOLLIE_API_KEY') ?: 'test_...']); MollieAPISDK::configure($configuration); foreach (Methods::get()->_embedded->methods as $method) { echo $method->id, ': ', $method->description, "\n"; } $amount = new Amount(); $amount->currency = 'EUR'; $amount->value = '10.00'; $request = new NewPayment(); $request->amount = $amount; $request->description = 'Order #12345'; $request->redirectUrl = 'https://example.com/return'; $payment = Payments::post($request); echo $payment->id, ' ', $payment->status, ' ', $payment->_links->checkout->href, "\n";
The same example is in examples/quickstart.php. Every operation is listed in docs/OPERATIONS.md.
What it covers
61 operations. The biggest areas:
| Area | Operations |
|---|---|
customers |
17 |
payments |
14 |
orders |
13 |
profiles |
5 |
methods |
3 |
payment-links |
3 |
terminals |
2 |
chargebacks |
1 |
refunds |
1 |
subscriptions |
1 |
Handling errors
use Dmorenof\SdkRuntime\ApiException; try { // ... any call from the quick start } catch (ApiException $e) { echo $e->response->status, "\n"; // the HTTP status echo $e->response->body, "\n"; // the raw body, always kept var_dump($e->error); // the decoded error model, when the API documents one }
Configuration
Configuration is the only place to set anything: baseUrl, securityCredentials, headers, timeout, connectTimeout, retryPolicy, redirectPolicy, middleware, httpClient (any PSR-18 client), serverVariables. Use Client::connect($configuration) instead of the static facades when you need several independent connections.
Good to know
- You need a Mollie account and an API key (Dashboard, Developers, API keys). Use the
test_key while you try it: test payments move no money. - A Postman collection shows examples, not a contract: fields are typed from the saved answers, and none is required. Mollie has deprecated this collection in favour of one on Postman Cloud, so newer API features are not in it (and Mollie now recommends the Payments API over the Orders API).
- Not run against the live service: it needs an API key. The SDK is checked by generation, PHPStan at the maximum level and loading every class.
- Version
0.1.0is a first release: the API of the SDK follows the source description, and a regenerated one can rename classes. Pin a version.
Documentation
- Operations catalog
- Vendor documentation
- sdk-runtime (what every SDK shares) and sdk-generator
- CHANGELOG.md, CONTRIBUTING.md, SECURITY.md
License
MIT, see LICENSE.md. The license covers this SDK's code, not the API, its trademarks or its terms: see NOTICE.md.