collab: Enable automatic tax calculation for all new subscriptions (#34720)
Release Notes: - N/A --------- Co-authored-by: Marshall Bowers <git@maxdeviant.com>
This commit is contained in:
parent
70bde54a2c
commit
4bdac8026c
3 changed files with 26 additions and 8 deletions
|
@ -11,8 +11,8 @@ use crate::Result;
|
|||
use crate::db::billing_subscription::SubscriptionKind;
|
||||
use crate::llm::AGENT_EXTENDED_TRIAL_FEATURE_FLAG;
|
||||
use crate::stripe_client::{
|
||||
RealStripeClient, StripeBillingAddressCollection, StripeCheckoutSessionMode,
|
||||
StripeCheckoutSessionPaymentMethodCollection, StripeClient,
|
||||
RealStripeClient, StripeAutomaticTax, StripeBillingAddressCollection,
|
||||
StripeCheckoutSessionMode, StripeCheckoutSessionPaymentMethodCollection, StripeClient,
|
||||
StripeCreateCheckoutSessionLineItems, StripeCreateCheckoutSessionParams,
|
||||
StripeCreateCheckoutSessionSubscriptionData, StripeCreateMeterEventParams,
|
||||
StripeCreateMeterEventPayload, StripeCreateSubscriptionItems, StripeCreateSubscriptionParams,
|
||||
|
@ -344,6 +344,7 @@ impl StripeBilling {
|
|||
price: Some(zed_free_price_id),
|
||||
quantity: Some(1),
|
||||
}],
|
||||
automatic_tax: Some(StripeAutomaticTax { enabled: true }),
|
||||
};
|
||||
|
||||
let subscription = self.client.create_subscription(params).await?;
|
||||
|
|
|
@ -73,6 +73,7 @@ pub enum StripeCancellationDetailsReason {
|
|||
pub struct StripeCreateSubscriptionParams {
|
||||
pub customer: StripeCustomerId,
|
||||
pub items: Vec<StripeCreateSubscriptionItems>,
|
||||
pub automatic_tax: Option<StripeAutomaticTax>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
|
@ -224,6 +225,11 @@ pub struct StripeTaxIdCollection {
|
|||
pub enabled: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct StripeAutomaticTax {
|
||||
pub enabled: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct StripeCheckoutSession {
|
||||
pub url: Option<String>,
|
||||
|
|
|
@ -10,16 +10,17 @@ use stripe::{
|
|||
CreateCheckoutSessionSubscriptionData, CreateCheckoutSessionSubscriptionDataTrialSettings,
|
||||
CreateCheckoutSessionSubscriptionDataTrialSettingsEndBehavior,
|
||||
CreateCheckoutSessionSubscriptionDataTrialSettingsEndBehaviorMissingPaymentMethod,
|
||||
CreateCustomer, Customer, CustomerId, ListCustomers, Price, PriceId, Recurring, Subscription,
|
||||
SubscriptionId, SubscriptionItem, SubscriptionItemId, UpdateCustomer, UpdateSubscriptionItems,
|
||||
UpdateSubscriptionTrialSettings, UpdateSubscriptionTrialSettingsEndBehavior,
|
||||
CreateCustomer, CreateSubscriptionAutomaticTax, Customer, CustomerId, ListCustomers, Price,
|
||||
PriceId, Recurring, Subscription, SubscriptionId, SubscriptionItem, SubscriptionItemId,
|
||||
UpdateCustomer, UpdateSubscriptionItems, UpdateSubscriptionTrialSettings,
|
||||
UpdateSubscriptionTrialSettingsEndBehavior,
|
||||
UpdateSubscriptionTrialSettingsEndBehaviorMissingPaymentMethod,
|
||||
};
|
||||
|
||||
use crate::stripe_client::{
|
||||
CreateCustomerParams, StripeBillingAddressCollection, StripeCancellationDetails,
|
||||
StripeCancellationDetailsReason, StripeCheckoutSession, StripeCheckoutSessionMode,
|
||||
StripeCheckoutSessionPaymentMethodCollection, StripeClient,
|
||||
CreateCustomerParams, StripeAutomaticTax, StripeBillingAddressCollection,
|
||||
StripeCancellationDetails, StripeCancellationDetailsReason, StripeCheckoutSession,
|
||||
StripeCheckoutSessionMode, StripeCheckoutSessionPaymentMethodCollection, StripeClient,
|
||||
StripeCreateCheckoutSessionLineItems, StripeCreateCheckoutSessionParams,
|
||||
StripeCreateCheckoutSessionSubscriptionData, StripeCreateMeterEventParams,
|
||||
StripeCreateSubscriptionParams, StripeCustomer, StripeCustomerId, StripeCustomerUpdate,
|
||||
|
@ -151,6 +152,7 @@ impl StripeClient for RealStripeClient {
|
|||
})
|
||||
.collect(),
|
||||
);
|
||||
create_subscription.automatic_tax = params.automatic_tax.map(Into::into);
|
||||
|
||||
let subscription = Subscription::create(&self.client, create_subscription).await?;
|
||||
|
||||
|
@ -366,6 +368,15 @@ impl From<SubscriptionItem> for StripeSubscriptionItem {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<StripeAutomaticTax> for CreateSubscriptionAutomaticTax {
|
||||
fn from(value: StripeAutomaticTax) -> Self {
|
||||
Self {
|
||||
enabled: value.enabled,
|
||||
liability: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<StripeSubscriptionTrialSettings> for UpdateSubscriptionTrialSettings {
|
||||
fn from(value: StripeSubscriptionTrialSettings) -> Self {
|
||||
Self {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue