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
WebhookReceivedandWebhookHandledevents, and keeping subscriptions and customers in sync, like PHP Cashier’sWebhookController.
Macros§
- billable
- Implement
BillableColumnsandBillablefor a model.
Structs§
- Billing
Columns - The billable columns of a model, as
BillableColumns::billing_columnsreads them. - Billing
Columns Mut - 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\Cashierclass. - Cashier
Config - Cashier’s settings.
- Cashier
Service Provider - Registers Cashier’s configuration, migrations, views, routes (the webhook and the payment
page), and the
cashier:webhookcommand for the billable modelB. - Checkout
- A Stripe Checkout session.
- Checkout
Builder - Builds a Checkout session, with coupons, promotion codes, and taxes.
- Confirm
Payment - Asks a customer to confirm a payment that needs extra verification, such as 3D Secure, on Cashier’s payment page.
- Coupon
- A Stripe coupon.
- Customer
Already Created - The billable model is already a Stripe customer.
- Customer
Balance Transaction - A transaction of a customer’s balance. It serializes as the Stripe transaction itself.
- Discount
- A discount applied to a subscription or invoice.
- Incomplete
Payment - A payment that needs the customer to act, such as to confirm it with 3D Secure.
- Invalid
Argument - An argument that Cashier can’t use, the counterpart of PHP’s
InvalidArgumentExceptionandLogicException. - Invalid
Customer - The billable model isn’t a Stripe customer yet.
- Invalid
Customer Balance Transaction - A customer balance transaction belongs to another customer.
- Invalid
Invoice - An invoice belongs to another customer.
- Invalid
Payment Method - A payment method belongs to another customer.
- Invoice
- A Stripe invoice of the billable model’s customer.
- Invoice
Cursor - Where a page of invoices starts, encoded like Laravel’s cursors.
- Invoice
Cursor Paginator - A page of invoices with cursors for the pages before and after it. It serializes like
Laravel’s
CursorPaginator. - Invoice
Line Item - A line of an invoice. It serializes as the Stripe line item itself.
- Invoice
Payment - A payment of an invoice. It serializes as the Stripe invoice payment itself.
- Invoice
Render Options - The options PHP Cashier passes to its invoice renderer:
config('cashier.invoices.options'). - Item
Changes - A change to a subscription item, with options such as its proration behavior.
- Line
Items - 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]), andcheckout([['price' => 'price_a', 'quantity' => 2]]). - Payment
- A Stripe PaymentIntent.
- Payment
Method - 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']), andswap(['price_a' => ['quantity' => 5]]). - Print
PdfInvoice Renderer - Renders the
cashier::invoiceview with printpdf, a pure-Rust HTML and CSS to PDF engine, the counterpart of PHP’sDompdfInvoiceRenderer. - Promotion
Code - A Stripe promotion code.
- Signature
Verification Error - A webhook request whose
Stripe-Signatureheader doesn’t match its payload. - Stripe
Error - An error that the Stripe API returned.
- Subscription
- A customer’s subscription, stored in the
subscriptionstable. - Subscription
Builder - Builds a new subscription for a billable model.
- Subscription
Changes - A change to a subscription, with options such as its proration behavior.
- Subscription
Item - One price of a subscription, stored in the
subscription_itemstable. - Subscription
Status - The statuses Stripe gives subscriptions.
- Subscription
Update Failure - 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.
- Webhook
Command - Create the Stripe webhook to interact with Cashier.
Enums§
- Anchor
- Where a billing cycle is anchored: now, or at a time.
- Default
Payment Method - The customer’s default payment method.
- Subscription
Target - 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-php21.3) pins. - VERSION
- The version of PHP Cashier this package follows.
Traits§
- Billable
- A model that is a Stripe customer: PHP Cashier’s
Billabletrait. - Billable
Columns - How a billable model’s fields map to the columns Cashier uses.
- Billable
Text - Text that
billable!reads a name or email address from: aString, anOption<String>, or a&str. - Invoice
Renderer - Renders invoices as PDFs, PHP Cashier’s
InvoiceRenderercontract.
Functions§
- format_
english - Format an amount the way ICU’s
enlocale 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
SyncCustomerDetailsjob. Register it withCashierServiceProvider::sync_customer_details, or listen with it yourself. - verify_
redirect_ url - Return
403unlessredirectis a relative URL or anhttp/httpsURL onhost, like PHP Cashier’sVerifyRedirectUrlmiddleware.
Type Aliases§
- Formatter
- A custom money formatter: the amount in the currency’s smallest unit, the currency, and the locale.
- Render
Future - A future returned by an
InvoiceRenderer.