본문으로 건너뛰기
Skillpedia
API 및 서버 (백엔드)9.5k · #12236

convex-billing

하는 일

이 스킬은 Stripe 결제를 Convex 앱에 연결합니다. 결제 페이지, 결제를 기록하는 웹훅, 특정 기능을 유료 사용자로 제한하는 확인을 다룹니다. Convex 앱으로 고객에게 요금을 받으려는 개발자를 위한 스킬입니다.

사용하는 경우

  • ✓Convex 앱으로 고객에게 요금을 청구하고 싶을 때.
  • ✓앱의 일부 기능을 여는 구독이 필요할 때.
  • ✓Stripe 웹훅이 앱의 결제 상태를 자동으로 업데이트하게 하고 싶은 경우.

스킬 링크

https://github.com/openclaw/clawhub/blob/main/.agents/skills/convex-billing/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/openclaw/clawhub/blob/main/.agents/skills/convex-billing/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“Convex 앱에 Stripe 구독을 추가해서 유료 사용자만 프리미엄 기능을 쓰게 해 주세요.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

에이전트는 Stripe 구성 요소를 설치하고, Stripe 키를 Convex 설정에 저장하고, 결제 페이지 액션과 웹훅을 설정하며, 사용자의 구독이 활성인지 앱에 알려 주는 확인 기능을 추가합니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

<!-- GENERATED from convex-agents content/capabilities/billing.json — do not edit by hand. -->

Add billing / payments

Wire Stripe to Convex using @convex-dev/stripe: a checkout action, an httpAction webhook registered by the component (signature-verified automatically), subscription state stored in the component's tables, and server-side gating via a query.

Workflow

  1. Install the component: npm install @convex-dev/stripe.
  2. Create convex/convex.config.ts:
    import stripe from "@convex-dev/stripe/convex.config.js";
    import { defineApp } from "convex/server";
    const app = defineApp();
    app.use(stripe);
    export default app;
    
  3. Store Stripe keys in Convex env (use the env micro power): STRIPE_SECRET_KEY (sk_test_… / sk_live_…) and STRIPE_WEBHOOK_SECRET (whsec_…).
  4. Create convex/http.ts to register the webhook route (the component handles signature verification automatically):
    import { registerRoutes } from "@convex-dev/stripe";
    import { httpRouter } from "convex/server";
    import { components } from "./_generated/api";
    const http = httpRouter();
    registerRoutes(http, components.stripe, { webhookPath: "/stripe/webhook" });
    export default http;
    
  5. Create convex/billing.ts with a checkout action and a subscription-gate query:
    import { StripeSubscriptions } from "@convex-dev/stripe";
    import { v } from "convex/values";
    import { components } from "./_generated/api";
    import { action, query } from "./_generated/server";
    const stripeClient = new StripeSubscriptions(components.stripe, {});
    export const createSubscriptionCheckout = action({
      args: { priceId: v.string() },
      returns: v.object({ sessionId: v.string(), url: v.union(v.string(), v.null()) }),
      handler: async (ctx, args) => {
        const identity = await ctx.auth.getUserIdentity();
        if (!identity) throw new Error("Not authenticated");
        const customer = await stripeClient.getOrCreateCustomer(ctx, {
          userId: identity.subject,
          email: identity.email,
          name: identity.name,
        });
        return await stripeClient.createCheckoutSession(ctx, {
          priceId: args.priceId,
          customerId: customer.customerId,
          mode: "subscription",
          successUrl: `${process.env.SITE_URL ?? "http://localhost:3000"}/?success=true`,
          cancelUrl: `${process.env.SITE_URL ?? "http://localhost:3000"}/?canceled=true`,
          subscriptionMetadata: { userId: identity.subject },
        });
      },
    });
    export const isSubscribed = query({
      args: {},
      returns: v.boolean(),
      handler: async (ctx) => {
        const identity = await ctx.auth.getUserIdentity();
        if (!identity) return false;
        const subscriptions = await ctx.runQuery(
          components.stripe.public.listSubscriptionsByUserId,
          { userId: identity.subject },
        );
        return subscriptions.some((sub) => sub.status === "active" || sub.status === "trialing");
      },
    });
    
  6. Run npx convex dev --once — it will install the component and push the functions. Verify output shows ✔ Installed component stripe.
  7. In Stripe Dashboard → Webhooks: add endpoint https://<deployment>.convex.site/stripe/webhook, subscribe to checkout.session.completed, customer.subscription.*, invoice.*, payment_intent.*. Copy the signing secret as STRIPE_WEBHOOK_SECRET.

Rules

  • Use @convex-dev/stripe (npm: @convex-dev/stripe@^0.1.4) — it handles webhook signature verification internally via registerRoutes; do NOT write a manual constructEvent webhook.
  • Stripe keys live in Convex env (use the env micro power): STRIPE_SECRET_KEY and STRIPE_WEBHOOK_SECRET.
  • Gate on server-stored subscription state via isSubscribed query (reads component tables), not client claims.
  • convex/convex.config.ts must import from '@convex-dev/stripe/convex.config.js' (not .ts) — the .js extension is required by the Convex bundler.
자주 묻는 질문

Stripe 키는 어디에 두나요?

코드가 아니라 Convex 환경 설정에 둡니다. 테스트 키와 실제 키는 따로 보관됩니다.

스킬이 웹훅 메시지를 확인하나요?

예. Stripe 구성 요소가 각 웹훅의 서명을 자동으로 확인합니다.

일회성 결제도 처리하나요?

스킬은 결제 페이지와 구독에 초점을 둡니다. 다른 결제 유형이 필요하면 생성된 코드를 직접 검토해야 합니다.

상세 정보

작성자의 원본 설명

Add Stripe billing/payments to the Convex app via @convex-dev/stripe (checkout + webhook + gating).

repo: openclaw/clawhub

인기도

GitHub 스타
9.5k
순위
#12236
라이선스
MIT
업데이트
2026. 11. 2.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬