PHPackages                             multisafepay/php-sdk - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Payment Processing](/categories/payments)
4. /
5. multisafepay/php-sdk

ActiveLibrary[Payment Processing](/categories/payments)

multisafepay/php-sdk
====================

MultiSafepay PHP SDK

5.21.0(2mo ago)14930.8k—4.4%11[1 issues](https://github.com/MultiSafepay/php-sdk/issues)6OSL-3.0PHPPHP ^7.2|^8.0CI passing

Since Jun 5Pushed 2mo ago7 watchersCompare

[ Source](https://github.com/MultiSafepay/php-sdk)[ Packagist](https://packagist.org/packages/multisafepay/php-sdk)[ RSS](/packages/multisafepay-php-sdk/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (26)Versions (43)Used By (6)

 [![](https://raw.githubusercontent.com/MultiSafepay/MultiSafepay-logos/master/MultiSafepay-logo-color.svg)](https://raw.githubusercontent.com/MultiSafepay/MultiSafepay-logos/master/MultiSafepay-logo-color.svg)

MultiSafepay PHP SDK
====================

[](#multisafepay-php-sdk)

[![Build](https://camo.githubusercontent.com/c0d1e92d7f471f44dc1e8cf8b1cee8af094da06ac776f26b44138e12e17f9953/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6d756c7469736166657061792f7068702d73646b2f6275696c642e796d6c3f7374796c653d666f722d7468652d6261646765)](https://github.com/MultiSafepay/php-sdk/actions)[![Codecov](https://camo.githubusercontent.com/336f27644c9d0132e7bb3231725170b978b9dedfa7ab9dd4f5bbe9f80f14174c/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f6d756c7469736166657061792f7068702d73646b3f7374796c653d666f722d7468652d6261646765)](https://app.codecov.io/gh/MultiSafepay/php-sdk)[![Latest stable version](https://camo.githubusercontent.com/270a87d92c92f639ebc184629c1b979338714f9994f38cc506d038081026c5b1/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f6d756c7469736166657061792f7068702d73646b3f7374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/multisafepay/php-sdk)[![Total downloads](https://camo.githubusercontent.com/686b500561ae2ad5742065f81f54704a62fce652c0c38593efe99608c2092fca/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d756c7469736166657061792f7068702d73646b3f7374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/multisafepay/php-sdk/stats)[![License](https://camo.githubusercontent.com/5c05bc8428412578001a5ca76a3f8030696892a94602f5552a39861b872221f9/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6d756c7469736166657061792f7068702d73646b3f7374796c653d666f722d7468652d6261646765)](https://github.com/MultiSafepay/php-sdk/blob/master/LICENSE.md)

About MultiSafepay
------------------

[](#about-multisafepay)

MultiSafepay is a Dutch payment services provider, which takes care of contracts, processing transactions, and collecting payment for a range of local and international payment methods. Start selling online today and manage all your transactions in one place!

Installation
------------

[](#installation)

Run the following composer command:

```
composer require multisafepay/php-sdk
```

**WARNING!** This SDK does **not** have a direct dependency on Guzzle or cURL. Instead, it uses the [PSR-18](https://www.php-fig.org/psr/psr-18/) client abstraction and [PSR-17](https://www.php-fig.org/psr/psr-18/) factory abstraction. This lets you choose which [PSR-7 implementation and HTTP client](https://packagist.org/providers/psr/http-client-implementation) to use. You can replace all clients without any side effects.

If you don't have a client implementation installed, run:

```
composer require guzzlehttp/guzzle
```

If you don't have a factory implementation installed, run:

```
composer require http-interop/http-factory-guzzle
```

You should now have installed:

- [PSR-18 client implementation](https://packagist.org/providers/psr/http-client-implementation)
- [PSR-17 factory implementation](https://packagist.org/providers/psr/http-factory-implementation)
- [PSR-7 message implementation](https://packagist.org/providers/psr/http-message-implementation)

Getting started
---------------

[](#getting-started)

Use Composer autoloader to automatically load class dependencies:

```
require 'vendor/autoload.php';
```

Next, instantiate the SDK with your [site API key](https://docs.multisafepay.com/docs/sites#site-id-api-key-and-security-code) and a flag to identify whether this is the live environment or testing environment.

```
$yourApiKey = 'your-api-key';
$isProduction = false;
$multiSafepaySdk = new \MultiSafepay\Sdk($yourApiKey, $isProduction);
```

From the SDK, you can get various managers:

```
$multiSafepaySdk->getTransactionManager();
$multiSafepaySdk->getGatewayManager();
$multiSafepaySdk->getPaymentMethodManager();
$multiSafepaySdk->getIssuerManager();
$multiSafepaySdk->getCategoryManager();
$multiSafepaySdk->getTokenManager();
$multiSafepaySdk->getApiTokenManager();
```

The transaction manager is the most important, because it lets you create orders and refunds.

```
use MultiSafepay\ValueObject\Customer\Country;
use MultiSafepay\ValueObject\Customer\Address;
use MultiSafepay\ValueObject\Customer\PhoneNumber;
use MultiSafepay\ValueObject\Customer\EmailAddress;
use MultiSafepay\ValueObject\Amount;
use MultiSafepay\ValueObject\Currency;
use MultiSafepay\Api\Transactions\OrderRequest\Arguments\CustomerDetails;
use MultiSafepay\Api\Transactions\OrderRequest\Arguments\PluginDetails;
use MultiSafepay\Api\Transactions\OrderRequest\Arguments\PaymentOptions;
use MultiSafepay\Api\Transactions\OrderRequest;

$yourApiKey = 'your-api-key';
$isProduction = false;
$multiSafepaySdk = new \MultiSafepay\Sdk($yourApiKey, $isProduction);

$orderId = (string) time();
$description = 'Order #' . $orderId;
$amount = new Amount(2000); // Amount must be in cents!!
$currency = new Currency('EUR');

$address = (new Address())
    ->addStreetName('Kraanspoor')
    ->addStreetNameAdditional('(blue door)')
    ->addHouseNumber('39')
    ->addZipCode('1033SC')
    ->addCity('Amsterdam')
    ->addState('Noord Holland')
    ->addCountry(new Country('NL'));

$customer = (new CustomerDetails())
    ->addFirstName('John')
    ->addLastName('Doe')
    ->addAddress($address)
    ->addEmailAddress(new EmailAddress('noreply@example.org'))
    ->addPhoneNumber(new PhoneNumber('0208500500'))
    ->addLocale('nl_NL');

$pluginDetails = (new PluginDetails())
    ->addApplicationName('My e-commerce application')
    ->addApplicationVersion('0.0.1')
    ->addPluginVersion('1.1.0');

$paymentOptions = (new PaymentOptions())
    ->addNotificationUrl('http://www.example.com/client/notification?type=notification')
    ->addRedirectUrl('http://www.example.com/client/notification?type=redirect')
    ->addCancelUrl('http://www.example.com/client/notification?type=cancel')
    ->addCloseWindow(true);

$orderRequest = (new OrderRequest())
    ->addType('redirect')
    ->addOrderId($orderId)
    ->addDescriptionText($description)
    ->addAmount($amount)
    ->addCurrency($currency)
    ->addGatewayCode('IDEAL')
    ->addCustomer($customer)
    ->addDelivery($customer)
    ->addPluginDetails($pluginDetails)
    ->addPaymentOptions( $paymentOptions);

$transactionManager = $multiSafepaySdk->getTransactionManager()->create($orderRequest);
$transactionManager->getPaymentUrl();
```

Example refund:

```
// Refund example.
use MultiSafepay\Api\Transactions\RefundRequest;
use MultiSafepay\ValueObject\Amount;
use MultiSafepay\ValueObject\Currency;

$yourApiKey = 'your-api-key';
$isProduction = false;
$multiSafepaySdk = new \MultiSafepay\Sdk($yourApiKey, $isProduction);

$orderId = XXXXX;  // The order ID of a previously completed transaction
$refundAmount = new Amount(2000);
$refundCurrency = new Currency('EUR');
$transactionManager = $multiSafepaySdk->getTransactionManager();
$transaction = $transactionManager->get($orderId);
$transactionManager->refund($transaction, (new RefundRequest())->addAmount($refundAmount)->addCurrency($refundCurrency));
```

For examples of building full requests, see [USAGE.md](USAGE.md) and the functional tests in `tests/Functional/Api/Transactions`.

Advanced usage: Strict mode
---------------------------

[](#advanced-usage-strict-mode)

Strict mode:

- Adds additional validations on top of various API requests and responses.
- Validation errors throw an exception, which you need to handle.
- It is enabled in tests.

Non-strict mode (default) skips some validation errors.

**Example:**If there is a mismatch between the number of decimal places of the total amount of the items in the `ShoppingCart` object and your ecommerce platform, strict mode throws an `\MultiSafepay\Exception\InvalidTotalAmountException` exception.

Code quality checks
-------------------

[](#code-quality-checks)

The following checks are in place to maintain code quality:

- PHP CodeSniffer (via `./vendor/bin/phpcs --standard=phpcs.ruleset.xml .`)
    - PSR-2
    - Object Calisthenics
- PHPUnit tests (via `./vendor/bin/phpunit`)
    - Unit tests
    - Integration tests
    - Functional tests

Testing
-------

[](#testing)

- Unit tests work without the API or any dependencies (`tests/Unit`)
- Integration tests work without the API but have dependencies (`tests/Integration`)
- Functional tests work with the live API (`tests/Functional`) – API key required

#### Unit tests

[](#unit-tests)

To run unit tests from this package:

1. Clone this repository.
2. To install all dependencies, run `composer install`
3. Run PHPUnit with the following command: `./vendor/bin/phpunit tests/Unit`

#### Functional tests

[](#functional-tests)

To run functional tests from this package:

1. Clone this repository.
2. To install all dependencies, run `composer install`.
3. Copy `.env.php.example` to `.env.php` and add your site API key.
4. Run PHPUnit with the following command: `./vendor/bin/phpunit tests/Functional`

#### Mocking the API for unit and integration tests

[](#mocking-the-api-for-unit-and-integration-tests)

Unit and integration tests run without the API, which means that the client is mocking all data calls. To do this, the `tests/fixture-data` folder contains JSON files to spoof calls. To fill this folder with real data, make sure you have a valid `.env.php` file, and then use the following command:

```
php tests/generateApiMocks.php

```

This commits all generated JSON files into git, so that they serve as fixtures. Files that are not used in tests don't need to be generated.

Support
-------

[](#support)

Create an issue on this repository or email [](mailto:integration@multisafepay.com)

Contributors
------------

[](#contributors)

If you create a pull request to suggest an improvement, we'll send you some MultiSafepay swag as a thank you!

License
-------

[](#license)

[Open Software License (OSL 3.0)](https://github.com/MultiSafepay/php-sdk/blob/master/LICENSE.md)

Want to be part of the team?
----------------------------

[](#want-to-be-part-of-the-team)

Are you a developer interested in working at MultiSafepay? Check out our [job openings](https://www.multisafepay.com/careers/#jobopenings) and feel free to get in touch!

###  Health Score

62

—

FairBetter than 99% of packages

Maintenance83

Actively maintained with recent releases

Popularity49

Moderate usage in the ecosystem

Community30

Small or concentrated contributor base

Maturity72

Established project with proven stability

 Bus Factor1

Top contributor holds 54.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~51 days

Recently: every ~41 days

Total

42

Last Release

77d ago

Major Versions

1.0.0 → 2.0.02020-07-08

2.0.0 → 3.0.02020-08-19

3.0.2 → 4.0.02020-09-11

4.1.0 → 5.0.02021-02-16

PHP version history (2 changes)1.0.0PHP ^7.1

5.0.0PHP ^7.2|^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/2191df32ae1d7f2d5559e91e73bf29e8b003b368917a0985afcb3c4e23de8587?d=identicon)[MSP](/maintainers/MSP)

---

Top Contributors

[![jissereitsma](https://avatars.githubusercontent.com/u/7670482?v=4)](https://github.com/jissereitsma "jissereitsma (307 commits)")[![danielcivit](https://avatars.githubusercontent.com/u/64795062?v=4)](https://github.com/danielcivit "danielcivit (82 commits)")[![vinodsowdagar](https://avatars.githubusercontent.com/u/53818758?v=4)](https://github.com/vinodsowdagar "vinodsowdagar (49 commits)")[![Jasper-MultiSafepay](https://avatars.githubusercontent.com/u/26003384?v=4)](https://github.com/Jasper-MultiSafepay "Jasper-MultiSafepay (38 commits)")[![mikededecker1](https://avatars.githubusercontent.com/u/41482163?v=4)](https://github.com/mikededecker1 "mikededecker1 (30 commits)")[![Stanislau-MultiSafepay](https://avatars.githubusercontent.com/u/78361324?v=4)](https://github.com/Stanislau-MultiSafepay "Stanislau-MultiSafepay (25 commits)")[![Miguel-MultiSafepay](https://avatars.githubusercontent.com/u/104830395?v=4)](https://github.com/Miguel-MultiSafepay "Miguel-MultiSafepay (10 commits)")[![J0risS](https://avatars.githubusercontent.com/u/63226870?v=4)](https://github.com/J0risS "J0risS (8 commits)")[![Ronald-MultiSafepay](https://avatars.githubusercontent.com/u/29576036?v=4)](https://github.com/Ronald-MultiSafepay "Ronald-MultiSafepay (4 commits)")[![Markus-MultiSafepay](https://avatars.githubusercontent.com/u/83587490?v=4)](https://github.com/Markus-MultiSafepay "Markus-MultiSafepay (3 commits)")[![Thomas-MultiSafepay](https://avatars.githubusercontent.com/u/57214075?v=4)](https://github.com/Thomas-MultiSafepay "Thomas-MultiSafepay (2 commits)")[![CasEbb](https://avatars.githubusercontent.com/u/617080?v=4)](https://github.com/CasEbb "CasEbb (1 commits)")[![Lars-MultiSafepay](https://avatars.githubusercontent.com/u/48061444?v=4)](https://github.com/Lars-MultiSafepay "Lars-MultiSafepay (1 commits)")[![DaanDeSmedt](https://avatars.githubusercontent.com/u/1093123?v=4)](https://github.com/DaanDeSmedt "DaanDeSmedt (1 commits)")

---

Tags

phpphp-library

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/multisafepay-php-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/multisafepay-php-sdk/health.svg)](https://phpackages.com/packages/multisafepay-php-sdk)
```

###  Alternatives

[openai-php/client

OpenAI PHP is a supercharged PHP API client that allows you to interact with the Open AI API

5.8k22.6M232](/packages/openai-php-client)[opensearch-project/opensearch-php

PHP Client for OpenSearch

15224.3M65](/packages/opensearch-project-opensearch-php)[phpro/http-tools

HTTP tools for developing more consistent HTTP implementations.

28137.8k](/packages/phpro-http-tools)[deeplcom/deepl-php

Official DeepL API Client Library

2616.2M66](/packages/deeplcom-deepl-php)[mariosimao/notion-sdk-php

A complete Notion SDK for PHP developers.

171225.1k1](/packages/mariosimao-notion-sdk-php)[php-soap/psr18-transport

PSR-18 HTTP Client transport for SOAP

183.4M20](/packages/php-soap-psr18-transport)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
