-
Notifications
You must be signed in to change notification settings - Fork 704
[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
Conversation
… 2025-03-31.basil
… enhancing flexibility for expansion and filtering.
…p for improved clarity and performance; add static method to get Stripe SDK client in SubscriptionBuilder.php.
…ow accepts parameters for enhanced flexibility in retrieving Stripe line items.
… compatibility adjustments.
…action; include unit tests for new functionality
Thank you. I'll review this one when I find some time. |
Is there a rough target release date for Cashier 16/Basil support? |
Add meter_event_name storage for metered items
- Add new expansion paths so invoice responses include full tax_rate objects - Simplify tax rate lookup to return the expanded object and eliminate extra Stripe API calls
- Introduce nullable `meter_id` column in `subscription_items` (lines 12–17 in migration) - Cast `meter_id` and `meter_event_name` as strings on the model for direct access - Cache meter ID and event name on subscription swaps and price additions - Enhance usage reporting to read from cache or fetch-and-store meter details on first call - Add tests to ensure `meter_id` and `meter_event_name` persist after creation
- uniqid can collide in high‑load situations. Laravel’s Str::uuid() provides truly unique identifiers.
I feel like its been draft for too long. I have done all I personally can on it so any further suggestions I will implement but apart from that I feel like it would be ace to get the ball rolling on this being merged! @driesvints |
- Add guard in `SubscriptionBuilder::quantity` to throw `InvalidArgumentException` if no prices are provided - Introduce unit test to verify `quantity()` without any prices raises the expected exception
Signed-off-by: Mior Muhammad Zaki <[email protected]>
Signed-off-by: Mior Muhammad Zaki <[email protected]>
Signed-off-by: Mior Muhammad Zaki <[email protected]>
Signed-off-by: Mior Muhammad Zaki <[email protected]>
Signed-off-by: Mior Muhammad Zaki <[email protected]>
Signed-off-by: Mior Muhammad Zaki <[email protected]>
Signed-off-by: Mior Muhammad Zaki <[email protected]>
Signed-off-by: Mior Muhammad Zaki <[email protected]>
Signed-off-by: Mior Muhammad Zaki <[email protected]>
@crynobone could you do a bullet point list upgrade guide of what users the steps users will need to take to upgrade? |
@crynobone @taylorotwell @driesvints Whats currently holding this back? Keen to see it merged :) |
isset($parameters['subscription_details']) || | ||
isset($parameters['schedule']) || | ||
isset($parameters['schedule_details']) || | ||
isset($parameters['invoice_items']); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this supposed to be &&
?
@Diddyy merged, but I have no idea how to update the docs for this, and also need an upgrade guide. |
Thanks @taylorotwell for merging. One other thing to flag perhaps before this gets a tagged release. It seems that as part of the basil release, Stripe are moving towards a new "flexible" billing mode. https://docs.stripe.com/billing/subscriptions/billing-mode While it's possible to pass in the
I'm wondering if it's worth having a config option and/or a helper method on the SubscriptionBuilder i.e 'cashier' => [
'default_billing_mode' => env('CASHIER_DEFAULT_BILLING_MODE', 'classic'),
], or class SubscriptionBuilder
{
/**
* The billing mode for the subscription.
*
* @var array|null
*/
protected $billingMode = null;
/**
* Set the billing mode for the subscription.
*
* @param string $type
* @return $this
*/
public function withBillingMode(string $type = 'flexible')
{
$this->billingMode = ['type' => $type];
return $this;
}
/**
* Get the default billing mode from config.
*
* @return string
*/
protected function getDefaultBillingMode(): string
{
return config('cashier.default_billing_mode', 'classic');
}
/**
* Get the effective billing mode for this subscription.
*
* @return string
*/
protected function getEffectiveBillingMode(): string
{
if ($this->billingMode) {
return $this->billingMode['type'];
}
return $this->getDefaultBillingMode();
}
/**
* Get the billing mode for the Stripe payload.
*
* @return array|null
*/
protected function getBillingModeForPayload()
{
$mode = $this->getEffectiveBillingMode();
// Only include billing_mode if it's not classic (Stripe's default)
if ($mode !== 'classic') {
return ['type' => $mode];
}
return null;
}
What do you think? @taylorotwell @driesvints @crynobone |
@crynobone is this something you're able to help with? :) |
@Diddyy I'm going through the upgrading guide, and we did face some issues, especially dealing with ![]() ![]() https://docs.stripe.com/api-v2-overview?api-version=2025-07-30.preview&rds=1#limitations We need to be able to list all the required steps to upgrade to the new version. |
Furthermore, new metered billings is not on the PR description. |
Thanks for checking this @crynobone 🙌 I won’t be able to put together the full upgrade guide myself, but I agree it’s needed to document the steps (API version upgrade, sandbox key requirements, metered billing, etc.). Maybe it makes sense to open a follow-up issue in the relevant repo dedicated to the upgrade guide so we can track that separately? |
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 version2025-03-31.basil
), as highlighted in the Cashier source code:Summary of Changes
Invoice Line Items: Added helpers to extract pricing data using Stripe’s new
price_details
andinline_price_data
structures introduced in Basil:Unit Amount Handling: Retrieve unit amounts and support inline price data:
Tax Behavior Retrieval: Access the
tax_behavior
on invoice line items: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 retrievalunitAmount
handling for bothprice_details
andinline_price_data
taxBehavior
methodAll 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!