revised thing

Signed-off-by: Kenneth Obsequio <k80308392@gmail.com>
This commit is contained in:
2026-08-09 17:33:38 +08:00
parent 30ec1330c6
commit 9018d6d158
11 changed files with 82 additions and 82 deletions
+10 -10
View File
@@ -77,7 +77,7 @@ exports.getMyTier = async (req, res) => {
const freeTier = { tier: 'free', status: 'active', category: freeCategory ?? null };
// Spread freeTier at top level too — keeps `myTier.tier`/`myTier.status`/`myTier.category`
// working for existing frontend code that predates the active_tiers/top_tier shape.
return R.success(res, 'Active tier retrieved.', {
return R.success(res, 'Active subscription retrieved.', {
...freeTier,
active_tiers: [freeTier],
top_tier: 'free',
@@ -126,10 +126,10 @@ exports.getMyTier = async (req, res) => {
// Spread topTierObj at top level too — keeps `myTier.tier`/`myTier.status`/
// `myTier.category`/`myTier.expires_at` working for existing frontend code
// that predates the active_tiers/top_tier shape (it'll just see the best tier).
return R.success(res, 'Active tier retrieved.', { ...topTierObj, active_tiers, top_tier, just_expired, my_grants });
return R.success(res, 'Active subscription retrieved.', { ...topTierObj, active_tiers, top_tier, just_expired, my_grants });
} catch (err) {
console.error('[CLIENT][GET MY TIER]', err);
return R.error(res, 'Could not retrieve tier.', 500);
return R.error(res, 'Could not retrieve subscription.', 500);
}
};
@@ -139,10 +139,10 @@ exports.getMyTierHistory = async (req, res) => {
where: { user_id: req.user.user_id },
order: [['createdAt', 'DESC']],
});
return R.success(res, 'Tier history retrieved.', history);
return R.success(res, 'Subscription history retrieved.', history);
} catch (err) {
console.error('[CLIENT][GET MY TIER HISTORY]', err);
return R.error(res, 'Could not retrieve tier history.', 500);
return R.error(res, 'Could not retrieve subscription history.', 500);
}
};
@@ -392,7 +392,7 @@ exports.captureOrder = async (req, res) => {
expires_at: expiresAt,
granted_by: null,
});
successMessage = 'Payment successful. Tier activated.';
successMessage = 'Payment successful. Subscription activated.';
}
// Snapshot the plan's current bundle contents into user_tier_grants —
@@ -471,7 +471,7 @@ exports.refundOrder = async (req, res) => {
where: activeTierWhere,
order: [['createdAt', 'DESC']],
});
if (!activeTierCandidates.length) return R.error(res, 'No active tier to refund.', 404);
if (!activeTierCandidates.length) return R.error(res, 'No active subscription to refund.', 404);
if (activeTierCandidates.length > 1) {
return R.error(res, 'You have more than one active subscription — specify plan_id to refund a specific one.', 400);
}
@@ -481,7 +481,7 @@ exports.refundOrder = async (req, res) => {
where: { user_id, tier_id: activeTier.tier_id, status: 'completed' },
order: [['paid_at', 'DESC']],
});
if (!payment) return R.error(res, 'No completed payment found for this tier.', 404);
if (!payment) return R.error(res, 'No completed payment found for this subscription.', 404);
// Load plan's payment policy to get the configured refund window
const policy = await paymentSvc.getPolicyForPlan(payment.plan_id);
@@ -608,10 +608,10 @@ exports.getCategories = async (req, res) => {
include: [{ model: Asset, as: 'badgeAsset', attributes: ['asset_id', 'storage_provider', 'file_url', 'display_name'], required: false }],
order: [['rank', 'ASC']],
});
return R.success(res, 'Tier categories retrieved.', categories);
return R.success(res, 'Subscription categories retrieved.', categories);
} catch (err) {
console.error('[CLIENT][GET TIER CATEGORIES]', err);
return R.error(res, 'Could not retrieve tier categories.', 500);
return R.error(res, 'Could not retrieve subscription categories.', 500);
}
};