承接 jeanfprado/cashier 相关项目开发

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

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

jeanfprado/cashier

Composer 安装命令:

composer require jeanfprado/cashier

包简介

Cashier provides a subscription billing services.

README 文档

README

Cashier provides subscription billing for Laravel applications. It handles the recurring billing flow and now uses a product-based catalog (plans, add-ons, and other billable items) attached to each subscription.

Table of Contents

Installation

Install via Composer:

composer require jeanfprado/cashier

The package supports auto-discovery. If auto-discovery is disabled, register the service provider manually:

Jeanfprado\Cashier\CashierServiceProvider::class,

Optional facade alias:

'Cashier' => Jeanfprado\Cashier\Support\Facade\Cashier::class,

Publishing Config and Migrations

Publish only the config:

php artisan vendor:publish --tag=cashier-config

Publish only the migrations:

php artisan vendor:publish --tag=cashier-migrations

Then run migrations:

php artisan migrate

Products

Define your products in config/cashier.php under cashier.products.

Each product supports:

  • name
  • description (optional)
  • type (Plan, Add-on, Other)
  • amount (decimal)
  • value (metric value, optional business meaning)
  • operation (increment or decrement)
  • settings (optional JSON)
  • options (optional JSON)

Seed products from config:

php artisan cashier:seed-products

Subscribable Model

Set the subscribable model in config/cashier.php:

'model' => App\Models\User::class,

Your model must implement the contract and use the trait:

<?php

namespace App\Models;

use Illuminate\Foundation\Auth\User as Authenticatable;
use Jeanfprado\Cashier\Subscribable;
use Jeanfprado\Cashier\Contracts\Subscribable as SubscribableContract;

class User extends Authenticatable implements SubscribableContract
{
    use Subscribable;
}

Subscriptions

Create a subscription by passing one or more Product models:

use Jeanfprado\Cashier\Models\Product;
use Jeanfprado\Cashier\Models\Subscription;

$products = Product::whereIn('slug_name', ['extra-storage', 'additional-seats'])->get();

$subscription = $user->subscribe(
    $products,
    Subscription::TYPE_MONTHLY, // monthly, triennial, semestrial, yearly
    7 // optional trial days; falls back to config('cashier.trial_days')
);

Add or remove products on an existing subscription:

$subscription->addProduct($product, 2);   // attach or increment quantity
$subscription->removeProduct($product);   // detach

Cancel the current subscription:

$user->cancelSubscription();

Billing

Generate due billings for all subscriptions:

php artisan cashier:subscription-check

Or generate from code for a single subscription:

if ($subscription->canGenerateBilling() && ! $subscription->hasBillingPending()) {
    $billing = $subscription->generateBilling();
}

Mark a billing as paid:

$billing->markToPaid();

Upgrade Notes (Plan to Product)

Recent migrations replaced the old plans relation with a product catalog + pivot (subscription_products).

  • Existing plan records are migrated into products.
  • Existing subscriptions are linked to migrated products.
  • subscriptions.plan_id is replaced by subscriptions.type.
  • The legacy plans table is removed.

If you are upgrading an existing installation, publish/update migrations and run:

php artisan migrate

After migrating, review config/cashier.php and run cashier:seed-products to add any new catalog items.

Contributing

Thank you for considering contributing to Cashier.

License

Cashier is open-sourced software licensed under the MIT license.

jeanfprado/cashier 适用场景与选型建议

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

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-04-07