Skip to content

[16.x] Stripe Basil API Support #1762

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 9 commits into
base: 16.x
Choose a base branch
from
Draft

[16.x] Stripe Basil API Support #1762

wants to merge 9 commits into from

Conversation

Diddyy
Copy link

@Diddyy Diddyy commented Jun 6, 2025

This PR targets the 16.x branch in line with Laravel’s support policy. It finalizes Cashier’s compatibility with Stripe’s Basil API (API version 2025-03-31.basil), as highlighted in the Cashier source code:

// src/Cashier.php
const STRIPE_VERSION = '2025-03-31.basil';

Summary of Changes

Invoice Line Items: Added helpers to extract pricing data using Stripe’s new price_details and inline_price_data structures introduced in Basil:

public function priceId()
{
    // Handle the new pricing structure (Basil release)
    if (isset($this->item->pricing) && $this->item->pricing->type === 'price_details') {
        return $this->item->pricing->price_details->price ?? null;
    }

    return null;
}

Unit Amount Handling: Retrieve unit amounts and support inline price data:

public function unitAmount()
{
    // Handle the new pricing structure (Basil release)
    if (isset($this->item->pricing)) {
        if (isset($this->item->pricing->unit_amount_decimal)) {
            return (int) $this->item->pricing->unit_amount_decimal;
        }
        if ($this->item->pricing->type === 'inline_price_data' &&
            isset($this->item->pricing->inline_price_data->unit_amount)) {
            return (int) $this->item->pricing->inline_price_data->unit_amount;
        }
    }

    return null;
}

Tax Behavior Retrieval: Access the tax_behavior on invoice line items:

public function taxBehavior()
{
    $price = $this->price();
    return $price ? ($price->tax_behavior ?? null) : null;
}

Benefits to Users

Keeps Cashier aligned with Stripe’s latest Basil API, as requested by Taylor April tweet inviting contributions.

Testing

Added PHPUnit tests covering the new invoice line item helpers:

priceId and price retrieval
unitAmount handling for both price_details and inline_price_data
taxBehavior method

All test suites pass locally. Please refer to the CI checks for confirmation.

Motivation

Taylor mentioned that the team “would love some assistance making Cashier compatible with Stripe's latest API version (Basil)” — this PR answers that call. It updates core invoice item logic and tests to ensure developers can rely on Cashier when using the latest Stripe features.

This is my first significant open source contribution attempt so apologies if it isn't quite up to scratch, I welcome any criticism or commits to improve it!

@driesvints driesvints self-assigned this Jun 9, 2025
@driesvints driesvints marked this pull request as draft June 9, 2025 08:02
@driesvints
Copy link
Member

Thank you. I'll review this one when I find some time.

@driesvints driesvints changed the base branch from 15.x to 16.x June 9, 2025 08:02
@driesvints driesvints changed the base branch from 16.x to 15.x June 9, 2025 08:02
@driesvints driesvints changed the base branch from 15.x to 16.x June 9, 2025 08:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants