Search by

mollie / php

molops

v0.1.0-alpha.3 2026-11-27 09:33 UTC

This package is auto-updated.

Last update: 2026-11-27 09:42:46 UTC


README

Developer-friendly & type-safe Php SDK specifically catered to leverage mollie/php API.

Built by Speakeasy License: AGPL-3.0-only



Important

This SDK is not yet ready for production use. To complete setup please follow the steps outlined in your workspace. Delete this section before > publishing to a package manager.

Summary

Table of Contents

SDK Installation

The SDK relies on Composer to manage its dependencies.

To install the SDK and add it as a dependency to an existing composer.json file:

composer require "mollie/php"

SDK Example Usage

Example

declare(strict_types=1);

require 'vendor/autoload.php';

use Mollie\Api;
use Mollie\Api\Models\Components;
use Mollie\Api\Models\Operations;

$sdk = Api\Client::builder()->build();

$body = new Operations\OauthGenerateTokensRequestBody(
    grantType: Components\OauthGrantType::AuthorizationCode,
    code: 'auth_...',
    refreshToken: 'refresh_...',
    redirectUri: 'https://example.com/redirect',
);
$requestSecurity = new Operations\OauthGenerateTokensSecurity(
    username: '',
    password: '',
);

$response = $sdk->oauth->generate(
    security: $requestSecurity,
    idempotencyKey: '123e4567-e89b-12d3-a456-426',
    body: $body

);

if ($response->object !== null) {
    // handle response
}

Authentication

Per-Client Security Schemes

This SDK supports the following security schemes globally:

Name Type Scheme
apiKey http HTTP Bearer
advancedAccessToken http HTTP Bearer
oAuth oauth2 OAuth2 token

You can set the security parameters through the setSecurity function on the SDKBuilder when initializing the SDK. The selected scheme will be used by default to authenticate with the API for all operations that support it. For example:

declare(strict_types=1);

require 'vendor/autoload.php';

use Mollie\Api;
use Mollie\Api\Models\Components;
use Mollie\Api\Models\Operations;

$sdk = Api\Client::builder()
    ->setSecurity(
        new Components\Security(
            apiKey: '<YOUR_BEARER_TOKEN_HERE>',
        )
    )
    ->setTestmode(true)
    ->build();

$request = new Operations\ListBalancesRequest(
    currency: 'EUR',
    limit: 50,
    idempotencyKey: '123e4567-e89b-12d3-a456-426',
    xClientSignature: 'MEUCIQDx8sJvK3z...',
    xClientSignedAt: '2025-01-01T12:00:00Z',
);

$responses = $sdk->balances->list(
    request: $request
);


foreach ($responses as $response) {
    if ($response->statusCode === 200) {
        // handle response
    }
}

Per-Operation Security Schemes

Some operations in this SDK require the security scheme to be specified at the request level. For example:

declare(strict_types=1);

require 'vendor/autoload.php';

use Mollie\Api;
use Mollie\Api\Models\Components;
use Mollie\Api\Models\Operations;

$sdk = Api\Client::builder()->build();

$body = new Operations\OauthGenerateTokensRequestBody(
    grantType: Components\OauthGrantType::AuthorizationCode,
    code: 'auth_...',
    refreshToken: 'refresh_...',
    redirectUri: 'https://example.com/redirect',
);
$requestSecurity = new Operations\OauthGenerateTokensSecurity(
    username: '',
    password: '',
);

$response = $sdk->oauth->generate(
    security: $requestSecurity,
    idempotencyKey: '123e4567-e89b-12d3-a456-426',
    body: $body

);

if ($response->object !== null) {
    // handle response
}

Available Resources and Operations

Available methods

Accounts

BalanceTransfers

  • create - Create a Connect balance transfer
  • list - List all Connect balance transfers
  • get - Get a Connect balance transfer

Balances

Capabilities

  • list - List capabilities

Captures

Chargebacks

  • list - List payment chargebacks
  • get - Get payment chargeback
  • all - List all chargebacks

CheckoutSessions

  • create - Create Checkout Session
  • get - Get Checkout Session

ClientLinks

Clients

  • list - List clients
  • get - Get client

Customers

DelayedRouting

  • create - Create a delayed route
  • list - List payment routes
  • get - Get a delayed route

DraftTransfers

  • create - Create draft transfer
  • list - List draft transfers
  • get - Get draft transfer
  • cancel - Cancel draft transfer

Invoices

  • list - List invoices
  • get - Get invoice

Mandates

Methods

Oauth

Onboarding

  • get - Get onboarding status
  • submit - Submit onboarding data

Organizations

PaymentLinks

Payments

Payouts

Permissions

  • list - List permissions
  • get - Get permission

Profiles

Refunds

  • create - Create payment refund
  • list - List payment refunds
  • get - Get payment refund
  • cancel - Cancel payment refund
  • all - List all refunds

Reports

SalesInvoices

  • create - Create sales invoice
  • list - List sales invoices
  • get - Get sales invoice
  • update - Update sales invoice
  • delete - Delete sales invoice

Settlements

Subscriptions

  • create - Create subscription
  • list - List customer subscriptions
  • get - Get subscription
  • update - Update subscription
  • cancel - Cancel subscription
  • all - List all subscriptions
  • listPayments - List subscription payments

Terminals

Transfers

  • create - Create transfer
  • get - Get transfer

UnmatchedCreditTransfers

  • list - List unmatched credit transfers
  • get - Get unmatched credit transfer
  • match - Match unmatched credit transfer
  • return - Return unmatched credit transfer

VerifyPayee

Wallets

WebhookEvents

  • get - Get a Webhook Event

Webhooks

  • create - Create a webhook
  • list - List all webhooks
  • update - Update a webhook
  • get - Get a webhook
  • delete - Delete a webhook
  • test - Test a webhook

Global Parameters

Certain parameters are configured globally. These parameters may be set on the SDK client instance itself during initialization. When configured as an option during SDK initialization, These global values will be used as defaults on the operations that use them. When such operations are called, there is a place in each to override the global value, if needed.

For example, you can set profileId to `` at SDK initialization and then you do not have to pass the same value on calls to operations like list. But if you want to do so you may, which will locally override the global setting. See the example code below for a demonstration.

Available Globals

The following global parameters are available.

Name Type Description
profileId string The identifier referring to the profile you wish to
retrieve the resources for.

Most API credentials are linked to a single profile. In these cases the profileId must not be sent. For
organization-level credentials such as OAuth access tokens however, the profileId parameter is required.
testmode bool Most API credentials are specifically created for either live mode or test mode. In those cases the testmode query
parameter must not be sent. For organization-level credentials such as OAuth access tokens, you can enable test mode by
setting the testmode query parameter to true.

Test entities cannot be retrieved when the endpoint is set to live mode, and vice versa.
customUserAgent string Custom user agent string to be appended to the default Mollie SDK user agent.

Example

declare(strict_types=1);

require 'vendor/autoload.php';

use Mollie\Api;
use Mollie\Api\Models\Components;
use Mollie\Api\Models\Operations;

$sdk = Api\Client::builder()
    ->setTestmode(true)
    ->setProfileId('<id>')
    ->setCustomUserAgent('<value>')
    ->setSecurity(
        new Components\Security(
            advancedAccessToken: '<YOUR_BEARER_TOKEN_HERE>',
        )
    )
    ->build();

$request = new Operations\ListBalancesRequest(
    currency: 'EUR',
    limit: 50,
    idempotencyKey: '123e4567-e89b-12d3-a456-426',
    xClientSignature: 'MEUCIQDx8sJvK3z...',
    xClientSignedAt: '2025-01-01T12:00:00Z',
);

$responses = $sdk->balances->list(
    request: $request
);


foreach ($responses as $response) {
    if ($response->statusCode === 200) {
        // handle response
    }
}

Pagination

Some of the endpoints in this SDK support pagination. To use pagination, you make your SDK calls as usual, but the returned object will be a Generator instead of an individual response.

Working with generators is as simple as iterating over the responses in a foreach loop, and you can see an example below:

declare(strict_types=1);

require 'vendor/autoload.php';

use Mollie\Api;
use Mollie\Api\Models\Components;
use Mollie\Api\Models\Operations;

$sdk = Api\Client::builder()
    ->setTestmode(true)
    ->setSecurity(
        new Components\Security(
            advancedAccessToken: '<YOUR_BEARER_TOKEN_HERE>',
        )
    )
    ->build();

$request = new Operations\ListBalancesRequest(
    currency: 'EUR',
    limit: 50,
    idempotencyKey: '123e4567-e89b-12d3-a456-426',
    xClientSignature: 'MEUCIQDx8sJvK3z...',
    xClientSignedAt: '2025-01-01T12:00:00Z',
);

$responses = $sdk->balances->list(
    request: $request
);


foreach ($responses as $response) {
    if ($response->statusCode === 200) {
        // handle response
    }
}

Retries

Some of the endpoints in this SDK support retries. If you use the SDK without any configuration, it will fall back to the default retry strategy provided by the API. However, the default retry strategy can be overridden on a per-operation basis, or across the entire SDK.

To change the default retry strategy for a single API call, simply provide an Options object built with a RetryConfig object to the call:

declare(strict_types=1);

require 'vendor/autoload.php';

use Mollie\Api;
use Mollie\Api\Models\Components;
use Mollie\Api\Models\Operations;
use Mollie\Api\Utils\Retry;

$sdk = Api\Client::builder()->build();

$body = new Operations\OauthGenerateTokensRequestBody(
    grantType: Components\OauthGrantType::AuthorizationCode,
    code: 'auth_...',
    refreshToken: 'refresh_...',
    redirectUri: 'https://example.com/redirect',
);
$requestSecurity = new Operations\OauthGenerateTokensSecurity(
    username: '',
    password: '',
);

$response = $sdk->oauth->generate(
    security: $requestSecurity,
    idempotencyKey: '123e4567-e89b-12d3-a456-426',
    body: $body,
    options: Utils\Options->builder()->setRetryConfig(
        new Retry\RetryConfigBackoff(
            initialInterval: 1,
            maxInterval:     50,
            exponent:        1.1,
            maxElapsedTime:  100,
            retryConnectionErrors: false,
        ))->build()

);

if ($response->object !== null) {
    // handle response
}

If you'd like to override the default retry strategy for all operations that support retries, you can pass a RetryConfig object to the SDKBuilder->setRetryConfig function when initializing the SDK:

declare(strict_types=1);

require 'vendor/autoload.php';

use Mollie\Api;
use Mollie\Api\Models\Components;
use Mollie\Api\Models\Operations;
use Mollie\Api\Utils\Retry;

$sdk = Api\Client::builder()
    ->setRetryConfig(
        new Retry\RetryConfigBackoff(
            initialInterval: 1,
            maxInterval:     50,
            exponent:        1.1,
            maxElapsedTime:  100,
            retryConnectionErrors: false,
        )
  )
    ->build();

$body = new Operations\OauthGenerateTokensRequestBody(
    grantType: Components\OauthGrantType::AuthorizationCode,
    code: 'auth_...',
    refreshToken: 'refresh_...',
    redirectUri: 'https://example.com/redirect',
);
$requestSecurity = new Operations\OauthGenerateTokensSecurity(
    username: '',
    password: '',
);

$response = $sdk->oauth->generate(
    security: $requestSecurity,
    idempotencyKey: '123e4567-e89b-12d3-a456-426',
    body: $body

);

if ($response->object !== null) {
    // handle response
}

Error Handling

Handling errors in this SDK should largely match your expectations. All operations return a response object or throw an exception.

By default an API error will raise a Errors\APIException exception, which has the following properties:

Property Type Description
$message string The error message
$statusCode int The HTTP status code
$rawResponse ?\Psr\Http\Message\ResponseInterface The raw HTTP response
$body string The response content

When custom error responses are specified for an operation, the SDK may also throw their associated exception. You can refer to respective Errors tables in SDK docs for more details on possible exception types for each operation. For example, the generate method throws the following exceptions:

Error Type Status Code Content Type
Errors\ErrorResponse 429 application/hal+json
Errors\APIException 4XX, 5XX */*

Example

declare(strict_types=1);

require 'vendor/autoload.php';

use Mollie\Api;
use Mollie\Api\Models\Components;
use Mollie\Api\Models\Errors;
use Mollie\Api\Models\Operations;

$sdk = Api\Client::builder()->build();

try {
    $body = new Operations\OauthGenerateTokensRequestBody(
        grantType: Components\OauthGrantType::AuthorizationCode,
        code: 'auth_...',
        refreshToken: 'refresh_...',
        redirectUri: 'https://example.com/redirect',
    );
    $requestSecurity = new Operations\OauthGenerateTokensSecurity(
        username: '',
        password: '',
    );

    $response = $sdk->oauth->generate(
        security: $requestSecurity,
        idempotencyKey: '123e4567-e89b-12d3-a456-426',
        body: $body

    );

    if ($response->object !== null) {
        // handle response
    }
} catch (Errors\ErrorResponseThrowable $e) {
    // handle $e->$container data
    throw $e;
} catch (Errors\APIException $e) {
    // handle default exception
    throw $e;
}

Server Selection

Override Server URL Per-Client

The default server can be overridden globally using the setServerUrl(string $serverUrl) builder method when initializing the SDK client instance. For example:

declare(strict_types=1);

require 'vendor/autoload.php';

use Mollie\Api;
use Mollie\Api\Models\Components;
use Mollie\Api\Models\Operations;

$sdk = Api\Client::builder()
    ->setServerURL('https://api.mollie.com')
    ->build();

$body = new Operations\OauthGenerateTokensRequestBody(
    grantType: Components\OauthGrantType::AuthorizationCode,
    code: 'auth_...',
    refreshToken: 'refresh_...',
    redirectUri: 'https://example.com/redirect',
);
$requestSecurity = new Operations\OauthGenerateTokensSecurity(
    username: '',
    password: '',
);

$response = $sdk->oauth->generate(
    security: $requestSecurity,
    idempotencyKey: '123e4567-e89b-12d3-a456-426',
    body: $body

);

if ($response->object !== null) {
    // handle response
}

Development

Maturity

This SDK is in alpha, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning usage to a specific package version. This way, you can install the same version each time without breaking changes unless you are intentionally looking for the latest version.

Contributions

While we value open-source contributions to this SDK, this library is generated programmatically. Any manual changes added to internal files will be overwritten on the next generation. We look forward to hearing your feedback. Feel free to open a PR or an issue with a proof of concept and we'll do our best to include it in a future release.

SDK Created by Speakeasy

mollie-automatic-api-php