PHPackages                             cruisedotco/trustly-client-php - 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. cruisedotco/trustly-client-php

ActiveLibrary[Payment Processing](/categories/payments)

cruisedotco/trustly-client-php
==============================

Implementation of communications with Trustly public API for Online bank e-payments. See https://trustly.com for more information

1.0.4(8y ago)011.0kPHPPHP &gt;=5.2.0

Since Nov 15Pushed 8y ago1 watchersCompare

[ Source](https://github.com/CruiseDotCo/trustly-client-php)[ Packagist](https://packagist.org/packages/cruisedotco/trustly-client-php)[ Docs](http://github.com/trustly/trustly-client-php)[ RSS](/packages/cruisedotco-trustly-client-php/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (2)Versions (8)Used By (0)

Trustly PHP Client
==================

[](#trustly-php-client)

This is an example implementation of communication with the Trustly API using PHP. It implements the standard Payments API as well as gives stubs for executing calls against the API used by the backoffice.

For full documentation on the Trustly API internals visit our developer website:  . All information about software flows and call patters can be found on that site. The documentation within this code will only cover the code itself, not how you use the Trustly API.

This code is provided as-is, use it as inspiration, reference or drop it directly into your own project and use it.

If you find problem in the code or want to extend it feel free to fork it and send us a pull request.

This code should work with PHP 5 (&gt;= 5.2.0). PHP modules needed are: bcmath, openssl, curl, mbstring and json.

Overview
========

[](#overview)

The code provided wrappers for calling the trustly API. Create an instance of the API call with you merchant criterias and use the stubs in that class for calling the API. The API will default to communicate with , override the `host` parameter for the constructor to comminicate with test.trustly.com instead.

When processing an incoming notification the `handleNotification()` method of the API will help with parsing and verifying the message signature, use `notificationResponse()`to build a proper response object

The examples below represent a very basic usage of the calls. A minimum of error handling around this code would be to check for the following exceptions during processing.

- `Trustly_ConnectionException`

    Thrown when unable to communicate with the Trustly API. This can be due to Internet or other forms of service errors.
- `Trustly_DataException`

    Thrown upon various problems with the API returned data. For instance when a responding message contains a different UUID then the sent message or when the response structure is incomplete.
- `Trustly_SignatureException`

    Issued when the authenticity of messages cannot be verified. If ever this exception is caught the data in the communication should be voided as it can be a forgery.

Example deposit call
--------------------

[](#example-deposit-call)

```
require_once('Trustly.php');

/* Change 'test.trustly.com' to 'trustly.com' below to use the live environment */
$api = new Trustly\Api\Trustly_Api_Signed(
                $trustly_rsa_private_key,
                $trustly_username,
                $trustly_password,
                'test.trustly.com'
            );

/* Guzzle will handle our remote requests. */
$api->setGuzzle(new \GuzzleHttp\Client());

$deposit = $api->deposit(
                "$base_url/php/example.php/notification",   /* NotificationURL */
                'john.doe@example.com',                     /* EndUserID */
                $messageid,                                 /* MessageID */
                'en_US',                                    /* Locale */
                $amount,                                    /* Amount */
                $currency,                                  /* Currency */
                'SE',                                       /* Country */
                NULL,                                       /* MobilePhone */
                NULL,                                       /* FirstName */
                NULL,                                       /* LastName */
                NULL,                                       /* NationalIdentificationNumber */
                'Test',                                     /* ShopperStatement */
                $ip,                                        /* IP */
                "$base_url/success.html",                   /* SuccessURL */
                "$base_url/fail.html",                      /* FailURL */
                NULL,                                       /* TemplateURL */
                "0",                                        /* URLTarget */
                NULL,                                       /* SuggestedMinAmount */
                NULL,                                       /* SuggestedMaxAmount */
                'trustly-client-php example/1.0'            /* IntegrationModule */
                FALSE,                                      /* HoldNotifications */
                'john.doe@example.com',                     /* Email */
                'SE',                                       /* ShippingAddressCountry */
                '12345',                                    /* ShippingAddressPostalCode */
                'ExampleCity',                              /* ShippingAddressCity */
                '123 Main St'                               /* ShippingAddressLine1 */
                'C/O Careholder',                           /* ShippingAddressLine2 */
                NULL                                        /* ShippingAddress */
            );

$iframe_url= $deposit->getData('url');

```

Example notification processing
-------------------------------

[](#example-notification-processing)

```
$request = $api->handleNotification($notification_body);
    # FIXME Handle the incoming notification data here
$notifyresponse = $api->notificationResponse($request, TRUE);

echo $notifyresponse->json();

```

Example implementation
----------------------

[](#example-implementation)

In the example/ subdirectory is a simple implementation of a client that uses the code to make a deposit call to Trustly and processes incoming notifications. The code is well commented and contains information about what to calls that needs to be made and some caveats while doing so.

Use the built-in php webserver to give it a go (php -S localhost:8000 in the example/www directory). You need to amend `example/www/php/example.php` and `example/example.private.pem` to contain your processing account information before giving it a test spin.

Contribution / Development
--------------------------

[](#contribution--development)

Feel free to raise a pull request for changes that you may need. Any changes coming in would need to be covered with unit tests.

Thanks very much, happy open sourcing.

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 80.9% 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 ~10 days

Recently: every ~4 days

Total

7

Last Release

3035d ago

Major Versions

0.1.1 → 1.0.02018-01-02

### Community

Maintainers

![](https://www.gravatar.com/avatar/0f9bb8121a4df6a00f95195587ea47a2cdb6de5644c13637a2bb60496b86b7ee?d=identicon)[cruiseco](/maintainers/cruiseco)

---

Top Contributors

[![perltrustly](https://avatars.githubusercontent.com/u/45230070?v=4)](https://github.com/perltrustly "perltrustly (72 commits)")[![forceedge01](https://avatars.githubusercontent.com/u/1619816?v=4)](https://github.com/forceedge01 "forceedge01 (9 commits)")[![Pelleplutt](https://avatars.githubusercontent.com/u/2745232?v=4)](https://github.com/Pelleplutt "Pelleplutt (5 commits)")[![makasim](https://avatars.githubusercontent.com/u/143206?v=4)](https://github.com/makasim "makasim (1 commits)")[![ramonv](https://avatars.githubusercontent.com/u/333021?v=4)](https://github.com/ramonv "ramonv (1 commits)")[![TXC](https://avatars.githubusercontent.com/u/236697?v=4)](https://github.com/TXC "TXC (1 commits)")

---

Tags

paymenttrustly

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/cruisedotco-trustly-client-php/health.svg)

```
[![Health](https://phpackages.com/badges/cruisedotco-trustly-client-php/health.svg)](https://phpackages.com/packages/cruisedotco-trustly-client-php)
```

###  Alternatives

[shetabit/multipay

PHP Payment Gateway Integration Package

291348.2k3](/packages/shetabit-multipay)[bitpay/sdk

Complete version of the PHP library for the new cryptographically secure BitPay API

42337.5k4](/packages/bitpay-sdk)[trustly/trustly-client-php

Implementation of communications with Trustly public API for Online bank e-payments. See https://trustly.com for more information

18380.3k1](/packages/trustly-trustly-client-php)[sebdesign/laravel-viva-payments

A Laravel package for integrating the Viva Payments gateway

4845.9k](/packages/sebdesign-laravel-viva-payments)[paypayopa/php-sdk

PHP SDK for PayPay Open Payment API

18279.6k3](/packages/paypayopa-php-sdk)[henryejemuta/laravel-monnify

A laravel package to seamlessly integrate monnify api within your laravel application

132.1k](/packages/henryejemuta-laravel-monnify)

PHPackages © 2026

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