承接 teamgantt/dues 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

teamgantt/dues

Composer 安装命令:

composer require teamgantt/dues

包简介

README 文档

README

Table of Contents

Goals

Dues is meant to provide a high level API for processing payments, particularly subscriptions.

It is designed to be processor agnostic, but currently only supports Braintree.

Installation

Dues isn't currently published to packagist. Until it is, it is recommended that dues be installed from the main branch using composer's vcs functionality.

Your composer.json should include the following:

{
  "repositories": [
    {
      "url": "https://github.com/teamgantt/dues",
      "type": "vcs"
    }
  ],
  "require": {
    "teamgantt/dues": "dev-main",
  }
}

See composer documentation for specifying a specific commit.

Usage

The high level API of dues is accessed by constructing a Dues instance with a gateway implementation.

use TeamGantt\Dues\Dues;
use TeamGantt\Dues\Processor\Braintree;

$gateway = new Braintree([
    'environment' => $_ENV['BRAINTREE_ENVIRONMENT'],
    'merchantId' => $_ENV['BRAINTREE_MERCHANT_ID'],
    'publicKey' => $_ENV['BRAINTREE_PUBLIC_KEY'],
    'privateKey' => $_ENV['BRAINTREE_PRIVATE_KEY'],
]);

$dues = new Dues($gateway);

All functionality supported by dues can be found on the Dues class.

Note: some of dues' public API is mixed in via a trait.

Events

Dues provides support for handling certain events via the the addListener method. This method expects an implementation of the EventListener interface.

interface EventListener
{
    public function onAfterCreateCustomer(Customer $customer): void;

    public function onAfterUpdateCustomer(Customer $customer): void;

    public function onBeforeCreateCustomer(Customer $customer): void;

    public function onBeforeUpdateCustomer(Customer $customer): void;

    public function onAfterCreateSubscription(Subscription $subscription): void;

    public function onAfterUpdateSubscription(Subscription $subscription): void;

    public function onBeforeCreateSubscription(Subscription $subscription): void;

    public function onBeforeUpdateSubscription(Subscription $subscription): void;
}

A listener can be removed by calling removeEventListener with the same instance.

$dues->removeListener($listener);

Events are useful for logging, analytics, and other integrations (such as dealing with taxes).

Development

Dues is developed against PHP version 8.1

A Dockerfile is provided for a consistent development environment.

The provided commands in bin/ assume a docker image named dues with a tag of dev. You can build this from the root of the repo:

docker build . -t dues:dev

It is recommended, though not necessary, to use direnv for development. If direnv is installed, the .envrc file will automatically be loaded when entering the project directory. This will allow developers to use the php and composer commands without having to install them locally. All composer commands will be run transparently through the docker container.

Executing from the docker container without direnv

You can use the scripts provided in bin/ directly

$ bin/composer test

Testing

Dues aims for very high test coverage. Tests are written using PHPUnit.

The test suite is broken into unit tests and integration tests.

Individual mileage may vary when running integration tests locally, but the suite is designed to be run in a CI environment. CI tests run against a BrainTree sandbox environment configured by TeamGantt.

To run unit tests locally, run composer test:unit.

To run integration tests locally, run composer test:integration.

Integration and unit tests are not separated by any kind of file naming convention, but instead they are grouped together. An integration test should be annotated using a @group annotation.

/**
 * @group integration
 */
public function testAProcesserRequest()
{

}

Tests are organized by feature in the tests/Feature directory.

BrainTree tests

In order to ensure a consistent test environment, the Braintree tests are run against a sandbox environment. It is important that "duplicate transaction checking" is disabled. This will allow integrations to run tests with the same data multiple times without unexpected results.

Please see the Braintree documentation for more information on configuring duplicate transaction checking.

Conventions

Dues aims to be consistent in style and type correctness. Code conventions are enforced using PHP_CodeSniffer. The list of conventions can be found in the .php-cs-fixer.php file.

Static analysis is perfomed using phpstan. See phpstan.neon for configuration.

There are composer scripts provided for checking conventions and running static analysis.

$ composer run fix
$ composer run check
$ composer run analyse

Note: composer run fix will automatically fix any CodeSniffer issues that can be fixed automatically. This is not always possible, so it is recommended that composer run check be run before committing code.

teamgantt/dues 适用场景与选型建议

teamgantt/dues 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 17.65k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2020 年 12 月 01 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 teamgantt/dues 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 2
  • Watchers: 5
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-12-01