Add subcription feature 4
This commit is contained in:
@@ -264,7 +264,7 @@ export const PaymentStep: React.FC<PaymentStepProps> = ({
|
||||
// Store payment method ID for use after 3DS completion
|
||||
setPendingPaymentMethodId(paymentMethod.id);
|
||||
|
||||
// Update paymentSetup state with customer_id for redirect recovery
|
||||
// Update paymentSetup state with customer_id and trial_period_days for redirect recovery
|
||||
updateRegistrationState({
|
||||
paymentSetup: {
|
||||
success: false,
|
||||
@@ -272,6 +272,7 @@ export const PaymentStep: React.FC<PaymentStepProps> = ({
|
||||
subscriptionId: '',
|
||||
paymentMethodId: paymentMethod.id,
|
||||
planId: registrationState.subscription.planId,
|
||||
trialPeriodDays: paymentSetupResult.trial_period_days ?? (registrationState.subscription.useTrial ? 90 : 0),
|
||||
},
|
||||
});
|
||||
|
||||
@@ -353,6 +354,7 @@ export const PaymentStep: React.FC<PaymentStepProps> = ({
|
||||
: setupIntent.payment_method?.id || pendingPaymentMethodId;
|
||||
|
||||
// Complete registration with verified SetupIntent using React Query mutation
|
||||
// Send coupon_code to backend for trial period calculation
|
||||
const verificationResult = await completeRegistrationMutation.mutateAsync({
|
||||
setup_intent_id: setupIntentId || '',
|
||||
user_data: {
|
||||
@@ -363,6 +365,9 @@ export const PaymentStep: React.FC<PaymentStepProps> = ({
|
||||
billing_cycle: registrationState.subscription.billingInterval,
|
||||
payment_method_id: confirmedPaymentMethodId || pendingPaymentMethodId,
|
||||
coupon_code: registrationState.subscription.couponCode,
|
||||
// Pass customer_id for reference
|
||||
customer_id: registrationState.paymentSetup?.customerId || '',
|
||||
// Remove trial_period_days - backend will calculate from coupon_code
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user