承接 aiarmada/cashier 相关项目开发

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

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

aiarmada/cashier

Composer 安装命令:

composer require aiarmada/cashier

包简介

Unified multi-gateway billing integration for Laravel supporting Stripe and CHIP

README 文档

README

A unified multi-gateway billing integration for Laravel supporting Stripe and CHIP.

Introduction

AIArmada Cashier provides a unified interface for working with multiple payment gateways in Laravel. Instead of learning different APIs for Stripe and CHIP, you can use a single, consistent API that works across all supported gateways.

Key Features

  • Unified API: One interface for multiple gateways
  • Multi-Gateway Support: Users can have subscriptions on different gateways simultaneously
  • Gateway Manager: Factory pattern for resolving gateways dynamically
  • Contract-First Design: All components implement well-defined interfaces
  • No Data Duplication: Subscriptions stored in respective gateway tables

Architecture

This package is a wrapper/adapter layer that delegates to underlying gateway packages:

  • laravel/cashier → Stripe subscriptions stored in subscriptions table
  • aiarmada/cashier-chip → CHIP subscriptions stored in chip_subscriptions table

No additional tables are created. This package provides a unified interface only.

Requirements

  • PHP 8.4+
  • Laravel 13.0+
  • At least one gateway package installed:
    • laravel/cashier for Stripe
    • aiarmada/cashier-chip for CHIP

Installation

composer require aiarmada/cashier

Install gateway packages as needed:

# For Stripe
composer require laravel/cashier

# For CHIP
composer require aiarmada/cashier-chip

Publish the configuration:

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

Migration Ownership

aiarmada/cashier does not ship a unified billing schema.

  • Stripe columns and subscription tables come from laravel/cashier
  • CHIP columns and subscription tables come from aiarmada/cashier-chip

If laravel/cashier is installed, this package will conditionally auto-load the vendor Stripe migrations when your app has not published them yet. Publish them when you need to customize the schema:

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

If you also install aiarmada/cashier-chip, just run your normal migrations and its package tables / billable columns will be created by that package.

Configuration

Environment Variables

# Default gateway
CASHIER_GATEWAY=stripe

# Stripe Configuration (if using laravel/cashier)
STRIPE_KEY=pk_live_xxx
STRIPE_SECRET=sk_live_xxx
STRIPE_WEBHOOK_SECRET=whsec_xxx

# CHIP Configuration (if using cashier-chip)
CHIP_BRAND_ID=your_brand_id
CHIP_COLLECT_API_KEY=your_collect_api_key
CHIP_WEBHOOK_SECRET=your_webhook_secret

# Currency Settings
CASHIER_CURRENCY=USD
CASHIER_CURRENCY_LOCALE=en_US
CASHIER_STRIPE_CURRENCY_LOCALE=en_US
CASHIER_CHIP_CURRENCY_LOCALE=ms_MY

Usage

Setting Up the Billable Model

Add all billable traits to your User model:

use AIArmada\Cashier\Billable as CashierBillable;
use Laravel\Cashier\Billable as StripeBillable;
use AIArmada\CashierChip\Billable as ChipBillable;

class User extends Authenticatable
{
    use StripeBillable, ChipBillable, CashierBillable;
}

Gateway Selection

use AIArmada\Cashier\Cashier;

// Get the default gateway
$gateway = Cashier::gateway();

// Get a specific gateway
$stripeGateway = Cashier::gateway('stripe');
$chipGateway = Cashier::gateway('chip');

// From a billable model
$user->gateway();        // Default gateway
$user->gateway('chip');  // Specific gateway

Creating Subscriptions

// Via default gateway
$user->newGatewaySubscription('default', 'price_xxx')->create();

// Via specific gateway
$user->newGatewaySubscription('default', 'price_xxx', 'chip')->create();

// Or drop down to the gateway adapter when you need gateway-specific behavior
$user->gateway('stripe')->subscription($user, 'default', 'price_xxx')->create();

Querying Subscriptions

// Get all subscriptions across all gateways
$allSubscriptions = $user->allSubscriptions();

// Find a subscription by type from any gateway
$subscription = $user->findSubscription('default');

// Get subscriptions for a specific gateway
$stripeSubscriptions = $user->gatewaySubscriptions('stripe');
$chipSubscriptions = $user->gatewaySubscriptions('chip');

// Check if subscribed on any gateway
if ($user->subscribedOnAny('premium')) {
    // Has premium subscription on Stripe OR CHIP
}

// Check if subscribed on specific gateway
if ($user->subscribedViaGateway('premium', null, 'stripe')) {
    // Has premium subscription on Stripe
}

One-Time Charges

// Charge via default gateway
$payment = $user->chargeWithGateway(1000, 'pm_xxx');

// Charge via specific gateway
$payment = $user->chargeWithGateway(5000, 'pm_xxx', 'chip');

Checkout Sessions

$checkout = $user->checkoutWithGateway('stripe')
    ->price('price_monthly')
    ->price('price_addon', 2)
    ->successUrl(route('checkout.success'))
    ->cancelUrl(route('checkout.cancel'))
    ->metadata(['order_id' => $order->id])
    ->create();

Payment Methods

// Get payment methods from all gateways
$allMethods = $user->allGatewayPaymentMethods();

// Get payment methods from specific gateway
$stripeMethods = $user->gatewayPaymentMethods('stripe');

// Get default payment method for a gateway
$default = $user->defaultGatewayPaymentMethod('chip');

Invoices

// Get invoices from all gateways
$allInvoices = $user->allGatewayInvoices();

// Get invoices from specific gateway
$stripeInvoices = $user->gatewayInvoices('stripe');

Extending with Custom Gateways

use AIArmada\Cashier\Gateways\AbstractGateway;

class PayPalGateway extends AbstractGateway
{
    public function name(): string
    {
        return 'paypal';
    }
    
    // Implement required methods...
}

// Register in a service provider
Cashier::manager()->extend('paypal', function ($app) {
    return new PayPalGateway(config('cashier.gateways.paypal'));
});

License

MIT License. See LICENSE for details.

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

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

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-03-21