@emulators/stripe 0.4.0 → 0.5.0

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 ADDED
@@ -0,0 +1,84 @@
1
+ # @emulators/stripe
2
+
3
+ Stripe API emulation with customers, payment methods, customer sessions, payment intents, charges, products, prices, and checkout sessions. Includes a hosted checkout page and webhook delivery.
4
+
5
+ Part of [emulate](https://github.com/vercel-labs/emulate) — local drop-in replacement services for CI and no-network sandboxes.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm install @emulators/stripe
11
+ ```
12
+
13
+ ## Endpoints
14
+
15
+ ### Customers
16
+ - `POST /v1/customers` — create customer
17
+ - `GET /v1/customers/:id` — retrieve customer
18
+ - `POST /v1/customers/:id` — update customer
19
+ - `DELETE /v1/customers/:id` — delete customer
20
+ - `GET /v1/customers` — list customers
21
+
22
+ ### Payment Methods
23
+ - `GET /v1/payment_methods` — list payment methods
24
+
25
+ ### Customer Sessions
26
+ - `POST /v1/customer_sessions` — create customer session
27
+
28
+ ### Payment Intents
29
+ - `POST /v1/payment_intents` — create payment intent
30
+ - `GET /v1/payment_intents/:id` — retrieve payment intent
31
+ - `POST /v1/payment_intents/:id` — update payment intent
32
+ - `POST /v1/payment_intents/:id/confirm` — confirm payment intent
33
+ - `POST /v1/payment_intents/:id/cancel` — cancel payment intent
34
+ - `GET /v1/payment_intents` — list payment intents
35
+
36
+ ### Charges
37
+ - `GET /v1/charges/:id` — retrieve charge
38
+ - `GET /v1/charges` — list charges
39
+
40
+ ### Products
41
+ - `POST /v1/products` — create product
42
+ - `GET /v1/products/:id` — retrieve product
43
+ - `GET /v1/products` — list products
44
+
45
+ ### Prices
46
+ - `POST /v1/prices` — create price
47
+ - `GET /v1/prices/:id` — retrieve price
48
+ - `GET /v1/prices` — list prices
49
+
50
+ ### Checkout Sessions
51
+ - `POST /v1/checkout/sessions` — create checkout session
52
+ - `GET /v1/checkout/sessions/:id` — retrieve session
53
+ - `POST /v1/checkout/sessions/:id/expire` — expire session
54
+ - `GET /v1/checkout/sessions` — list sessions (filter by `customer`, `status`, `payment_status`)
55
+ - `GET /checkout/:id` — hosted checkout page (HTML)
56
+ - `POST /checkout/:id/complete` — complete payment flow
57
+
58
+ ## Webhooks
59
+
60
+ Events are delivered to configured webhook URLs:
61
+ - `checkout.session.completed` — when a checkout session is completed
62
+ - `checkout.session.expired` — when a checkout session expires
63
+
64
+ ## Seed Configuration
65
+
66
+ ```yaml
67
+ stripe:
68
+ customers:
69
+ - name: Test Customer
70
+ email: test@example.com
71
+ products:
72
+ - name: Pro Plan
73
+ prices:
74
+ - product: Pro Plan
75
+ unit_amount: 2000
76
+ currency: usd
77
+ recurring:
78
+ interval: month
79
+ ```
80
+
81
+ ## Links
82
+
83
+ - [Full documentation](https://emulate.dev)
84
+ - [GitHub](https://github.com/vercel-labs/emulate)
Binary file
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Entity, Collection, Store, ServicePlugin } from '@emulators/core';
1
+ import { Entity, Collection, Store, ServicePlugin, WebhookDispatcher } from '@emulators/core';
2
2
 
3
3
  interface StripeCustomer extends Entity {
4
4
  stripe_id: string;
@@ -72,21 +72,29 @@ declare function getStripeStore(store: Store): StripeStore;
72
72
  interface StripeSeedConfig {
73
73
  port?: number;
74
74
  customers?: Array<{
75
+ id?: string;
75
76
  email?: string;
76
77
  name?: string;
77
78
  description?: string;
78
79
  }>;
79
80
  products?: Array<{
81
+ id?: string;
80
82
  name: string;
81
83
  description?: string;
82
84
  }>;
83
85
  prices?: Array<{
86
+ id?: string;
84
87
  product_name: string;
85
88
  currency: string;
86
89
  unit_amount: number;
87
90
  }>;
91
+ webhooks?: Array<{
92
+ url: string;
93
+ events: string[];
94
+ secret?: string;
95
+ }>;
88
96
  }
89
- declare function seedFromConfig(store: Store, _baseUrl: string, config: StripeSeedConfig): void;
97
+ declare function seedFromConfig(store: Store, _baseUrl: string, config: StripeSeedConfig, webhooks?: WebhookDispatcher): void;
90
98
  declare const stripePlugin: ServicePlugin;
91
99
 
92
100
  export { type PaymentIntentStatus, type StripeCharge, type StripeCheckoutSession, type StripeCustomer, type StripePaymentIntent, type StripePrice, type StripeProduct, type StripeSeedConfig, type StripeStore, stripePlugin as default, getStripeStore, seedFromConfig, stripePlugin };