Skip to main content

Crate laravel_cashier

Crate laravel_cashier 

Source
Expand description

§Laravel Cashier (Stripe) for Laravel Rust

A port of Laravel Cashier to Laravel Rust: subscriptions, payment methods, Stripe Checkout, single charges, invoices, the billing portal, and webhook handling for Stripe.

Register the service provider with your billable model, add the billable columns to the model, and implement Billable with the billable! macro:

ⓘ
// src/app.rs
Application::configure()
    .with_providers(|providers| {
        providers.add(laravel_cashier::CashierServiceProvider::<User>::new());
    })

// src/models/user.rs
#[model]
pub struct User {
    pub id: i64,
    pub name: String,
    pub email: String,
    pub stripe_id: Option<String>,
    pub pm_type: Option<String>,
    pub pm_last_four: Option<String>,
    pub trial_ends_at: Option<Timestamp>,
    // ...
}

laravel_cashier::billable!(User);

This is a community port by Rivervo. It isn’t an official Laravel package.

Re-exports§

pub use crate::stripe::RequestOptions;
pub use crate::stripe::Stripe;
pub use crate::stripe::with_network_retries;
pub use crate::webhook::WebhookHandled;
pub use crate::webhook::WebhookHandler;
pub use crate::webhook::WebhookReceived;
pub use crate::webhook::handle_webhook;

Modules§

stripe
A small client for Stripe’s REST API, sent through Laravel’s HTTP client.
webhook
Stripe webhooks: signature verification, the WebhookReceived and WebhookHandled events, and keeping subscriptions and customers in sync, like PHP Cashier’s WebhookController.

Macros§

billable
Implement BillableColumns and Billable for a model.

Structs§

BillingColumns
The billable columns of a model, as BillableColumns::billing_columns reads them.
BillingColumnsMut
The billable columns of a model, for Cashier to change in memory after writing them.
Cashier
Cashier’s static helpers, the counterpart of PHP’s Laravel\Cashier\Cashier class.
CashierConfig
Cashier’s settings.
CashierServiceProvider
Registers Cashier’s configuration, migrations, views, routes (the webhook and the payment page), and the cashier:webhook command for the billable model B.
Checkout
A Stripe Checkout session.
CheckoutBuilder
Builds a Checkout session, with coupons, promotion codes, and taxes.
ConfirmPayment
Asks a customer to confirm a payment that needs extra verification, such as 3D Secure, on Cashier’s payment page.
Coupon
A Stripe coupon.
CustomerAlreadyCreated
The billable model is already a Stripe customer.
CustomerBalanceTransaction
A transaction of a customer’s balance. It serializes as the Stripe transaction itself.
Discount
A discount applied to a subscription or invoice.
IncompletePayment
A payment that needs the customer to act, such as to confirm it with 3D Secure.
InvalidArgument
An argument that Cashier can’t use, the counterpart of PHP’s InvalidArgumentException and LogicException.
InvalidCustomer
The billable model isn’t a Stripe customer yet.
InvalidCustomerBalanceTransaction
A customer balance transaction belongs to another customer.
InvalidInvoice
An invoice belongs to another customer.
InvalidPaymentMethod
A payment method belongs to another customer.
Invoice
A Stripe invoice of the billable model’s customer.
InvoiceCursor
Where a page of invoices starts, encoded like Laravel’s cursors.
InvoiceCursorPaginator
A page of invoices with cursors for the pages before and after it. It serializes like Laravel’s CursorPaginator.
InvoiceLineItem
A line of an invoice. It serializes as the Stripe line item itself.
InvoicePayment
A payment of an invoice. It serializes as the Stripe invoice payment itself.
InvoiceRenderOptions
The options PHP Cashier passes to its invoice renderer: config('cashier.invoices.options').
ItemChanges
A change to a subscription item, with options such as its proration behavior.
LineItems
Line items for a Checkout session: price IDs, price IDs with quantities, or full line items, like PHP’s checkout('price_a'), checkout(['price_a' => 2]), and checkout([['price' => 'price_a', 'quantity' => 2]]).
Payment
A Stripe PaymentIntent.
PaymentMethod
A Stripe PaymentMethod attached to the billable model’s customer.
Prices
Prices to swap a subscription to: price IDs, or price IDs with item options, like PHP’s swap('price_a'), swap(['price_a', 'price_b']), and swap(['price_a' => ['quantity' => 5]]).
PrintPdfInvoiceRenderer
Renders the cashier::invoice view with printpdf, a pure-Rust HTML and CSS to PDF engine, the counterpart of PHP’s DompdfInvoiceRenderer.
PromotionCode
A Stripe promotion code.
SignatureVerificationError
A webhook request whose Stripe-Signature header doesn’t match its payload.
StripeError
An error that the Stripe API returned.
Subscription
A customer’s subscription, stored in the subscriptions table.
SubscriptionBuilder
Builds a new subscription for a billable model.
SubscriptionChanges
A change to a subscription, with options such as its proration behavior.
SubscriptionItem
One price of a subscription, stored in the subscription_items table.
SubscriptionStatus
The statuses Stripe gives subscriptions.
SubscriptionUpdateFailure
A subscription can’t be updated as asked.
Tax
One tax amount of an invoice, with its tax rate when Stripe Tax didn’t calculate it.
WebhookCommand
Create the Stripe webhook to interact with Cashier.

Enums§

Anchor
Where a billing cycle is anchored: now, or at a time.
DefaultPaymentMethod
The customer’s default payment method.
SubscriptionTarget
The subscriptions a coupon or promotion code applies to.

Constants§

DEFAULT_API_BASE
The Stripe API’s base URL, which Stripe’s own SDKs use by default.
STRIPE_VERSION
The Stripe API version every request sends, the version that PHP Cashier 16.11’s newest supported Stripe SDK (stripe/stripe-php 21.3) pins.
VERSION
The version of PHP Cashier this package follows.

Traits§

Billable
A model that is a Stripe customer: PHP Cashier’s Billable trait.
BillableColumns
How a billable model’s fields map to the columns Cashier uses.
BillableText
Text that billable! reads a name or email address from: a String, an Option<String>, or a &str.
InvoiceRenderer
Renders invoices as PDFs, PHP Cashier’s InvoiceRenderer contract.

Functions§

format_english
Format an amount the way ICU’s en locale formats currencies.
format_locale
Format an amount in a locale with CLDR data, like PHP’s NumberFormatter::CURRENCY.
show_payment
GET /stripe/payment/{id}: the page where a customer confirms a payment that needs extra verification, such as 3D Secure, with Stripe.js.
sync_customer_details
Sync an updated billable model’s details to its Stripe customer, the counterpart of PHP’s SyncCustomerDetails job. Register it with CashierServiceProvider::sync_customer_details, or listen with it yourself.
verify_redirect_url
Return 403 unless redirect is a relative URL or an http/https URL on host, like PHP Cashier’s VerifyRedirectUrl middleware.

Type Aliases§

Formatter
A custom money formatter: the amount in the currency’s smallest unit, the currency, and the locale.
RenderFuture
A future returned by an InvoiceRenderer.