الوثائق
الفواتير
معلومات الاشتراك، والخروج من الشريط/تكامل البوابة، والصيانة التجريبية، واستيعاب الويب هوك الموقع.
مترجم تلقائيًا من الإنجليزية. عرض الأصل بالإنجليزية
أرسل هذه الطلبات إلى السايدكار الخاصة بك. تبقى القيم في هذا المتصفح.
كيف يعمل هذا
يستمع السايدكار إلى منفذ الاسترجاع الذي تم اختياره عند بدء التشغيل ويطبعه في منفذ الاسترجاع الخاص به ready خط؛ استخدم عنوان URL هذا و CADCAMFUN_TOKEN لقد بدأ مع. تذهب الطلبات مباشرة من هذه الصفحة إلى هذا العنوان.
يرسل السايدكار رؤوس CORS فقط إلى أصول Tauri وإلى http://localhost أو http://127.0.0.1 على أي منفذ. من المستندات المستضافة، يحظر المتصفح الاستجابة، لذا قم بتشغيل المستندات محليًا (bun run dev في packages/web) لاستخدام الملعب، أو نسخ الطلب كحليقة. للتجربة دون لمس البيانات الحقيقية، ابدأ تشغيل السايدكار باستخدام CADCAMFUN_DATA_DIR أشار إلى دليل مهمل - انظر إرشادات واجهة برمجة التطبيقات.
العمليات
15 نقاط نهاية في billing المجموعة التي تم إنشاؤها من السايدكار مستند OpenAPI. تأخذ العمليات المحمية Authorization: Bearer $CADCAMFUN_TOKEN; يرى المصادقة. السلوك والحدود موجودة دليل النظام الفرعي.
| يحصل | /api/subscription/info | billing.info |
| يحصل | /api/subscriptions | billing.current |
| بريد | /api/subscriptions | billing.subscribe |
| بريد | /api/subscriptions/portal | billing.portal |
| يحصل | /api/better-auth-stripe/subscription | billing.baGet |
| بريد | /api/better-auth-stripe/subscription | billing.baCheckout |
| يضع | /api/better-auth-stripe/subscription | billing.baUpdate |
| يمسح | /api/better-auth-stripe/subscription | billing.baCancel |
| بريد | /api/better-auth-stripe/billing-portal | billing.baPortal |
| بريد | /api/better-auth-stripe/feature-access | billing.baFeature |
| بريد | /api/better-auth-stripe/sync | billing.baSync |
| يحصل | /api/cron/update-expired-trials | billing.cronGet |
| بريد | /api/cron/update-expired-trials | billing.cronPost |
| يحصل | /api/health/stripe | billing.stripeHealth |
| بريد | /api/webhooks/stripe | billing.stripeWebhook |
/api/subscription/info
billing.info يتطلب Authorization: Bearer <token>.
| اسم | في | يكتب | مطلوب |
|---|---|---|---|
| userId | استفسار | خيط | null | خياري |
200 هدف application/json
{ id: string plan: string status: string currentPeriodEnd: string | null cancelAtPeriodEnd: boolean | null stripeCustomerId: string | null stripeSubscriptionId: string | null }
400 BillingBadRequestEncoded application/json
BillingBadRequestEncoded
401 UnauthorizedEncoded application/json
UnauthorizedEncoded
403 BillingForbiddenEncoded application/json
BillingForbiddenEncoded
404 BillingNotFoundEncoded application/json
BillingNotFoundEncoded
500 BillingFailureEncoded application/json
BillingFailureEncoded
رد المثال تم الالتقاط · 400
{
"_tag": "BillingBadRequest",
"error": "User ID is required"
} مثال SDK
import { CadCam } from "@cadcamfun/api/sdk"
const client = CadCam.make({
baseUrl: process.env.CADCAMFUN_URL!,
headers: { authorization: `Bearer ${process.env.CADCAMFUN_TOKEN}` },
})
// BillingInfoInput
const result = await client.billing.info({}) curl
curl --request GET "${CADCAMFUN_URL}/api/subscription/info" \
--header "Authorization: Bearer ${CADCAMFUN_TOKEN}" جربه
/api/subscriptions
billing.current يتطلب Authorization: Bearer <token>.
200 هدف application/json
{ plan: string status: string periodEnd: string | null cancelAtPeriodEnd: boolean isOnTrial?: boolean | null trialEnd?: string | null }
401 UnauthorizedEncoded application/json
UnauthorizedEncoded
500 InternalErrorEncoded application/json
InternalErrorEncoded
رد المثال تم الالتقاط · 200
{
"plan": "FREE",
"status": "active",
"periodEnd": null,
"cancelAtPeriodEnd": false
} مثال SDK
import { CadCam } from "@cadcamfun/api/sdk"
const client = CadCam.make({
baseUrl: process.env.CADCAMFUN_URL!,
headers: { authorization: `Bearer ${process.env.CADCAMFUN_TOKEN}` },
})
// no input
const result = await client.billing.current() curl
curl --request GET "${CADCAMFUN_URL}/api/subscriptions" \
--header "Authorization: Bearer ${CADCAMFUN_TOKEN}" جربه
billing.subscribe يتطلب Authorization: Bearer <token>.
{ priceId?: string | null startTrial?: boolean | null }
200 هدف application/json
{ url?: string | null success?: boolean | null message?: string | null redirectUrl?: string | null }
400 BadRequestEncoded application/json
BadRequestEncoded
401 UnauthorizedEncoded application/json
UnauthorizedEncoded
404 NotFoundEncoded application/json
NotFoundEncoded
500 InternalErrorEncoded application/json
InternalErrorEncoded
مثال SDK
import { CadCam } from "@cadcamfun/api/sdk"
const client = CadCam.make({
baseUrl: process.env.CADCAMFUN_URL!,
headers: { authorization: `Bearer ${process.env.CADCAMFUN_TOKEN}` },
})
// BillingSubscribeInput
const result = await client.billing.subscribe({
priceId: "",
startTrial: false
}) curl
curl --request POST "${CADCAMFUN_URL}/api/subscriptions" \
--header "Authorization: Bearer ${CADCAMFUN_TOKEN}" \
--header "Content-Type: application/json" \
--data-binary @request.json جربه
/api/subscriptions/portal
billing.portal يتطلب Authorization: Bearer <token>.
{ returnUrl?: string | null }
200 هدف application/json
{ url: string }
400 BadRequestEncoded application/json
BadRequestEncoded
401 UnauthorizedEncoded application/json
UnauthorizedEncoded
404 NotFoundEncoded application/json
NotFoundEncoded
500 InternalErrorEncoded application/json
InternalErrorEncoded
مثال SDK
import { CadCam } from "@cadcamfun/api/sdk"
const client = CadCam.make({
baseUrl: process.env.CADCAMFUN_URL!,
headers: { authorization: `Bearer ${process.env.CADCAMFUN_TOKEN}` },
})
// BillingPortalInput
const result = await client.billing.portal({
returnUrl: ""
}) curl
curl --request POST "${CADCAMFUN_URL}/api/subscriptions/portal" \
--header "Authorization: Bearer ${CADCAMFUN_TOKEN}" \
--header "Content-Type: application/json" \
--data-binary @request.json جربه
/api/better-auth-stripe/subscription
billing.baGet يتطلب Authorization: Bearer <token>.
200 هدف application/json
{ id?: string | null plan: string status: string currentPeriodEnd: string | null cancelAtPeriodEnd: boolean stripeCustomerId?: string | null stripeSubscriptionId?: string | null source: "better-auth" }
401 UnauthorizedEncoded application/json
UnauthorizedEncoded
500 BillingFailureEncoded application/json
BillingFailureEncoded
رد المثال تم الالتقاط · 200
{
"id": "c942817d-0162-4291-84ff-77321d387acc",
"plan": "FREE",
"status": "active",
"currentPeriodEnd": null,
"cancelAtPeriodEnd": false,
"stripeCustomerId": null,
"stripeSubscriptionId": null,
"source": "better-auth"
} مثال SDK
import { CadCam } from "@cadcamfun/api/sdk"
const client = CadCam.make({
baseUrl: process.env.CADCAMFUN_URL!,
headers: { authorization: `Bearer ${process.env.CADCAMFUN_TOKEN}` },
})
// no input
const result = await client.billing.baGet() curl
curl --request GET "${CADCAMFUN_URL}/api/better-auth-stripe/subscription" \
--header "Authorization: Bearer ${CADCAMFUN_TOKEN}" جربه
billing.baCheckout يتطلب Authorization: Bearer <token>.
{ plan?: string | null successUrl?: string | null cancelUrl?: string | null trialDays?: number | "Infinity" | "-Infinity" | "NaN" | null }
200 هدف application/json
{ url: string source: "better-auth" }
400 BillingBadRequestEncoded application/json
BillingBadRequestEncoded
401 UnauthorizedEncoded application/json
UnauthorizedEncoded
500 BillingFailureEncoded application/json
BillingFailureEncoded
مثال SDK
import { CadCam } from "@cadcamfun/api/sdk"
const client = CadCam.make({
baseUrl: process.env.CADCAMFUN_URL!,
headers: { authorization: `Bearer ${process.env.CADCAMFUN_TOKEN}` },
})
// BillingBaCheckoutInput
const result = await client.billing.baCheckout({
plan: "",
successUrl: "",
cancelUrl: "",
trialDays: 0
}) curl
curl --request POST "${CADCAMFUN_URL}/api/better-auth-stripe/subscription" \
--header "Authorization: Bearer ${CADCAMFUN_TOKEN}" \
--header "Content-Type: application/json" \
--data-binary @request.json جربه
billing.baUpdate يتطلب Authorization: Bearer <token>.
{ newPlan?: string | null }
200 هدف application/json
{ success: true message: string source: "better-auth" }
400 BillingBadRequestEncoded application/json
BillingBadRequestEncoded
401 UnauthorizedEncoded application/json
UnauthorizedEncoded
500 BillingFailureEncoded application/json
BillingFailureEncoded
مثال SDK
import { CadCam } from "@cadcamfun/api/sdk"
const client = CadCam.make({
baseUrl: process.env.CADCAMFUN_URL!,
headers: { authorization: `Bearer ${process.env.CADCAMFUN_TOKEN}` },
})
// BillingBaUpdateInput
const result = await client.billing.baUpdate({
newPlan: ""
}) curl
curl --request PUT "${CADCAMFUN_URL}/api/better-auth-stripe/subscription" \
--header "Authorization: Bearer ${CADCAMFUN_TOKEN}" \
--header "Content-Type: application/json" \
--data-binary @request.json جربه
billing.baCancel يتطلب Authorization: Bearer <token>.
200 هدف application/json
{ success: true message: string source: "better-auth" }
401 UnauthorizedEncoded application/json
UnauthorizedEncoded
500 BillingFailureEncoded application/json
BillingFailureEncoded
مثال SDK
import { CadCam } from "@cadcamfun/api/sdk"
const client = CadCam.make({
baseUrl: process.env.CADCAMFUN_URL!,
headers: { authorization: `Bearer ${process.env.CADCAMFUN_TOKEN}` },
})
// no input
const result = await client.billing.baCancel() curl
curl --request DELETE "${CADCAMFUN_URL}/api/better-auth-stripe/subscription" \
--header "Authorization: Bearer ${CADCAMFUN_TOKEN}" جربه
/api/better-auth-stripe/billing-portal
billing.baPortal يتطلب Authorization: Bearer <token>.
{ returnUrl?: string | null }
200 هدف application/json
{ url: string source: "better-auth" }
400 BillingBadRequestEncoded application/json
BillingBadRequestEncoded
401 UnauthorizedEncoded application/json
UnauthorizedEncoded
500 BillingFailureEncoded application/json
BillingFailureEncoded
مثال SDK
import { CadCam } from "@cadcamfun/api/sdk"
const client = CadCam.make({
baseUrl: process.env.CADCAMFUN_URL!,
headers: { authorization: `Bearer ${process.env.CADCAMFUN_TOKEN}` },
})
// BillingBaPortalInput
const result = await client.billing.baPortal({
returnUrl: ""
}) curl
curl --request POST "${CADCAMFUN_URL}/api/better-auth-stripe/billing-portal" \
--header "Authorization: Bearer ${CADCAMFUN_TOKEN}" \
--header "Content-Type: application/json" \
--data-binary @request.json جربه
/api/better-auth-stripe/feature-access
billing.baFeature يتطلب Authorization: Bearer <token>.
{ feature?: string | null features?: unknown | null }
200 هدف application/json
{ feature?: string | null hasAccess?: boolean | null source: "better-auth" features?: Array<{ feature: string hasAccess: boolean error?: string | null }> | null }
400 BillingBadRequestEncoded application/json
BillingBadRequestEncoded
401 UnauthorizedEncoded application/json
UnauthorizedEncoded
500 BillingFailureEncoded application/json
BillingFailureEncoded
مثال SDK
import { CadCam } from "@cadcamfun/api/sdk"
const client = CadCam.make({
baseUrl: process.env.CADCAMFUN_URL!,
headers: { authorization: `Bearer ${process.env.CADCAMFUN_TOKEN}` },
})
// BillingBaFeatureInput
const result = await client.billing.baFeature({
feature: "",
features: null
}) curl
curl --request POST "${CADCAMFUN_URL}/api/better-auth-stripe/feature-access" \
--header "Authorization: Bearer ${CADCAMFUN_TOKEN}" \
--header "Content-Type: application/json" \
--data-binary @request.json جربه
/api/better-auth-stripe/sync
billing.baSync يتطلب Authorization: Bearer <token>.
200 هدف application/json
{ success: true message: string subscription: { id?: string | null plan: string status: string currentPeriodEnd: string | null cancelAtPeriodEnd: boolean stripeCustomerId?: string | null stripeSubscriptionId?: string | null source: "better-auth" } | null source: "better-auth" }
401 UnauthorizedEncoded application/json
UnauthorizedEncoded
500 BillingFailureEncoded application/json
BillingFailureEncoded
مثال SDK
import { CadCam } from "@cadcamfun/api/sdk"
const client = CadCam.make({
baseUrl: process.env.CADCAMFUN_URL!,
headers: { authorization: `Bearer ${process.env.CADCAMFUN_TOKEN}` },
})
// no input
const result = await client.billing.baSync() curl
curl --request POST "${CADCAMFUN_URL}/api/better-auth-stripe/sync" \
--header "Authorization: Bearer ${CADCAMFUN_TOKEN}" جربه
/api/cron/update-expired-trials
billing.cronGet يتطلب Authorization: Bearer <token>.
| اسم | في | يكتب | مطلوب |
|---|---|---|---|
| سر | استفسار | خيط | null | خياري |
200 هدف application/json
{ success: true updatedCount: number | "Infinity" | "-Infinity" | "NaN" message: string timestamp: string }
401 كرونUnauthorizedEncoded | غير مصرح به مشفرة application/json
CronUnauthorizedEncoded | UnauthorizedEncoded
500 CronFailureEncoded application/json
CronFailureEncoded
رد المثال تم الالتقاط · 200
{
"success": true,
"updatedCount": 0,
"message": "Successfully updated 0 expired trials",
"timestamp": "2026-10-15T04:52:23.475Z"
} مثال SDK
import { CadCam } from "@cadcamfun/api/sdk"
const client = CadCam.make({
baseUrl: process.env.CADCAMFUN_URL!,
headers: { authorization: `Bearer ${process.env.CADCAMFUN_TOKEN}` },
})
// BillingCronGetInput
const result = await client.billing.cronGet({}) curl
curl --request GET "${CADCAMFUN_URL}/api/cron/update-expired-trials" \
--header "Authorization: Bearer ${CADCAMFUN_TOKEN}" جربه
billing.cronPost يتطلب Authorization: Bearer <token>.
| اسم | في | يكتب | مطلوب |
|---|---|---|---|
| سر | استفسار | خيط | null | خياري |
200 هدف application/json
{ success: true updatedCount: number | "Infinity" | "-Infinity" | "NaN" message: string timestamp: string }
401 كرونUnauthorizedEncoded | غير مصرح به مشفرة application/json
CronUnauthorizedEncoded | UnauthorizedEncoded
500 CronFailureEncoded application/json
CronFailureEncoded
مثال SDK
import { CadCam } from "@cadcamfun/api/sdk"
const client = CadCam.make({
baseUrl: process.env.CADCAMFUN_URL!,
headers: { authorization: `Bearer ${process.env.CADCAMFUN_TOKEN}` },
})
// BillingCronPostInput
const result = await client.billing.cronPost({}) curl
curl --request POST "${CADCAMFUN_URL}/api/cron/update-expired-trials" \
--header "Authorization: Bearer ${CADCAMFUN_TOKEN}" جربه
/api/health/stripe
billing.stripeHealth يتطلب Authorization: Bearer <token>.
200 هدف application/json
{ status: "healthy" message: string timestamp: string service: "stripe" }
401 UnauthorizedEncoded application/json
UnauthorizedEncoded
503 StripeUnhealthyEncoded application/json
StripeUnhealthyEncoded
رد المثال تم الالتقاط · 503
{
"_tag": "StripeUnhealthy",
"status": "unhealthy",
"message": "Stripe is not configured on this installation",
"timestamp": "2026-10-15T04:52:23.476Z",
"service": "stripe"
} مثال SDK
import { CadCam } from "@cadcamfun/api/sdk"
const client = CadCam.make({
baseUrl: process.env.CADCAMFUN_URL!,
headers: { authorization: `Bearer ${process.env.CADCAMFUN_TOKEN}` },
})
// no input
const result = await client.billing.stripeHealth() curl
curl --request GET "${CADCAMFUN_URL}/api/health/stripe" \
--header "Authorization: Bearer ${CADCAMFUN_TOKEN}" جربه
/api/webhooks/stripe
billing.stripeWebhook يتطلب Authorization: Bearer <token>.
string 200 هدف application/json
{ received: true }
400 BadRequestEncoded application/json
BadRequestEncoded
401 UnauthorizedEncoded application/json
UnauthorizedEncoded
جلب المثال
// Not generated in the Promise SDK (multipart, binary or raw body): call it with fetch.
const response = await fetch(`${process.env.CADCAMFUN_URL}/api/webhooks/stripe`, {
method: "POST",
headers: { authorization: `Bearer ${process.env.CADCAMFUN_TOKEN}` },
}) curl
curl --request POST "${CADCAMFUN_URL}/api/webhooks/stripe" \
--header "Authorization: Bearer ${CADCAMFUN_TOKEN}" \
--header "Content-Type: application/octet-stream" \
--data-binary @request-body جربه
تأخذ هذه العملية التطبيق/الثمانية تيار؛ استخدم مثال الضفيرة أو الجلب.
المخططات
يمكن الوصول إلى المخططات المسماة من معلمات هذه المجموعة وأجسامها واستجاباتها. أ ? يمثل حقلاً اختياريًا؛ | null يضع علامة على الحقل الذي قد يكون موجودًا بقيمة فارغة.
BadRequestEncoded{ _tag: "BadRequest" message: string }
BillingBadRequestEncoded{ _tag: "BillingBadRequest" error: string }
BillingFailureEncoded{ _tag: "BillingFailure" error: string }
BillingForbiddenEncoded{ _tag: "BillingForbidden" error: string }
BillingNotFoundEncoded{ _tag: "BillingNotFound" error: string }
CronFailureEncoded{ _tag: "CronFailure" success: false error: string timestamp: string }
InternalErrorEncoded{ _tag: "InternalError" message: string }
NotFoundEncoded{ _tag: "NotFound" message: string }
StripeUnhealthyEncoded{ _tag: "StripeUnhealthy" status: "unhealthy" message: string timestamp: string service: "stripe" }
استدعاء هذه المجموعة
معرفات العملية لها النموذج billing.<name>. وعد SDK الذي تم إنشاؤه (@cadcamfun/api/sdk) يعرض معظمهم client.<namespace>.<method>(input)، أين input هو كائن مسطح واحد من معلمات المسار وحقول النص؛ يُظهر مثال SDK لكل بطاقة الملحق الدقيق ونوع الإدخال. لا يتم إنشاء التحميلات متعددة الأجزاء والاستجابات الثنائية أو استجابات JavaScript وخطافات الويب الأولية؛ تظهر تلك البطاقات fetch بدلاً من ذلك.
import { CadCam, ClientError } from "@cadcamfun/api/sdk"
const client = CadCam.make({
baseUrl: process.env.CADCAMFUN_URL!,
headers: { authorization: `Bearer ${process.env.CADCAMFUN_TOKEN}` },
})
try {
await client.projects.list()
} catch (error) {
if (error instanceof ClientError) {
// Transport | UnexpectedStatus | UnsupportedContentType | MalformedResponse | SseEventTooLarge
} else {
// a declared error body: switch on error._tag
}
} استكشاف الأخطاء وإصلاحها
| أعراض | السبب المحتمل | يصلح |
|---|---|---|
| 401 في كل طلب | رمز مميز من إطلاق سابق، أو مفقود Bearer بادئة | يرسل Authorization: Bearer <token> بالرمز المميز الذي بدأت به السايدكار. |
| 400 قبل أن يحدث أي شيء | النص أو المعلمة لا يتطابقان مع المخطط | قارن الحمولة بمخطط الطلب الموجود على البطاقة. |
| 403 أو 404 لسجل يمكنك رؤيته في مكان آخر | حساب التمثيل يختلف | أرسل الحق x-session-tokenأو استخدم ملف التعريف المحلي الذي يملك السجل. |
| 409 | حالة متعارضة، مثل اسم مكرر أو رأس فرع قديم | أعد قراءة المورد وأعد المحاولة باستخدام البيانات الحالية. |
| جربه يقول "تم حظره بواسطة CORS" | يتم تقديم المستندات من أصل غير استرجاعي | قم بتشغيل المستندات محليًا أو انسخ الطلب كـ curly. |
| رفض اتصال | تم إعادة تشغيل السايدكار في منفذ جديد | قراءة المنفذ من الجديد ready سطر. |