@@ -10,6 +10,7 @@ export const checkout = (options: PolarOptions) =>
10
10
method : "GET" ,
11
11
query : z . object ( {
12
12
products : z . union ( [ z . array ( z . string ( ) ) , z . string ( ) ] ) ,
13
+ customerEmail : z . string ( ) . email ( ) . optional ( ) ,
13
14
} ) ,
14
15
} ,
15
16
async ( ctx ) => {
@@ -30,6 +31,7 @@ export const checkout = (options: PolarOptions) =>
30
31
31
32
try {
32
33
const checkout = await options . client . checkouts . create ( {
34
+ customerEmail : ctx . query . customerEmail ?? session ?. user . email ,
33
35
customerExternalId : session ?. user . id ,
34
36
products : Array . isArray ( products ) ? products : [ products ] ,
35
37
successUrl : options . checkout . successUrl
@@ -60,8 +62,12 @@ export const checkoutWithSlug = (options: PolarOptions) =>
60
62
params : z . object ( {
61
63
slug : z . string ( ) ,
62
64
} ) ,
65
+ query : z . object ( {
66
+ customerEmail : z . string ( ) . email ( ) . optional ( ) ,
67
+ } ) ,
63
68
} ,
64
69
async ( ctx ) => {
70
+
65
71
if ( ! options . checkout ?. enabled ) {
66
72
throw new APIError ( "BAD_REQUEST" , {
67
73
message : "Checkout is not enabled" ,
@@ -92,6 +98,7 @@ export const checkoutWithSlug = (options: PolarOptions) =>
92
98
93
99
try {
94
100
const checkout = await options . client . checkouts . create ( {
101
+ customerEmail : ctx . query . customerEmail ?? session ?. user . email ,
95
102
customerExternalId : session ?. user . id ,
96
103
products : [ productId ] ,
97
104
successUrl : options . checkout . successUrl
0 commit comments