承接 alturacode/billing-laravel 相关项目开发

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

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

alturacode/billing-laravel

最新稳定版本:v0.6.2

Composer 安装命令:

composer require alturacode/billing-laravel

包简介

AlturaCode Billing for Laravel

README 文档

README

Altura Code Billing for Laravel gives you a clean way to manage subscriptions in your Laravel applications.

This package is still under active development.

The Motivation

We created this package because we needed to support multiple billing providers (Stripe & PayPal) in one of our projects. Laravel Cashier, while great, only supports either Stripe or Paddle.

This package acts as a nice wrapper for Altura Code Billing, giving us a nice API to manage subscriptions in our Laravel apps.

We went a little further and made purchasable products as part of the core package; this allows you to easily define products, prices and features right from a config file. You can optionally sync with billing providers like Stripe to get started quickly.

TL;DR

use AlturaCode\Billing\Laravel\HasBilling;
use AlturaCode\Billing\Laravel\Billable;

class User extends Model implements Billable {
    use HasBilling;
}

// Create a subscription
$result = $user->newSubscription('default')
    ->withPlan('plan_id', 'month', 1, 'usd') // or withPlanPriceId('product_price_id')
    ->withTrialDays(14)
    ->create();

if ($result->requiresAction()) {
    return $result->redirect();
}

$subscription = $result->subscription; // AlturaCode\Billing\Laravel\Subscription

Requirements

  • PHP 8.4+
  • Laravel 12.x

Installation

Install the package

composer require alturacode/billing-laravel

Make your billable model implement AlturaCode\Billing\Laravel\Billable and use the AlturaCode\Billing\Laravel\HasBilling trait:

use AlturaCode\Billing\Laravel\HasBilling;
use AlturaCode\Billing\Laravel\Billable;

class User extends Model implements Billable
{
    use HasBilling;
}

Publish the config file and migrations

php artisan vendor:publish --provider="AlturaCode\Billing\Laravel\BillingServiceProvider"

Quick start

Create a subscription for a user:

// In a controller action
$result = $request->user()->newSubscription('default')
    ->withPlanPriceId('price_basic_monthly', quantity: 1)
    ->withTrialDays(14)
    ->create();

if ($result->requiresAction()) {
    return $result->redirect();
}

$subscription = $result->subscription; // AlturaCode\Billing\Laravel\Subscription

Check a user’s subscription status:

if ($user->subscribed()) {
    // has an active default subscription
}

$sub = $user->subscription('default'); // Eloquent model or null

Check if a user can use a feature:

$user->features()->canUse('projects', 3); // boolean

Query subscriptions:

use AlturaCode\Billing\Laravel\Subscription;

$active = Subscription::query()
    ->provider('sync')
    ->active()
    ->get();

Stripe

Install the Stripe package:

composer require alturacode/billing-stripe

Register the billing provider in config/billing.php:

'providers' => [
    // ...
    'stripe' => AlturaCode\Billing\Stripe\StripeBillingProvider::class,
]

Use Stripe for subscriptions:

$user->newSubscription('default')
    ->withPlanPriceId('price_basic_monthly')
    ->withProvider('stripe')
    ->create([
       'success_url' => 'https://example.com/success',
        'cancel_url' => 'https://example.com/cancel',
   ]);

License

MIT License. See LICENSE for details.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-12-08