定制 avto-dev/cloud-payments-laravel 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

avto-dev/cloud-payments-laravel

Composer 安装命令:

composer require avto-dev/cloud-payments-laravel

包简介

Cloud Payments PHP-client

README 文档

README

logo

Cloud Payments PHP-client

Version PHP Version Build Status Coverage Downloads count License

The package provides easy way to use Cloud Payments API.

Install

Require this package with composer using the following command:

$ composer require avto-dev/cloud-payments-laravel

Installed composer is required (how to install composer).

Configuration

You can find laravel framework integration here

For client configuration use Config instance. Client constructor requires Public ID and API Secret that you can find in ClodPayments personal area.

use AvtoDev\CloudPayments\Config;

$config = new Config('pk_some_key', 'some_api_key');

Usage

Select one of requset builders:

$request_builder = new \AvtoDev\CloudPayments\Requests\Payments\Cards\CardsAuthRequestBuilder;

Set all necessary parameters through the setters:

/** @var $request_builder \AvtoDev\CloudPayments\Requests\AbstractRequestBuilder */

$request_builder->setAccountId('some_id');
$request_builder->setName('name');

Get PSR7 request:

/** @var \AvtoDev\CloudPayments\Requests\AbstractRequestBuilder $request_builder */
/** @var \Psr\Http\Message\RequestInterface $request */

$request = $request_builder->buildRequest();

Set up client, and send the request:

$client = new \AvtoDev\CloudPayments\Client(
    new \GuzzleHttp\Client,
    new \AvtoDev\CloudPayments\Config('public_id', 'api_key')
);

/** @var \Psr\Http\Message\RequestInterface $request */
$response = $client->send($request);

Api client

Constructing

Constructor requires any GuzzleHttp\ClientInterface instance and Config instance

/** @var \AvtoDev\CloudPayments\Config $config */

use AvtoDev\CloudPayments\Client;
use GuzzleHttp\Client as GuzzleClient;

$client = new Client(new GuzzleClient, $config);

Sending

This method allows to send any Psr\Http\Message\RequestInterface and returns only Psr\Http\Message\ResponseInterface, that allow you to build own requests as you want or use one of provided requests builders.

This client does only one thing: authorizes requests for CloudPayments and sends them.

$request = new \GuzzleHttp\Psr7\Request('POST','https://api',[],'{"foo":"bar"}');

/** @var \AvtoDev\CloudPayments\Client $client */
$response = $client->send($request);

Request builders

Supported builders:

Builder Description Documentation link
TestRequestBuilder The method to test the interaction with the API Link
CardsAuthRequestBuilder The method to make a payment by a cryptogram Link
CardsChargeRequestBuilder The method to make a payment by a cryptogram. Charge only Link
CardsPost3DsRequestBuilder 3-D Secure Processing Link
TokensAuthRequestBuilder The method to make a payment by a token Link
TokensChargeRequestBuilder The method to make a payment by a token. Charge only Link
PaymentsConfirmRequestBuilder Payment Confirmation Link
PaymentsVoidRequestBuilder Payment Cancellation Link
SubscriptionsCreateRequestBuilder Creation of Subscriptions on Recurrent Payments Link
SubscriptionsGetRequestBuilder Subscription Details Link
SubscriptionsFindRequestBuilder Subscriptions Search Link
SubscriptionsUpdateRequestBuilder Recurrent Payments Subscription Change Link
SubscriptionsCancelRequestBuilder Subscription on Recurrent Payments Cancellation Link

How to get card cryptogram packet?

Idempotency

Idempotency is an ability of API to produce the same result as the first one without re-processing in case of repeated requests. That means you can send several requests to the system with the same identifier, and only one request will be processed. All the responses will be identical. Thus the protection against network errors is implemented which can lead to creation of duplicate records and actions.

To enable idempotency, it is necessary to call setRequestId('request_id') method with a unique identifier in API request. Generation of request identifier remains on your side - it can be a guid, a combination of an order number, date and amount, or other values of your choice. Each new request that needs to be processed must include new request_id value. The processed result is stored in the system for 1 hour.

Frameworks integration

Laravel

Laravel 5.5 and above uses Package Auto-Discovery, so doesn't require you to manually register the service-provider. Otherwise you must add the service provider to the providers array in ./config/app.php:

'providers' => [
    // ...
    AvtoDev\CloudPayments\Frameworks\Laravel\ServiceProvider::class,
]

Laravel configuration

Service provider pick configuration from services.cloud_payments config. So you need to put it into config/services.php file. For example:

return [
    // ...
    /*
    |--------------------------------------------------------------------------
    | CloudPayments Settings
    |--------------------------------------------------------------------------
    | - `public_id` (string) - Public ID  (You can find it in personal area)
    | - `api_key`   (string) - API Secret (You can find it in personal area)
    |
    */
    'cloud_payments' => [
        'public_id' => env('CLOUD_PAYMENTS_PUBLIC_ID', 'some id'),
        'api_key'   => env('CLOUD_PAYMENTS_API_KEY', 'some api key'),
    ],
];

Testing

For package testing we use phpunit framework. Just write into your terminal:

$ make build
$ make install
$ make test

Changes log

Release date Commits since latest release

Changes log can be found here.

Support

Issues Issues

If you will find any package errors, please, make an issue in current repository.

License

This is open-sourced software licensed under the MIT License.

avto-dev/cloud-payments-laravel 适用场景与选型建议

avto-dev/cloud-payments-laravel 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 16.76k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2019 年 12 月 02 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「laravel」 「cloud-payments」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

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

围绕 avto-dev/cloud-payments-laravel 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 16.76k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 5
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 1
  • Forks: 6
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-12-02