-
Notifications
You must be signed in to change notification settings - Fork 197
Description
Bug report
- Extension name:
firestore-stripe-payments
Describe the bug
The promotion codes cannot be redeemed neither in checkout nor in customer portal. It is indicated as invalid even though they are properly configured.
Checkout generated by:
import {
getStripePayments,
createCheckoutSession,
getProducts,
Product,
} from '@invertase/firestore-stripe-payments';
export const createSubscriptionCheckout = async (
priceId: string,
{
trialPeriodDays,
locale,
initialQuantity = 1,
maxQuantity = 50,
promotionCode
}: {
trialPeriodDays?: number,
locale?: string,
initialQuantity?: number,
maxQuantity?: number,
promotionCode?: string
} = {},
): Promise<string> => {
try {
const sessionConfig: any = {
payment_method_types: ['card'],
line_items: [{
price: priceId,
quantity: initialQuantity,
adjustable_quantity: {
enabled: true,
minimum: initialQuantity,
maximum: maxQuantity,
},
}],
mode: 'subscription',
success_url: window.location.href,
cancel_url: window.location.href,
// Enable automatic tax collection
automatic_tax: {
enabled: true,
},
// Collect tax IDs from customers (business default)
tax_id_collection: {
enabled: true,
required: "if_supported",
},
// Collect billing address (required for business)
billing_address_collection: 'required',
// Allow promotion codes
...(locale && { locale }),
allow_promotion_codes: true,
...(promotionCode && { promotion_code: promotionCode })
};
console.log('sessionConfig', sessionConfig);
// Add trial period if specified
if (trialPeriodDays && trialPeriodDays > 0) {
sessionConfig.trial_period_days = trialPeriodDays;
}
const session = await createCheckoutSession(payments, sessionConfig);
return session.url;
} catch (error) {
console.error('Error creating checkout session:', error);
throw new Error('Failed to create checkout session');
}
};
It is very interesting that if promotionCode is undefined, let's the user input the code in the checkout but never is validated.
However, if promotionCode is defined, the discount is automatically applied and working as expected. Therefore, it has to be related to this extension's method.
And portal link is generated by:
const createPortalLink = httpsCallable(europeWest1Functions, 'ext-firestore-stripe-payments-pro-createPortalLink');
To Reproduce
Create a valid promotion code in Stripe which can be redeemed and try to redeem it in checkout payment or customer portal.
Expected behavior
It should accept a valid promotion code.
Screenshots
N/A
System information
Indifferent.
Additional context
https://www.perplexity.ai/search/why-promotion-codes-are-invali-DnBciZXhQn.YKldTXKEEHQ