Skip to content

Commit 0b13478

Browse files
authored
allow coupon codes for stripe checkout (#94)
1 parent 7706e00 commit 0b13478

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

src/api/functions/stripe.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export type StripeCheckoutSessionCreateParams = {
1717
stripeApiKey: string;
1818
items: { price: string; quantity: number }[];
1919
initiator: string;
20+
allowPromotionCodes: boolean;
2021
};
2122

2223
/**
@@ -71,6 +72,7 @@ export const createCheckoutSession = async ({
7172
customerEmail,
7273
items,
7374
initiator,
75+
allowPromotionCodes,
7476
}: StripeCheckoutSessionCreateParams): Promise<string> => {
7577
const stripe = new Stripe(stripeApiKey);
7678
const payload: Stripe.Checkout.SessionCreateParams = {
@@ -86,6 +88,7 @@ export const createCheckoutSession = async ({
8688
metadata: {
8789
initiator,
8890
},
91+
allow_promotion_codes: allowPromotionCodes,
8992
};
9093
const session = await stripe.checkout.sessions.create(payload);
9194
if (!session.url) {

src/api/routes/membership.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ const membershipPlugin: FastifyPluginAsync = async (fastify, _options) => {
139139
{ price: fastify.environmentConfig.PaidMemberPriceId, quantity: 1 },
140140
],
141141
initiator: "purchase-membership",
142+
allowPromotionCodes: true,
142143
}),
143144
);
144145
});

0 commit comments

Comments
 (0)