Skip to content

Commit c3cd95c

Browse files
committed
add first and last name to stripe membership checkout
1 parent a5ffe4b commit c3cd95c

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/api/functions/stripe.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export type StripeCheckoutSessionCreateParams = {
1818
items: { price: string; quantity: number }[];
1919
initiator: string;
2020
allowPromotionCodes: boolean;
21+
customFields?: Stripe.Checkout.SessionCreateParams.CustomField[];
2122
};
2223

2324
/**
@@ -73,6 +74,7 @@ export const createCheckoutSession = async ({
7374
items,
7475
initiator,
7576
allowPromotionCodes,
77+
customFields,
7678
}: StripeCheckoutSessionCreateParams): Promise<string> => {
7779
const stripe = new Stripe(stripeApiKey);
7880
const payload: Stripe.Checkout.SessionCreateParams = {
@@ -89,6 +91,7 @@ export const createCheckoutSession = async ({
8991
initiator,
9092
},
9193
allow_promotion_codes: allowPromotionCodes,
94+
custom_fields: customFields,
9295
};
9396
const session = await stripe.checkout.sessions.create(payload);
9497
if (!session.url) {

src/api/routes/membership.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,24 @@ const membershipPlugin: FastifyPluginAsync = async (fastify, _options) => {
173173
quantity: 1,
174174
},
175175
],
176-
176+
customFields: [
177+
{
178+
key: "firstName",
179+
label: {
180+
type: "custom",
181+
custom: "Student First Name",
182+
},
183+
type: "text",
184+
},
185+
{
186+
key: "lastName",
187+
label: {
188+
type: "custom",
189+
custom: "Student Last Name",
190+
},
191+
type: "text",
192+
},
193+
],
177194
initiator: "purchase-membership",
178195
allowPromotionCodes: true,
179196
}),

0 commit comments

Comments
 (0)