mirror of
https://github.com/stack-auth/stack.git
synced 2026-06-13 21:01:21 +08:00
Update examples
This commit is contained in:
parent
2e3fe8d7d2
commit
9aa8f2206a
@ -133,9 +133,20 @@ To sell a product, generate a checkout URL and redirect the user to it. The `cre
|
||||
|
||||
For team purchases, call `createCheckoutUrl` on the team object instead:
|
||||
|
||||
```typescript
|
||||
const team = user.useTeam(teamId);
|
||||
const checkoutUrl = await team.createCheckoutUrl({ productId });
|
||||
```tsx
|
||||
function TeamPurchaseButton({ teamId, productId }: { teamId: string, productId: string }) {
|
||||
const user = useUser({ or: "redirect" });
|
||||
const team = user.useTeam(teamId);
|
||||
|
||||
return (
|
||||
<button onClick={async () => {
|
||||
const checkoutUrl = await team.createCheckoutUrl({ productId });
|
||||
window.location.href = checkoutUrl;
|
||||
}}>
|
||||
Purchase team plan
|
||||
</button>
|
||||
);
|
||||
}
|
||||
```
|
||||
|
||||
<Info>
|
||||
|
||||
@ -126,10 +126,20 @@ export default function UpgradeButton() {
|
||||
|
||||
Team plans work the same way when you call the methods on a team object:
|
||||
|
||||
```typescript
|
||||
const team = user.useTeam(teamId);
|
||||
await team.switchSubscription({
|
||||
fromProductId: "prod_team_pro",
|
||||
toProductId: "prod_team_enterprise",
|
||||
});
|
||||
```tsx
|
||||
function TeamUpgradeButton({ teamId }: { teamId: string }) {
|
||||
const user = useUser({ or: "redirect" });
|
||||
const team = user.useTeam(teamId);
|
||||
|
||||
return (
|
||||
<button onClick={async () => {
|
||||
await team.switchSubscription({
|
||||
fromProductId: "prod_team_pro",
|
||||
toProductId: "prod_team_enterprise",
|
||||
});
|
||||
}}>
|
||||
Upgrade team plan
|
||||
</button>
|
||||
);
|
||||
}
|
||||
```
|
||||
|
||||
@ -155,9 +155,20 @@ Generate a checkout URL from the user or team that will own the purchase:
|
||||
|
||||
For team purchases, call `createCheckoutUrl` on the team object:
|
||||
|
||||
```typescript
|
||||
const team = user.useTeam(teamId);
|
||||
const checkoutUrl = await team.createCheckoutUrl({ productId: "prod_team_plan" });
|
||||
```tsx
|
||||
function TeamPurchaseButton({ teamId }: { teamId: string }) {
|
||||
const user = useUser({ or: "redirect" });
|
||||
const team = user.useTeam(teamId);
|
||||
|
||||
return (
|
||||
<button onClick={async () => {
|
||||
const checkoutUrl = await team.createCheckoutUrl({ productId: "prod_team_plan" });
|
||||
window.location.href = checkoutUrl;
|
||||
}}>
|
||||
Purchase team plan
|
||||
</button>
|
||||
);
|
||||
}
|
||||
```
|
||||
|
||||
<Info>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user