@raideno/convex-stripe 0.3.3 → 0.3.5
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 +30 -33
- package/dist/index.d.ts +306 -35
- package/dist/server.js +186 -399
- package/package.json +5 -4
package/README.md
CHANGED
|
@@ -17,9 +17,9 @@ Stripe [syncing](./documentation/references/tables.md), subscriptions, [checkout
|
|
|
17
17
|
- [7. Run the `sync` Action](#7-run-the-sync-action)
|
|
18
18
|
- [8. Start Building](#8-start-building)
|
|
19
19
|
- [Configuration](#configuration)
|
|
20
|
+
- [Schema Configuration](#schema-configuration)
|
|
20
21
|
- [Stripe Configuration](#stripe-configuration)
|
|
21
22
|
- [Sync Configuration](#sync-configuration)
|
|
22
|
-
- [Table Selection](#table-selection)
|
|
23
23
|
- [Catalog (Unstable)](#catalog-unstable)
|
|
24
24
|
- [Webhook Configuration](#webhook-configuration)
|
|
25
25
|
- [Portal Configuration](#portal-configuration)
|
|
@@ -99,6 +99,22 @@ export default defineSchema({
|
|
|
99
99
|
});
|
|
100
100
|
```
|
|
101
101
|
|
|
102
|
+
If you only want to sync specific tables and avoid creating empty tables in your database, you can use the `allStripeTablesExcept` or `onlyStripeTables` helpers instead of `stripeTables`:
|
|
103
|
+
|
|
104
|
+
```ts
|
|
105
|
+
// convex/schema.ts
|
|
106
|
+
|
|
107
|
+
import { defineSchema } from "convex/server";
|
|
108
|
+
import { onlyStripeTables } from "@raideno/convex-stripe/server";
|
|
109
|
+
|
|
110
|
+
export default defineSchema({
|
|
111
|
+
...onlyStripeTables(["stripeCustomers", "stripeSubscriptions", "stripeProducts", "stripePrices"]),
|
|
112
|
+
// your other tables...
|
|
113
|
+
});
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
The package will only sync the tables you defined.
|
|
117
|
+
|
|
102
118
|
See [Tables Reference](./documentation/references/tables.md) for the full list of tables and their schemas.
|
|
103
119
|
|
|
104
120
|
### 4. Initialize the Library
|
|
@@ -108,16 +124,16 @@ Call `internalConvexStripe` with your Stripe credentials and sync configuration.
|
|
|
108
124
|
```ts
|
|
109
125
|
// convex/stripe.ts
|
|
110
126
|
|
|
111
|
-
import { internalConvexStripe
|
|
127
|
+
import { internalConvexStripe } from "@raideno/convex-stripe/server";
|
|
128
|
+
|
|
129
|
+
import schema from "./schema";
|
|
112
130
|
|
|
113
131
|
export const { stripe, store, sync } = internalConvexStripe({
|
|
132
|
+
schema: schema,
|
|
114
133
|
stripe: {
|
|
115
134
|
secret_key: process.env.STRIPE_SECRET_KEY!,
|
|
116
135
|
account_webhook_secret: process.env.STRIPE_ACCOUNT_WEBHOOK_SECRET!,
|
|
117
136
|
},
|
|
118
|
-
sync: {
|
|
119
|
-
tables: syncAllTables(),
|
|
120
|
-
},
|
|
121
137
|
});
|
|
122
138
|
```
|
|
123
139
|
|
|
@@ -243,6 +259,9 @@ The `internalConvexStripe` function accepts a configuration object and an option
|
|
|
243
259
|
```ts
|
|
244
260
|
const { stripe, store, sync } = internalConvexStripe(configuration, options);
|
|
245
261
|
```
|
|
262
|
+
### Schema Configuration
|
|
263
|
+
|
|
264
|
+
The `schema` key holds your convex app schema, from it the package will infer which stripe tables should be synced or not depending on what stripeTables where defined.
|
|
246
265
|
|
|
247
266
|
### Stripe Configuration
|
|
248
267
|
|
|
@@ -259,29 +278,6 @@ The `stripe` key in the configuration object holds your Stripe credentials and A
|
|
|
259
278
|
|
|
260
279
|
The `sync` key controls which tables are synced and allows you to define catalog items, webhook endpoints, and billing portal configuration.
|
|
261
280
|
|
|
262
|
-
#### Table Selection
|
|
263
|
-
|
|
264
|
-
Three helper functions are provided to control which Stripe tables are synced into Convex:
|
|
265
|
-
|
|
266
|
-
```ts
|
|
267
|
-
import {
|
|
268
|
-
syncAllTables,
|
|
269
|
-
syncAllTablesExcept,
|
|
270
|
-
syncOnlyTables,
|
|
271
|
-
} from "@raideno/convex-stripe/server";
|
|
272
|
-
|
|
273
|
-
// Sync all 24 tables (default)
|
|
274
|
-
{ tables: syncAllTables() }
|
|
275
|
-
|
|
276
|
-
// Sync all tables except specific ones
|
|
277
|
-
{ tables: syncAllTablesExcept(["stripeReviews", "stripePlans"]) }
|
|
278
|
-
|
|
279
|
-
// Sync only specific tables
|
|
280
|
-
{ tables: syncOnlyTables(["stripeCustomers", "stripeSubscriptions", "stripeProducts", "stripePrices"]) }
|
|
281
|
-
```
|
|
282
|
-
|
|
283
|
-
All 24 available tables are listed in the [Synced Tables](#synced-tables) section.
|
|
284
|
-
|
|
285
281
|
#### Catalog (Unstable)
|
|
286
282
|
|
|
287
283
|
The `sync.catalog` key lets you pre-define products and prices that should exist in Stripe. When the `sync` action is called with `{ catalog: true }`, the library ensures these objects exist in your Stripe account.
|
|
@@ -290,7 +286,6 @@ The `sync.catalog` key lets you pre-define products and prices that should exist
|
|
|
290
286
|
internalConvexStripe({
|
|
291
287
|
// ...
|
|
292
288
|
sync: {
|
|
293
|
-
tables: syncAllTables(),
|
|
294
289
|
catalog: {
|
|
295
290
|
products: [
|
|
296
291
|
{ name: "Pro Plan", metadata: { convex_stripe_key: "pro" } },
|
|
@@ -485,15 +480,17 @@ Then update your configuration to include it:
|
|
|
485
480
|
```ts
|
|
486
481
|
// convex/stripe.ts
|
|
487
482
|
|
|
483
|
+
import { internalConvexStripe } from "@raideno/convex-stripe/server";
|
|
484
|
+
|
|
485
|
+
import schema from "./schema";
|
|
486
|
+
|
|
488
487
|
export const { stripe, store, sync } = internalConvexStripe({
|
|
488
|
+
schema: schema,
|
|
489
489
|
stripe: {
|
|
490
490
|
secret_key: process.env.STRIPE_SECRET_KEY!,
|
|
491
491
|
account_webhook_secret: process.env.STRIPE_ACCOUNT_WEBHOOK_SECRET!,
|
|
492
492
|
connect_webhook_secret: process.env.STRIPE_CONNECT_WEBHOOK_SECRET!,
|
|
493
|
-
}
|
|
494
|
-
sync: {
|
|
495
|
-
tables: syncAllTables(),
|
|
496
|
-
},
|
|
493
|
+
}
|
|
497
494
|
});
|
|
498
495
|
```
|
|
499
496
|
|