Convert Figma logo to code with AI

laravel logocashier-stripe

Laravel Cashier provides an expressive, fluent interface to Stripe's subscription billing services.

2,372
669
2,372
1

Top Related Projects

PHP library for the Stripe API.

Quick Overview

Laravel Cashier provides an expressive, fluent interface to Stripe's subscription billing services. It handles almost all of the boilerplate subscription billing code you are dreading writing. Cashier can handle coupons, swapping subscription, subscription "quantities", cancellation grace periods, and even generate invoice PDFs.

Pros

  • Seamless integration with Laravel and Stripe
  • Handles complex billing scenarios with ease
  • Provides a clean, expressive API for subscription management
  • Supports both single and multi-plan subscriptions

Cons

  • Limited to Stripe payment gateway
  • Requires a good understanding of Laravel and Stripe concepts
  • May be overkill for simple payment processing needs
  • Documentation could be more comprehensive for advanced use cases

Code Examples

  1. Creating a subscription:
$user->newSubscription('default', 'price_monthly')
    ->create($paymentMethod);
  1. Checking subscription status:
if ($user->subscribed('default')) {
    // User has an active subscription...
}
  1. Cancelling a subscription:
$user->subscription('default')->cancel();
  1. Applying a coupon:
$user->newSubscription('default', 'price_monthly')
    ->withCoupon('code')
    ->create($paymentMethod);

Getting Started

  1. Install Cashier via Composer:
composer require laravel/cashier
  1. Add the Billable trait to your User model:
use Laravel\Cashier\Billable;

class User extends Authenticatable
{
    use Billable;
}
  1. Publish the migration:
php artisan vendor:publish --tag="cashier-migrations"
  1. Run the migration:
php artisan migrate
  1. Set your Stripe API keys in your .env file:
STRIPE_KEY=your-stripe-key
STRIPE_SECRET=your-stripe-secret

Now you're ready to start using Cashier in your Laravel application!

Competitor Comparisons

PHP library for the Stripe API.

Pros of stripe-php

  • More flexible and can be used with any PHP project, not limited to Laravel
  • Provides direct access to all Stripe API features without abstraction
  • Regularly updated to support the latest Stripe API changes

Cons of stripe-php

  • Requires more manual setup and configuration for integration
  • Less opinionated, which may lead to inconsistent implementation across projects
  • Lacks Laravel-specific features and optimizations

Code Comparison

stripe-php:

\Stripe\Stripe::setApiKey('sk_test_...');
$customer = \Stripe\Customer::create([
  'email' => 'customer@example.com',
  'source' => 'tok_visa'
]);

cashier-stripe:

use Laravel\Cashier\Billable;

class User extends Model
{
    use Billable;
}

$user->newSubscription('default', 'price_monthly')->create('pm_card_visa');

Summary

stripe-php offers more flexibility and direct access to Stripe's API, making it suitable for various PHP projects. However, it requires more manual setup and lacks Laravel-specific optimizations. cashier-stripe, on the other hand, provides a more streamlined experience for Laravel users with built-in features and conventions, but is limited to the Laravel ecosystem and may not offer as much flexibility for complex use cases.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Logo Laravel Cashier Stripe

Build Status Total Downloads Latest Stable Version License

Introduction

Laravel Cashier provides an expressive, fluent interface to Stripe's subscription billing services. It handles almost all of the boilerplate subscription billing code you are dreading writing. In addition to basic subscription management, Cashier can handle coupons, swapping subscription, subscription "quantities", cancellation grace periods, and even generate invoice PDFs.

Official Documentation

Documentation for Cashier can be found on the Laravel website.

Contributing

Thank you for considering contributing to Cashier! You can read the contribution guide here.

Code of Conduct

In order to ensure that the Laravel community is welcoming to all, please review and abide by the Code of Conduct.

Security Vulnerabilities

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

License

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