Skip to content

Commit 7d3c9f4

Browse files
committed
Add support for optional checkout country API overrides
1 parent 43edc74 commit 7d3c9f4

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

api/src/functions/redirect-to-checkout.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ export const handler = catchErrors(async (event) => {
4343
// Metadata to pass through:
4444
passthrough: passthroughParameter,
4545
// Optionally request a specific payment provider:
46-
paymentProvider: requestedPaymentProvider
46+
paymentProvider: requestedPaymentProvider,
47+
// Optionally override the country (but not pricing) shown in the the checkout:
48+
checkoutCountry: checkoutCountryOverride
4749
} = event.queryStringParameters as {
4850
email?: string,
4951
sku?: PricedSKU,
@@ -52,7 +54,8 @@ export const handler = catchErrors(async (event) => {
5254
returnUrl?: string,
5355
discountCode?: string,
5456
passthrough?: string,
55-
paymentProvider?: 'paddle' | 'paypro'
57+
paymentProvider?: 'paddle' | 'paypro',
58+
checkoutCountry?: string
5659
};
5760

5861
log.debug('Checkout query params:', event.queryStringParameters);
@@ -145,7 +148,7 @@ export const handler = catchErrors(async (event) => {
145148
sku,
146149
quantity,
147150
discountCode,
148-
countryCode: ipData?.countryCode,
151+
countryCode: checkoutCountryOverride || ipData?.countryCode,
149152
currency: productPrices.currency,
150153
price: productPrices[sku],
151154
source: source || 'unknown',
@@ -171,4 +174,4 @@ export const handler = catchErrors(async (event) => {
171174
},
172175
body: ''
173176
};
174-
});
177+
});

0 commit comments

Comments
 (0)