refactor: rename addSubscriptionRenewalCredits to addSubscriptionCredits for clarity

This commit is contained in:
javayhu 2025-07-13 09:26:16 +08:00
parent 368644b434
commit a89910489a
2 changed files with 4 additions and 10 deletions

View File

@ -458,10 +458,7 @@ export async function addMonthlyFreeCredits(userId: string) {
* @param userId - User ID
* @param priceId - Price ID
*/
export async function addSubscriptionRenewalCredits(
userId: string,
priceId: string
) {
export async function addSubscriptionCredits(userId: string, priceId: string) {
const pricePlan = findPlanByPriceId(priceId);
if (
!pricePlan ||

View File

@ -3,7 +3,7 @@ import { websiteConfig } from '@/config/website';
import {
addCredits,
addLifetimeMonthlyCredits,
addSubscriptionRenewalCredits,
addSubscriptionCredits,
} from '@/credits/credits';
import { getCreditPackageById } from '@/credits/server';
import { CREDIT_TRANSACTION_TYPE } from '@/credits/types';
@ -595,7 +595,7 @@ export class StripeProvider implements PaymentProvider {
// Add subscription renewal credits if plan config enables credits
const pricePlan = findPlanByPriceId(priceId);
if (pricePlan?.credits?.enable) {
await addSubscriptionRenewalCredits(userId, priceId);
await addSubscriptionCredits(userId, priceId);
}
}
}
@ -681,10 +681,7 @@ export class StripeProvider implements PaymentProvider {
// Add credits for subscription renewal
if (isRenewal && currentPayment[0].userId) {
try {
await addSubscriptionRenewalCredits(
currentPayment[0].userId,
priceId
);
await addSubscriptionCredits(currentPayment[0].userId, priceId);
console.log(
`<< Added renewal credits for user ${currentPayment[0].userId}, priceId: ${priceId}`
);