定制 settleup/catalog 二次开发

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

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

settleup/catalog

最新稳定版本:0.1.0

Composer 安装命令:

composer require settleup/catalog

包简介

A unified product catalog for SaaS billing

README 文档

README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

A unified product catalog for SaaS billing in Laravel. Define catalog items with recurring or metered pricing, manage their lifecycle from draft to published, and expose an optional API — all without coupling to any specific billing provider.

Key Concepts

  • Catalog Items — billable products with a type (Recurring or Metered), a unique SKU, and a managed lifecycle (DraftPublishedDisabled)
  • Recurring Prices — fixed-amount price points billed at configurable intervals (daily, weekly, monthly, quarterly, semi-annual, annual)
  • Metered Prices — tiered pricing based on consumption using Volume or Graduated strategies
  • Polymorphic Registration — attach catalog items to any Eloquent model (servers, plans, features, etc.)
  • Price History — prices are never deleted; syncing disables old prices and creates new ones, preserving a full audit trail

Installation

composer require settleup/catalog

Publish and run the migrations:

php artisan vendor:publish --tag="catalog-migrations"
php artisan migrate

Optionally publish the config:

php artisan vendor:publish --tag="catalog-config"

Usage

Creating Catalog Items

use SettleUp\Catalog\Actions\CreateCatalogItem;
use SettleUp\Catalog\DataTransferObjects\CatalogItemData;
use SettleUp\Catalog\Enums\CatalogItemType;

$item = CreateCatalogItem::make()->handle(
    new CatalogItemData(
        type: CatalogItemType::Recurring,
        name: 'Pro Plan',
        sku: 'pro-plan',
        description: 'Access to all pro features',
    )
);

Managing the Item Lifecycle

Items follow a strict lifecycle: DraftPublishedDisabled. A published item can be disabled and re-enabled, but can never return to draft.

use SettleUp\Catalog\Actions\PublishCatalogItem;
use SettleUp\Catalog\Actions\DisableCatalogItem;
use SettleUp\Catalog\Actions\EnableCatalogItem;

// Publish a draft item
PublishCatalogItem::make()->handle($item);

// Disable it (removes from active catalog)
DisableCatalogItem::make()->handle($item);

// Re-enable it
EnableCatalogItem::make()->handle($item);

Setting Recurring Prices

use SettleUp\Catalog\Actions\SyncRecurringPrices;
use SettleUp\Catalog\DataTransferObjects\RecurringPriceData;
use SettleUp\Catalog\Enums\RecurringInterval;

SyncRecurringPrices::make()->handle($item, [
    new RecurringPriceData(amount: 1999, interval: RecurringInterval::Monthly),
    new RecurringPriceData(amount: 19999, interval: RecurringInterval::Annual),
]);

Setting Metered Prices

use SettleUp\Catalog\Actions\SyncMeteredPrices;
use SettleUp\Catalog\DataTransferObjects\MeteredPriceData;
use SettleUp\Catalog\Enums\PricingStrategy;

SyncMeteredPrices::make()->handle($item, [
    new MeteredPriceData(
        pricingStrategy: PricingStrategy::Graduated,
        minUnits: 0,
        maxUnits: 100,
        pricePerUnit: 10,
        flatFee: 500,
    ),
    new MeteredPriceData(
        pricingStrategy: PricingStrategy::Graduated,
        minUnits: 101,
        maxUnits: null, // unlimited
        pricePerUnit: 5,
    ),
]);

All monetary amounts are stored as integers in cents.

Attaching to Eloquent Models

Use the HasCatalogItems concern to associate catalog items with any model:

use SettleUp\Catalog\Concerns\HasCatalogItems;
use SettleUp\Catalog\Enums\CatalogItemType;

class Server extends Model
{
    use HasCatalogItems;
}

$server->registerCatalogItem(CatalogItemType::Metered, [
    'name' => 'Bandwidth',
    'sku' => 'server-bandwidth',
]);

Registering API Routes

The package provides an optional REST API. Register the routes inside your own route group to control middleware, prefixing, and authentication:

use SettleUp\Catalog\Facades\Catalog;

Route::prefix('api')
    ->middleware(['auth:sanctum'])
    ->group(function () {
        Catalog::routes()->register();
    });

You can limit which routes are registered:

// Only register specific routes
Catalog::routes()->only(['index', 'show', 'store'])->register();

// Register all except certain routes
Catalog::routes()->except(['enable', 'disable'])->register();

Available API Endpoints

Method URI Description
GET /catalog-items List items (filterable by status and type)
POST /catalog-items Create a draft item
GET /catalog-items/{id} Show item with prices
PUT /catalog-items/{id} Update item details
POST /catalog-items/{id}/publish Publish a draft item
POST /catalog-items/{id}/enable Re-enable a disabled item
POST /catalog-items/{id}/disable Disable an item
GET /catalog-items/{id}/recurring-prices List recurring prices
PUT /catalog-items/{id}/recurring-prices Sync recurring prices
GET /catalog-items/{id}/metered-prices List metered prices
PUT /catalog-items/{id}/metered-prices Sync metered prices

Permissions

Every API endpoint is gated by a configurable permission. Set a permission to null to skip authorization for that action:

// config/catalog.php
return [
    'permissions' => [
        'catalog-items' => [
            'index'   => 'catalog:view',
            'store'   => 'catalog:create',
            'show'    => 'catalog:view',
            'update'  => 'catalog:update',
            'publish' => 'catalog:publish',
            'enable'  => 'catalog:update',
            'disable' => 'catalog:update',
        ],
        'recurring-prices' => [
            'index' => 'catalog:view',
            'sync'  => 'catalog:update',
        ],
        'metered-prices' => [
            'index' => 'catalog:view',
            'sync'  => 'catalog:update',
        ],
    ],
];

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

settleup/catalog 适用场景与选型建议

settleup/catalog 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 04 月 11 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-04-11