@stravigor/cashier 0.4.4 → 0.4.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.
Files changed (2) hide show
  1. package/README.md +71 -0
  2. package/package.json +2 -2
package/README.md ADDED
@@ -0,0 +1,71 @@
1
+ # @stravigor/cashier
2
+
3
+ Stripe billing for the [Strav](https://www.npmjs.com/package/@stravigor/core) framework. Subscriptions, one-time charges, checkout sessions, invoices, payment methods, and webhooks.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ bun add @stravigor/cashier
9
+ bun strav package:install cashier
10
+ ```
11
+
12
+ Requires `@stravigor/core` as a peer dependency.
13
+
14
+ ## Setup
15
+
16
+ ```ts
17
+ import { CashierProvider } from '@stravigor/cashier'
18
+
19
+ app.use(new CashierProvider())
20
+ ```
21
+
22
+ ## Usage
23
+
24
+ ```ts
25
+ import { cashier } from '@stravigor/cashier'
26
+
27
+ // Create a customer
28
+ const customer = await cashier.createCustomer(user)
29
+
30
+ // Start a subscription
31
+ const subscription = await cashier
32
+ .newSubscription('default', 'price_xxx')
33
+ .create(user)
34
+
35
+ // Checkout session
36
+ const checkout = await cashier
37
+ .checkout(user, 'price_xxx')
38
+ .successUrl('/success')
39
+ .cancelUrl('/cancel')
40
+ .create()
41
+ ```
42
+
43
+ ## Billable Mixin
44
+
45
+ ```ts
46
+ import { billable } from '@stravigor/cashier'
47
+
48
+ class User extends billable(BaseModel) {
49
+ // adds subscription, invoice, and payment helpers
50
+ }
51
+ ```
52
+
53
+ ## Webhooks
54
+
55
+ ```ts
56
+ import { stripeWebhook, onWebhookEvent } from '@stravigor/cashier'
57
+
58
+ onWebhookEvent('customer.subscription.updated', async (event) => {
59
+ // handle subscription changes
60
+ })
61
+
62
+ router.post('/stripe/webhook', stripeWebhook())
63
+ ```
64
+
65
+ ## Documentation
66
+
67
+ See the full [Cashier guide](../../guides/cashier.md).
68
+
69
+ ## License
70
+
71
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stravigor/cashier",
3
- "version": "0.4.4",
3
+ "version": "0.4.5",
4
4
  "type": "module",
5
5
  "description": "Stripe billing for the Strav framework",
6
6
  "license": "MIT",
@@ -15,7 +15,7 @@
15
15
  "tsconfig.json"
16
16
  ],
17
17
  "peerDependencies": {
18
- "@stravigor/core": "0.4.3"
18
+ "@stravigor/core": "0.4.4"
19
19
  },
20
20
  "dependencies": {
21
21
  "stripe": "^17.4.0"