@logto/cloud 0.2.5-9a1b047 → 0.2.5-9c40a76
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +63 -0
- package/lib/routes/index.d.ts +761 -366
- package/package.json +8 -7
package/README.md
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# Logto Cloud
|
|
2
|
+
|
|
3
|
+
Logto Cloud service package.
|
|
4
|
+
|
|
5
|
+
## Local Development Guides
|
|
6
|
+
|
|
7
|
+
### Stripe Subscription Development
|
|
8
|
+
|
|
9
|
+
This section covers setting up Stripe for local subscription debugging.
|
|
10
|
+
|
|
11
|
+
After completing the Cloud configuration and seeding the database, the `logto_skus` table will contain all Logto SKUs. Before starting debugging, you need to create corresponding products in Stripe for each SKU and sync the associations to the local `stripe_products` table via webhooks.
|
|
12
|
+
|
|
13
|
+
#### Stripe Prerequisites
|
|
14
|
+
|
|
15
|
+
1. Register and log in to a Stripe account (<https://stripe.com/>).
|
|
16
|
+
2. Install Stripe CLI (official documentation: <https://docs.stripe.com/stripe-cli>).
|
|
17
|
+
|
|
18
|
+
#### Configure Environment Variables
|
|
19
|
+
|
|
20
|
+
Prepare the following in your local environment:
|
|
21
|
+
|
|
22
|
+
- `STRIPE_API_KEY`: Switch to **Test mode** in Stripe Console, copy the secret key from the "For developers" section under "Get started with Stripe" on the homepage for local testing.
|
|
23
|
+
- `STRIPE_WEBHOOK_SECRET`:
|
|
24
|
+
1. First configure `STRIPE_API_KEY`, then run `stripe login` to log in to Stripe CLI.
|
|
25
|
+
2. Execute `pnpm cli stripe listen --target localhost:3003/api/webhook/stripe` in the `packages/cloud` directory to forward Stripe webhook events to your local environment (modify `--target` accordingly if using a custom port or address).
|
|
26
|
+
3. The terminal will output `Your webhook signing secret is ${WEBHOOK_SECRET}`, add this value to your environment variables.
|
|
27
|
+
4. If Cloud is currently running, restart it (or wait for automatic reload in development mode) to load the latest variables.
|
|
28
|
+
|
|
29
|
+
#### Associate Logto SKUs with Stripe Products
|
|
30
|
+
|
|
31
|
+
Once environment variables are ready, you can use one of the following two methods to create and associate Stripe products for each SKU. Both methods will write products to the local `stripe_products` table via webhooks.
|
|
32
|
+
|
|
33
|
+
> [!NOTE]
|
|
34
|
+
> Default SKUs are already seeded in the `logto_skus` table. If you need to add a new SKU, you must insert the record into `logto_skus` first before creating its corresponding Stripe product.
|
|
35
|
+
|
|
36
|
+
##### Method 1: Using Project CLI (Recommended)
|
|
37
|
+
|
|
38
|
+
1. Find the target `sku id` in the database's `logto_skus` table.
|
|
39
|
+
2. Run the command to create a product in the `packages/cloud` directory. For example, to create a product named "Pro Plan 202509" with a unit price of `1600` ($16) for the SKU whose ID is `pro-202509`:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
pnpm cli stripe upsert-product --skuId "pro-202509" --name "Pro Plan 202509" --unitPrice "1600"
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
3. After execution, the Stripe product will sync to the local database via webhook. Check the `stripe_products` table to confirm the record has been written.
|
|
46
|
+
|
|
47
|
+
> [!TIP]
|
|
48
|
+
> You can use AI to generate the complete set of `upsert-product` commands and execute them in batch.
|
|
49
|
+
|
|
50
|
+
##### Method 2: Create via Stripe Console
|
|
51
|
+
|
|
52
|
+
1. Find the target `sku id` in the database's `logto_skus` table.
|
|
53
|
+
2. In Stripe Console's Test mode, create a new product with:
|
|
54
|
+
- **Product name**: e.g., "Pro Plan 202509"
|
|
55
|
+
- **Pricing**: Set up monthly recurring pricing (or one-time for add-ons)
|
|
56
|
+
- **Metadata**: **Crucially**, add a metadata field with key `logtoSkuId` and value matching the SKU ID from step 1 (e.g., `pro-202509`)
|
|
57
|
+
3. Keep `stripe listen` running. The product creation event will be forwarded to your local webhook endpoint and automatically sync to the `stripe_products` table.
|
|
58
|
+
4. Verify the record in the `stripe_products` table to confirm the association.
|
|
59
|
+
|
|
60
|
+
> [!IMPORTANT]
|
|
61
|
+
> The webhook relies on the `logtoSkuId` metadata field to associate the Stripe product with the corresponding Logto SKU. Without this metadata, the webhook will fail.
|
|
62
|
+
|
|
63
|
+
Once all SKU product associations are complete, you can develop and debug Subscription-related features locally.
|