✨ add taxes automatic
This commit is contained in:
parent
86fee9a9a0
commit
bba73644f1
@ -16,45 +16,40 @@ export default class StripeService {
|
||||
}
|
||||
|
||||
public async createCheckoutSession(subscription: Subscription, frequency: EPaymentFrequency) {
|
||||
let priceId = this.variables.STRIPE_UNLIMITED_SUBSCRIPTION_PRICE_ID;
|
||||
if(subscription.type === "STANDARD") {
|
||||
if(frequency === EPaymentFrequency.Yearly) {
|
||||
priceId = this.variables.STRIPE_STANDARD_ANNUAL_SUBSCRIPTION_PRICE_ID;
|
||||
}
|
||||
else{
|
||||
priceId = this.variables.STRIPE_STANDARD_SUBSCRIPTION_PRICE_ID;
|
||||
}
|
||||
let priceId = this.variables.STRIPE_UNLIMITED_SUBSCRIPTION_PRICE_ID;
|
||||
if (subscription.type === "STANDARD") {
|
||||
if (frequency === EPaymentFrequency.Yearly) {
|
||||
priceId = this.variables.STRIPE_STANDARD_ANNUAL_SUBSCRIPTION_PRICE_ID;
|
||||
} else {
|
||||
priceId = this.variables.STRIPE_STANDARD_SUBSCRIPTION_PRICE_ID;
|
||||
}
|
||||
else if(subscription.type === "UNLIMITED") {
|
||||
if(frequency === EPaymentFrequency.Yearly) {
|
||||
priceId = this.variables.STRIPE_UNLIMITED_ANNUAL_SUBSCRIPTION_PRICE_ID;
|
||||
}
|
||||
else{
|
||||
priceId = this.variables.STRIPE_UNLIMITED_SUBSCRIPTION_PRICE_ID;
|
||||
}
|
||||
} else if (subscription.type === "UNLIMITED") {
|
||||
if (frequency === EPaymentFrequency.Yearly) {
|
||||
priceId = this.variables.STRIPE_UNLIMITED_ANNUAL_SUBSCRIPTION_PRICE_ID;
|
||||
} else {
|
||||
priceId = this.variables.STRIPE_UNLIMITED_SUBSCRIPTION_PRICE_ID;
|
||||
}
|
||||
}
|
||||
|
||||
return this.client.checkout.sessions.create({
|
||||
mode: "subscription",
|
||||
payment_method_types: ["card"],
|
||||
billing_address_collection: "auto",
|
||||
line_items: [
|
||||
{
|
||||
price: priceId,
|
||||
quantity: subscription.type === "STANDARD" ? subscription.nb_seats : 1,
|
||||
},
|
||||
],
|
||||
success_url: this.variables.APP_HOST + "/subscription/success",
|
||||
cancel_url: this.variables.APP_HOST + "/subscription/error",
|
||||
metadata: {
|
||||
subscription: JSON.stringify(subscription),
|
||||
env: this.variables.ENV,
|
||||
return this.client.checkout.sessions.create({
|
||||
mode: "subscription",
|
||||
payment_method_types: ["card"],
|
||||
billing_address_collection: "auto",
|
||||
line_items: [
|
||||
{
|
||||
price: priceId,
|
||||
quantity: subscription.type === "STANDARD" ? subscription.nb_seats : 1,
|
||||
},
|
||||
allow_promotion_codes: true,
|
||||
});
|
||||
|
||||
|
||||
|
||||
],
|
||||
success_url: this.variables.APP_HOST + "/subscription/success",
|
||||
cancel_url: this.variables.APP_HOST + "/subscription/error",
|
||||
metadata: {
|
||||
subscription: JSON.stringify(subscription),
|
||||
env: this.variables.ENV,
|
||||
},
|
||||
allow_promotion_codes: true,
|
||||
automatic_tax: { enabled: true },
|
||||
});
|
||||
}
|
||||
|
||||
public async getStripeSubscriptionByUid(subscriptionId: string) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user