dvsa/mot-cpms-client 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

dvsa/mot-cpms-client

Composer 安装命令:

composer create-project dvsa/mot-cpms-client

包简介

CPMS Common Client Module

README 文档

README

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

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

composer require dvsa/mot-cpms-client

Configuration

  1. 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 Monolog Logger 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

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

    $client         = $this->getCpmsRestClient(); 

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/<mandate_reference>/status';
         $params        = [
                'status' => '<status code>'
         ];
         $response      = $this->getCpmsRestClient()->get($endPoint, $requiredScope, $params);
      

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] (https://wiki.i-env.net/display/EA/CPMS+Interface+Service+Definition#CPMSInterfaceServiceDefinition-DataModel).

Required field from main table e.g. 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.

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

Please refer to our Contribution Guide.

dvsa/mot-cpms-client 适用场景与选型建议

dvsa/mot-cpms-client 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 12.67k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 06 月 26 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 dvsa/mot-cpms-client 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 dvsa/mot-cpms-client 我们能提供哪些服务?
定制开发 / 二次开发

基于 dvsa/mot-cpms-client 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 12.67k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 7
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 6
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: proprietary
  • 更新时间: 2023-06-26