Skip to content

Commit 4bda196

Browse files
committed
tax enebled
1 parent 130f271 commit 4bda196

2 files changed

Lines changed: 22 additions & 2 deletions

File tree

config/tierMap.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
// config/tierMap.js
23
// Map Ghost Product IDs to Stripe Price IDs
34
export default {
@@ -9,4 +10,5 @@ export default {
910
monthly: 'price_1Qyyyyyy_monthly',
1011
yearly: 'price_1Qyyyyyy_yearly'
1112
}
12-
};
13+
};
14+

services/stripeService.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ import Stripe from 'stripe';
22
import env from '../config/env.js';
33

44
const stripe = new Stripe(env.STRIPE_SECRET_KEY, {
5-
apiVersion: '2025-08-27.basil', // This is where the API version is set
5+
apiVersion: '2025-08-27.basil',
66
});
77

88
export async function createCheckoutSession(priceId, name, email, productId, plan) {
9+
// 1. Create a new Customer with name and email
910
const customer = await stripe.customers.create({
1011
name,
1112
email,
@@ -15,6 +16,7 @@ export async function createCheckoutSession(priceId, name, email, productId, pla
1516
}
1617
});
1718

19+
// 2. Create the Checkout Session with automatic_tax enabled and best practices
1820
return stripe.checkout.sessions.create({
1921
mode: 'subscription',
2022
payment_method_types: ['card', 'ideal'],
@@ -26,6 +28,22 @@ export async function createCheckoutSession(priceId, name, email, productId, pla
2628
productId,
2729
plan,
2830
name
31+
},
32+
33+
// 💡 REQUIRED: Enable automatic tax calculation (Stripe Tax)
34+
automatic_tax: {
35+
enabled: true,
36+
},
37+
38+
// collected in Checkout for more accurate tax calculation.
39+
customer_update: {
40+
address: 'auto',
41+
name: 'auto'
42+
},
43+
44+
// for B2B tax compliance and exemptions.
45+
tax_id_collection: {
46+
enabled: true,
2947
}
3048
});
3149
}

0 commit comments

Comments
 (0)