PHPackages                             dvsa/mot-cpms-client - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. dvsa/mot-cpms-client

ActiveProject[Utility &amp; Helpers](/categories/utility)

dvsa/mot-cpms-client
====================

CPMS Common Client Module

v3.1.0(1y ago)011.1k↓42.9%1[1 PRs](https://github.com/dvsa/mot-cpms-client/pulls)2proprietaryPHPPHP ^8.2

Since Jun 23Pushed 1y ago6 watchersCompare

[ Source](https://github.com/dvsa/mot-cpms-client)[ Packagist](https://packagist.org/packages/dvsa/mot-cpms-client)[ RSS](/packages/dvsa-mot-cpms-client/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (15)Versions (13)Used By (2)

CPMS Rest Client
================

[](#cpms-rest-client)

Introduction
------------

[](#introduction)

This a module designed to make restful API calls to CPMS backend API. It handles

- The generation of the required access token based on the scope
- Logging when a logger alias is provided
- Caching of access tokens when caching is setup and enabled.

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

[](#installation)

The recommended way to install is through \[Composer\]\[composer\].

```
composer require dvsa/mot-cpms-client

```

### Configuration

[](#configuration)

3. Modify the configuration in the client-config.global.php file as follows:

    ```
      ```
          return array(
              'cpms_api'                => array(
                  'version'           => 1,
                  'logger_alias'      => '',
                  'identity_provider' => '',
                  'enable_cache'      => true, //Enable of caching of access tokens for reuse
                  'cache_storage'     => 'filesystem',
                  'rest_client'   => array(
                      'options' => array(
                          'domain'             => ''
                      ),
                  ),
              ),
          );

    ```

    - `version` : This is the version of CPMS API to target, currently on version 1
    - `logger_alias` : Zend Service Manager alias for retrieving a Laminas\\Log instance
    - `identity_provider` : This is the service manager alias that should return an object which implements `CpmsClient\Authenticate\IdentityProviderInterface`. This is mandatory. The following information is retrieved from the class

        - `client_id` : The ID issues by CPMS that uniquely identifies the Scheme e.g. OLCS
        - `client_secret` : Hash value issued by CPMS
        - `user_id` : This is the OpenAM UUID of the logged in user. It is the responsiblity of the scheme to ensure that the data provided is valid as it would be logged against any action performed in CPMS for audit purposes.
        - `customer_reference` : This is the unique identifier for the customer on who is making the payment. In MoT this is the AE and in OLCS it would be the operator etc.
    - `enable_cache` : Enable caching of access tokens for reuse.
    - `cache_storage` : Zend cache storage alias which would be load using Zend's StorageCacheAbstractServiceFactory. The default is `filesystem`
    - `domain` : The API domain to which all API calls will be sent.

### Controller Plugin

[](#controller-plugin)

The `cpms-client` module ships with a controller plugin which simplifies usage of the Rest Client. In your controller:

```
    $client         = $this->getCpmsRestClient();

```

Usage
-----

[](#usage)

Below a typical usage of the `cpms-client` module.

- Requesting access token to make a card payment `POST`. Note that this is just an example for usage. By default, the module does this for you behind the scenes.

    ```
      $requiredScope  = 'CARD';
      $endPoint       = '/api/token';
      $client         = $this->getCpmsRestClient();
      $params         = [
          'sales_reference' => 'your invoice number ',
          ......
      ];

      $response       = $client->post($endPoint, $requiredScope, $params);

    ```
- Retrieving payment details and specifying required fields, page, depth etc `GET`. The client would generate the required access token for you, so you do not need to manually generate the access token.

    ```
          $requiredScope = 'QUERY_TXN';
          $endPoint      = '/api/payment';

           $params = array(
                'page'   => 1,
                'sort'   => 'id:desc',
                'params' => array(
                    'depth'           => -2,
                    'required_fields' => array(
                        'payment'       => array(
                            'created_on',
                            'receipt_reference',
                            'scope',
                            'total_amount',
                            'payment_details',
                            'payment_status',
                            'customer_reference',
                            'created_by'
                        ),
                        'paymentDetail' => array(
                            'product_reference',
                            'sales_reference',
                            'payment_reference',
                            'amount'
                        ),
                        'scope'         => array(
                            'code',
                            'name'
                        ),
                        'paymentStatus' => array(
                            'code',
                            'name',
                        )
                    )
                ),
            );

            $payments = $this->getCpmsRestClient()->get($endPoint, $requiredScope, $params);

    ```

    - Updating the status of a mandate `PUT`

        ```
           $requiredScope = 'DIRECT_DEBIT';
           $endPoint      = '/api/mandate//status';
           $params        = [
                  'status' => ''
           ];
           $response      = $this->getCpmsRestClient()->get($endPoint, $requiredScope, $params);

        ```

### Specifying Required Fields

[](#specifying-required-fields)

When querying CPMS for data e.g. payment details, it is recommended that you specify the fields you want returned in the request. If not specified, CMS would return the defaults fields which may change. The fields available are the column names as specified in the \[database scheme\] ().

#### Required field from main table e.g. Payment

[](#required-field-from-main-table-eg-payment)

```
    $requiredFields = [
          'created_on',
          'receipt_reference',
          'scope',
          'total_amount',
          'payment_details',
          'payment_status',
          'customer_reference',
          'created_by'
    ]

```

#### Required fields from join tables e.g PaymentDetails. Payment has a (one-to-many) relationship with PaymentDetails.

[](#required-fields-from-join-tables-eg-paymentdetails-payment-has-a-one-to-many-relationship-with-paymentdetails)

Note that the field names are underscore separated while the entity names are camel cases.

```
        $requiredFields = [
            'payment'       => [
                  'created_on',
                  'receipt_reference',
                  'scope',
                  'total_amount',
                  'payment_details',
                  'payment_status',
                  'customer_reference',
                  'created_by'
              ],
              'paymentDetail' => [
                  'product_reference',
                  'sales_reference',
                  'payment_reference',
                  'amount'
              ],
          ]

```

Contributing
------------

[](#contributing)

Please refer to our [Contribution Guide](/CONTRIBUTING.md).

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance35

Infrequent updates — may be unmaintained

Popularity26

Limited adoption so far

Community20

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~100 days

Total

5

Last Release

661d ago

Major Versions

v1.1.0 → v2.0.02023-10-13

v2.0.0 → v3.0.02024-07-16

PHP version history (3 changes)v1.0.0PHP ^8.0

v1.1.0PHP ^8.1

v3.0.0PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/6ac141ec696a70dbc4b8c1c7541cd1bfc06e99617f2484d7631ed43cb48d2f6b?d=identicon)[dvsa](/maintainers/dvsa)

---

Top Contributors

[![UndermountainK](https://avatars.githubusercontent.com/u/143088690?v=4)](https://github.com/UndermountainK "UndermountainK (3 commits)")[![alexisc-kainos](https://avatars.githubusercontent.com/u/74315644?v=4)](https://github.com/alexisc-kainos "alexisc-kainos (1 commits)")[![faggc](https://avatars.githubusercontent.com/u/44438005?v=4)](https://github.com/faggc "faggc (1 commits)")[![mateuszc-kainos](https://avatars.githubusercontent.com/u/20680998?v=4)](https://github.com/mateuszc-kainos "mateuszc-kainos (1 commits)")[![sdh100shaun](https://avatars.githubusercontent.com/u/79883?v=4)](https://github.com/sdh100shaun "sdh100shaun (1 commits)")[![waringr](https://avatars.githubusercontent.com/u/79579024?v=4)](https://github.com/waringr "waringr (1 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/dvsa-mot-cpms-client/health.svg)

```
[![Health](https://phpackages.com/badges/dvsa-mot-cpms-client/health.svg)](https://phpackages.com/packages/dvsa-mot-cpms-client)
```

###  Alternatives

[heise/shariff

PHP backend for Shariff. Shariff enables website users to share their favorite content without compromising their privacy.

139152.5k9](/packages/heise-shariff)

PHPackages © 2026

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