Update billing card display and server actions
The code changes update the way the billing details are fetched and displayed in the system. In the billing card component, the baseLineItem price is replaced with the cost. For the server actions, getLineItemsFromPlanId is replaced with getProductPlanPair to fetch the product plan more efficiently. The change reduces unnecessary details, simplifying the code and possibly speeding up the operation.
This commit is contained in:
@@ -4,7 +4,7 @@ import { redirect } from 'next/navigation';
|
||||
|
||||
import { z } from 'zod';
|
||||
|
||||
import { getLineItemsFromPlanId } from '@kit/billing';
|
||||
import { getProductPlanPair } from '@kit/billing';
|
||||
import { getBillingGatewayProvider } from '@kit/billing-gateway';
|
||||
import { Logger } from '@kit/shared/logger';
|
||||
import { requireUser } from '@kit/supabase/require-user';
|
||||
@@ -65,17 +65,15 @@ export async function createPersonalAccountCheckoutSession(params: {
|
||||
throw new Error('Product not found');
|
||||
}
|
||||
|
||||
const { lineItems, trialDays } = getLineItemsFromPlanId(product, planId);
|
||||
const { plan } = getProductPlanPair(billingConfig, planId);
|
||||
|
||||
// call the payment gateway to create the checkout session
|
||||
const { checkoutToken } = await service.createCheckoutSession({
|
||||
lineItems,
|
||||
returnUrl,
|
||||
accountId,
|
||||
trialDays,
|
||||
paymentType: product.paymentType,
|
||||
customerEmail: user.email,
|
||||
customerId,
|
||||
plan,
|
||||
});
|
||||
|
||||
Logger.info(
|
||||
|
||||
@@ -67,7 +67,7 @@ export function CurrentPlanCard({
|
||||
i18nKey="billing:planRenewal"
|
||||
values={{
|
||||
interval: subscription.interval,
|
||||
price: formatCurrency(product.currency, baseLineItem.price),
|
||||
price: formatCurrency(product.currency, baseLineItem.cost),
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user