@foldspace-fe/casdoor-next-auth-kit
v0.1.75
Published
[](https://www.npmjs.com/package/@foldspace-fe/casdoor-next-auth-kit) [ 生成 subscription catalog,再把结果交给 BillingProvider。商品项仍然可以单独拼进同一个 catalog,但订阅和商品要保持语义分离。
一个可以直接复制的完整模板如下:
const membershipPlans = [
{
id: 'plan-basic',
code: 'membership-monthly',
name: 'Membership Monthly',
level: 'BASIC',
priceCents: 99900,
giftPoints: 10000,
billingCycle: 'MONTH',
benefits: {
faceLibrary: true,
monthlyReports: true,
},
},
];
const subscriptionCatalog = buildBillingSubscriptionCatalog(membershipPlans, {
catalogKey: 'main',
title: 'Billing Catalog',
mapPlan: (plan) => ({
source: plan,
key: plan.code,
title: plan.name,
description: `${plan.level} membership`,
productId: 'qixiaoju/创小剧会员订阅',
planId: plan.id,
priceId: `pricing_${plan.code}`,
interval: 'month',
priceValue: plan.priceCents,
metadata: {
level: plan.level,
giftPoints: String(plan.giftPoints),
billingCycle: plan.billingCycle,
},
}),
});
const billingCatalog = {
...subscriptionCatalog,
purchasableIds: [...subscriptionCatalog.purchasableIds, 'credits-50'],
items: [
...subscriptionCatalog.items,
{
key: 'credits-50',
kind: 'product',
title: '50 Credits',
description: 'One-time product used for credits or other non-recurring goods.',
credits: 50,
backendRef: {
productId: 'qixiaoju/创小剧积分包-50',
priceId: 'price_credits_50',
},
creditGrant: {
creditsPerUnit: 50,
unitName: 'credits',
},
},
],
};如果你只是想配白名单,.env 里可以直接写:
NEXT_PUBLIC_BILLING_PURCHASABLE_IDS=membership-monthly,credits-50Billing 动作
'use client';
import {
useSubscribePlan,
usePurchaseProduct,
} from '@foldspace-fe/casdoor-next-auth-kit/react';最常用命令
npx @foldspace-fe/casdoor-next-auth-kit@latest init
npx @foldspace-fe/casdoor-next-auth-kit@latest update
npx @foldspace-fe/casdoor-next-auth-kit@latest check
npx @foldspace-fe/casdoor-next-auth-kit@latest --versionnpx 会读取 package 的 bin 入口并运行 casdoor-next-auth-kit CLI。
包导出
@foldspace-fe/casdoor-next-auth-kit@foldspace-fe/casdoor-next-auth-kit/react@foldspace-fe/casdoor-next-auth-kit/billing@foldspace-fe/casdoor-next-auth-kit/next
文档
npm
- 包页面:https://www.npmjs.com/package/@foldspace-fe/casdoor-next-auth-kit
- 发布 scope:
@foldspace-fe
