简体中文
了解如何使用 ShipThing 设置 Paddle。
.env.local
PADDLE_SECRET_KEY= PADDLE_WEBHOOK_SECRET= PADDLE_ENV="" // 如果您使用沙盒环境,请使用 'sandbox';否则使用 'production' 或省略该参数
paddle
import { paddle } from '@repo/payments';
/api/paddle/checkout
const response = await fetch('/api/paddle/checkout', { // 更改为 `/api/paddle/checkout` method: 'POST', body: JSON.stringify({ priceId: item.priceId, interval: item.interval, }), });
apps/web/api/paddle/checkout/route.ts
'use client'; import { usePaddle } from '@repo/payments/checkout'; const Pricing = () => { const paddle = usePaddle(); function openCheckout(priceId: string) { paddle?.Checkout.open({ items: [ { priceId, quantity: 1, }, ], }); } return ( <Button className="mt-8 gap-4" onClick={() => openCheckout('pri_01jkzb4x1hc91s8w38cr3m86yy')} > 立即订阅 <MoveRight className="h-4 w-4" /> </Button> ); }; export default Pricing;