alchemy 0.24.0 → 0.24.1
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/lib/aws/function.d.ts.map +1 -1
- package/lib/aws/function.js +1 -4
- package/lib/aws/function.js.map +1 -1
- package/lib/cloudflare/bindings.d.ts +3 -3
- package/lib/cloudflare/bindings.d.ts.map +1 -1
- package/lib/cloudflare/bindings.js.map +1 -1
- package/lib/cloudflare/bound.d.ts +3 -3
- package/lib/cloudflare/bound.d.ts.map +1 -1
- package/lib/cloudflare/do-state-store/index.d.ts +2 -0
- package/lib/cloudflare/do-state-store/index.d.ts.map +1 -0
- package/lib/cloudflare/do-state-store/index.js +2 -0
- package/lib/cloudflare/do-state-store/index.js.map +1 -0
- package/lib/cloudflare/do-state-store/internal.d.ts +19 -0
- package/lib/cloudflare/do-state-store/internal.d.ts.map +1 -0
- package/lib/cloudflare/do-state-store/internal.js +163 -0
- package/lib/cloudflare/do-state-store/internal.js.map +1 -0
- package/lib/cloudflare/do-state-store/store.d.ts +59 -0
- package/lib/cloudflare/do-state-store/store.d.ts.map +1 -0
- package/lib/cloudflare/do-state-store/store.js +120 -0
- package/lib/cloudflare/do-state-store/store.js.map +1 -0
- package/lib/cloudflare/do-state-store/types.d.ts +82 -0
- package/lib/cloudflare/do-state-store/types.d.ts.map +1 -0
- package/lib/cloudflare/do-state-store/types.js +1 -0
- package/lib/cloudflare/do-state-store/types.js.map +1 -0
- package/lib/cloudflare/do-state-store/worker.d.ts +27 -0
- package/lib/cloudflare/do-state-store/worker.d.ts.map +1 -0
- package/lib/cloudflare/do-state-store/worker.js +170 -0
- package/lib/cloudflare/do-state-store/worker.js.map +1 -0
- package/lib/cloudflare/index.d.ts +1 -0
- package/lib/cloudflare/index.d.ts.map +1 -1
- package/lib/cloudflare/index.js +1 -0
- package/lib/cloudflare/index.js.map +1 -1
- package/lib/cloudflare/pipeline.js +1 -1
- package/lib/cloudflare/pipeline.js.map +1 -1
- package/lib/cloudflare/queue-consumer.d.ts +14 -1
- package/lib/cloudflare/queue-consumer.d.ts.map +1 -1
- package/lib/cloudflare/queue-consumer.js +17 -0
- package/lib/cloudflare/queue-consumer.js.map +1 -1
- package/lib/cloudflare/website.d.ts +30 -1
- package/lib/cloudflare/website.d.ts.map +1 -1
- package/lib/cloudflare/website.js +8 -5
- package/lib/cloudflare/website.js.map +1 -1
- package/lib/cloudflare/worker-metadata.js +1 -1
- package/lib/cloudflare/worker-metadata.js.map +1 -1
- package/lib/cloudflare/worker.d.ts +40 -1
- package/lib/cloudflare/worker.d.ts.map +1 -1
- package/lib/cloudflare/worker.js +40 -38
- package/lib/cloudflare/worker.js.map +1 -1
- package/lib/cloudflare/wrangler.json.js +1 -1
- package/lib/cloudflare/wrangler.json.js.map +1 -1
- package/lib/fs/file-system-state-store.d.ts +3 -1
- package/lib/fs/file-system-state-store.d.ts.map +1 -1
- package/lib/fs/file-system-state-store.js +2 -2
- package/lib/fs/file-system-state-store.js.map +1 -1
- package/lib/stripe/card.d.ts +171 -0
- package/lib/stripe/card.d.ts.map +1 -0
- package/lib/stripe/card.js +148 -0
- package/lib/stripe/card.js.map +1 -0
- package/lib/stripe/client.d.ts +9 -0
- package/lib/stripe/client.d.ts.map +1 -0
- package/lib/stripe/client.js +94 -0
- package/lib/stripe/client.js.map +1 -0
- package/lib/stripe/coupon.d.ts +135 -0
- package/lib/stripe/coupon.d.ts.map +1 -0
- package/lib/stripe/coupon.js +161 -0
- package/lib/stripe/coupon.js.map +1 -0
- package/lib/stripe/customer.d.ts +269 -0
- package/lib/stripe/customer.d.ts.map +1 -0
- package/lib/stripe/customer.js +289 -0
- package/lib/stripe/customer.js.map +1 -0
- package/lib/stripe/entitlements-feature.d.ts +84 -0
- package/lib/stripe/entitlements-feature.d.ts.map +1 -0
- package/lib/stripe/entitlements-feature.js +102 -0
- package/lib/stripe/entitlements-feature.js.map +1 -0
- package/lib/stripe/file.d.ts +143 -0
- package/lib/stripe/file.d.ts.map +1 -0
- package/lib/stripe/file.js +97 -0
- package/lib/stripe/file.js.map +1 -0
- package/lib/stripe/index.d.ts +11 -0
- package/lib/stripe/index.d.ts.map +1 -1
- package/lib/stripe/index.js +11 -0
- package/lib/stripe/index.js.map +1 -1
- package/lib/stripe/meter.d.ts +10 -1
- package/lib/stripe/meter.d.ts.map +1 -1
- package/lib/stripe/meter.js +13 -7
- package/lib/stripe/meter.js.map +1 -1
- package/lib/stripe/portal-configuration.d.ts +286 -0
- package/lib/stripe/portal-configuration.d.ts.map +1 -0
- package/lib/stripe/portal-configuration.js +320 -0
- package/lib/stripe/portal-configuration.js.map +1 -0
- package/lib/stripe/price.d.ts +10 -1
- package/lib/stripe/price.d.ts.map +1 -1
- package/lib/stripe/price.js +34 -13
- package/lib/stripe/price.js.map +1 -1
- package/lib/stripe/product-feature.d.ts +76 -0
- package/lib/stripe/product-feature.d.ts.map +1 -0
- package/lib/stripe/product-feature.js +74 -0
- package/lib/stripe/product-feature.js.map +1 -0
- package/lib/stripe/product.d.ts +10 -1
- package/lib/stripe/product.d.ts.map +1 -1
- package/lib/stripe/product.js +33 -14
- package/lib/stripe/product.js.map +1 -1
- package/lib/stripe/promotion-code.d.ts +138 -0
- package/lib/stripe/promotion-code.d.ts.map +1 -0
- package/lib/stripe/promotion-code.js +150 -0
- package/lib/stripe/promotion-code.js.map +1 -0
- package/lib/stripe/shipping-rate.d.ts +188 -0
- package/lib/stripe/shipping-rate.d.ts.map +1 -0
- package/lib/stripe/shipping-rate.js +198 -0
- package/lib/stripe/shipping-rate.js.map +1 -0
- package/lib/stripe/tax-rate.d.ts +130 -0
- package/lib/stripe/tax-rate.d.ts.map +1 -0
- package/lib/stripe/tax-rate.js +126 -0
- package/lib/stripe/tax-rate.js.map +1 -0
- package/lib/stripe/webhook.d.ts +10 -1
- package/lib/stripe/webhook.d.ts.map +1 -1
- package/lib/stripe/webhook.js +59 -14
- package/lib/stripe/webhook.js.map +1 -1
- package/lib/test/bun.d.ts.map +1 -1
- package/lib/test/bun.js +2 -6
- package/lib/test/bun.js.map +1 -1
- package/lib/test/vitest.d.ts.map +1 -1
- package/lib/test/vitest.js +3 -7
- package/lib/test/vitest.js.map +1 -1
- package/lib/util/retry.d.ts +1 -1
- package/lib/util/retry.d.ts.map +1 -1
- package/lib/util/retry.js.map +1 -1
- package/package.json +2 -1
- package/src/aws/function.ts +3 -6
- package/src/cloudflare/bindings.ts +3 -2
- package/src/cloudflare/bound.ts +3 -3
- package/src/cloudflare/do-state-store/index.ts +1 -0
- package/src/cloudflare/do-state-store/internal.ts +215 -0
- package/src/cloudflare/do-state-store/store.ts +188 -0
- package/src/cloudflare/do-state-store/types.ts +74 -0
- package/src/cloudflare/do-state-store/worker.ts +199 -0
- package/src/cloudflare/index.ts +1 -0
- package/src/cloudflare/pipeline.ts +1 -1
- package/src/cloudflare/queue-consumer.ts +59 -1
- package/src/cloudflare/website.ts +38 -6
- package/src/cloudflare/worker-metadata.ts +1 -1
- package/src/cloudflare/worker.ts +66 -46
- package/src/cloudflare/wrangler.json.ts +1 -1
- package/src/fs/file-system-state-store.ts +7 -2
- package/src/stripe/card.ts +320 -0
- package/src/stripe/client.ts +145 -0
- package/src/stripe/coupon.ts +280 -0
- package/src/stripe/customer.ts +528 -0
- package/src/stripe/entitlements-feature.ts +169 -0
- package/src/stripe/file.ts +219 -0
- package/src/stripe/index.ts +11 -0
- package/src/stripe/meter.ts +23 -7
- package/src/stripe/portal-configuration.ts +609 -0
- package/src/stripe/price.ts +47 -14
- package/src/stripe/product-feature.ts +150 -0
- package/src/stripe/product.ts +48 -15
- package/src/stripe/promotion-code.ts +268 -0
- package/src/stripe/shipping-rate.ts +362 -0
- package/src/stripe/tax-rate.ts +218 -0
- package/src/stripe/webhook.ts +82 -15
- package/src/test/bun.ts +2 -7
- package/src/test/vitest.ts +3 -8
- package/src/util/retry.ts +1 -1
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
import type Stripe from "stripe";
|
|
2
|
+
import type { Context } from "../context.ts";
|
|
3
|
+
import { Resource } from "../resource.ts";
|
|
4
|
+
import type { Secret } from "../secret.ts";
|
|
5
|
+
/**
|
|
6
|
+
* Customer address information
|
|
7
|
+
*/
|
|
8
|
+
export interface CustomerAddress {
|
|
9
|
+
/**
|
|
10
|
+
* City, district, suburb, town, or village
|
|
11
|
+
*/
|
|
12
|
+
city?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Two-letter country code (ISO 3166-1 alpha-2)
|
|
15
|
+
*/
|
|
16
|
+
country?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Address line 1 (e.g., street, PO Box, or company name)
|
|
19
|
+
*/
|
|
20
|
+
line1?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Address line 2 (e.g., apartment, suite, unit, or building)
|
|
23
|
+
*/
|
|
24
|
+
line2?: string;
|
|
25
|
+
/**
|
|
26
|
+
* ZIP or postal code
|
|
27
|
+
*/
|
|
28
|
+
postalCode?: string;
|
|
29
|
+
/**
|
|
30
|
+
* State, county, province, or region
|
|
31
|
+
*/
|
|
32
|
+
state?: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Customer shipping information
|
|
36
|
+
*/
|
|
37
|
+
export interface CustomerShipping {
|
|
38
|
+
/**
|
|
39
|
+
* Customer's shipping address
|
|
40
|
+
*/
|
|
41
|
+
address?: CustomerAddress;
|
|
42
|
+
/**
|
|
43
|
+
* Customer name
|
|
44
|
+
*/
|
|
45
|
+
name?: string;
|
|
46
|
+
/**
|
|
47
|
+
* Customer phone number
|
|
48
|
+
*/
|
|
49
|
+
phone?: string;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Customer invoice settings
|
|
53
|
+
*/
|
|
54
|
+
export interface CustomerInvoiceSettings {
|
|
55
|
+
/**
|
|
56
|
+
* Default custom fields to be displayed on invoices for this customer
|
|
57
|
+
*/
|
|
58
|
+
customFields?: Array<{
|
|
59
|
+
name: string;
|
|
60
|
+
value: string;
|
|
61
|
+
}>;
|
|
62
|
+
/**
|
|
63
|
+
* ID of a payment method that's attached to the customer, to be used as the customer's default payment method for subscriptions and invoices
|
|
64
|
+
*/
|
|
65
|
+
defaultPaymentMethod?: string;
|
|
66
|
+
/**
|
|
67
|
+
* Default footer to be displayed on invoices for this customer
|
|
68
|
+
*/
|
|
69
|
+
footer?: string;
|
|
70
|
+
/**
|
|
71
|
+
* Default options for invoice PDF rendering for this customer
|
|
72
|
+
*/
|
|
73
|
+
renderingOptions?: {
|
|
74
|
+
amountTaxDisplay?: Stripe.CustomerCreateParams.InvoiceSettings.RenderingOptions.AmountTaxDisplay;
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Properties for creating a Stripe customer
|
|
79
|
+
*/
|
|
80
|
+
export interface CustomerProps {
|
|
81
|
+
/**
|
|
82
|
+
* The customer's address
|
|
83
|
+
*/
|
|
84
|
+
address?: CustomerAddress;
|
|
85
|
+
/**
|
|
86
|
+
* An integer amount in cents that represents the customer's current balance
|
|
87
|
+
*/
|
|
88
|
+
balance?: number;
|
|
89
|
+
/**
|
|
90
|
+
* If you provide a coupon code, the customer will have a discount applied on all recurring charges
|
|
91
|
+
*/
|
|
92
|
+
coupon?: string;
|
|
93
|
+
/**
|
|
94
|
+
* An arbitrary string attached to the object
|
|
95
|
+
*/
|
|
96
|
+
description?: string;
|
|
97
|
+
/**
|
|
98
|
+
* Customer's email address
|
|
99
|
+
*/
|
|
100
|
+
email?: string;
|
|
101
|
+
/**
|
|
102
|
+
* The prefix for the customer used to generate unique invoice numbers
|
|
103
|
+
*/
|
|
104
|
+
invoicePrefix?: string;
|
|
105
|
+
/**
|
|
106
|
+
* Default invoice settings for this customer
|
|
107
|
+
*/
|
|
108
|
+
invoiceSettings?: CustomerInvoiceSettings;
|
|
109
|
+
/**
|
|
110
|
+
* Set of key-value pairs that you can attach to an object
|
|
111
|
+
*/
|
|
112
|
+
metadata?: Record<string, string>;
|
|
113
|
+
/**
|
|
114
|
+
* The customer's full name or business name
|
|
115
|
+
*/
|
|
116
|
+
name?: string;
|
|
117
|
+
/**
|
|
118
|
+
* The sequence to be used on the customer's next invoice
|
|
119
|
+
*/
|
|
120
|
+
nextInvoiceSequence?: number;
|
|
121
|
+
/**
|
|
122
|
+
* The ID of the PaymentMethod to attach to the customer
|
|
123
|
+
*/
|
|
124
|
+
paymentMethod?: string;
|
|
125
|
+
/**
|
|
126
|
+
* The customer's phone number
|
|
127
|
+
*/
|
|
128
|
+
phone?: string;
|
|
129
|
+
/**
|
|
130
|
+
* Customer's preferred languages, ordered by preference
|
|
131
|
+
*/
|
|
132
|
+
preferredLocales?: string[];
|
|
133
|
+
/**
|
|
134
|
+
* The ID of a promotion code to apply to the customer
|
|
135
|
+
*/
|
|
136
|
+
promotionCode?: string;
|
|
137
|
+
/**
|
|
138
|
+
* The customer's shipping information
|
|
139
|
+
*/
|
|
140
|
+
shipping?: CustomerShipping;
|
|
141
|
+
/**
|
|
142
|
+
* When using a card as a source, you can pass the card information
|
|
143
|
+
*/
|
|
144
|
+
source?: string;
|
|
145
|
+
/**
|
|
146
|
+
* The customer's tax exemption status
|
|
147
|
+
*/
|
|
148
|
+
taxExempt?: Stripe.CustomerCreateParams.TaxExempt;
|
|
149
|
+
/**
|
|
150
|
+
* ID of the test clock to attach to the customer
|
|
151
|
+
*/
|
|
152
|
+
testClock?: string;
|
|
153
|
+
/**
|
|
154
|
+
* API key to use (overrides environment variable)
|
|
155
|
+
*/
|
|
156
|
+
apiKey?: Secret;
|
|
157
|
+
/**
|
|
158
|
+
* If true, adopt existing resource if creation fails due to conflict
|
|
159
|
+
*/
|
|
160
|
+
adopt?: boolean;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Output from the Stripe customer
|
|
164
|
+
*/
|
|
165
|
+
export interface Customer extends Resource<"stripe::Customer">, CustomerProps {
|
|
166
|
+
/**
|
|
167
|
+
* The ID of the customer
|
|
168
|
+
*/
|
|
169
|
+
id: string;
|
|
170
|
+
/**
|
|
171
|
+
* String representing the object's type
|
|
172
|
+
*/
|
|
173
|
+
object: "customer";
|
|
174
|
+
/**
|
|
175
|
+
* Time at which the object was created
|
|
176
|
+
*/
|
|
177
|
+
created: number;
|
|
178
|
+
/**
|
|
179
|
+
* Three-letter ISO code for the currency the customer can be charged in for recurring billing purposes
|
|
180
|
+
*/
|
|
181
|
+
currency?: string;
|
|
182
|
+
/**
|
|
183
|
+
* ID of the default payment source for the customer
|
|
184
|
+
*/
|
|
185
|
+
defaultSource?: string;
|
|
186
|
+
/**
|
|
187
|
+
* Whether or not the customer is currently delinquent
|
|
188
|
+
*/
|
|
189
|
+
delinquent?: boolean;
|
|
190
|
+
/**
|
|
191
|
+
* Describes the current discount active on the customer, if there is one
|
|
192
|
+
*/
|
|
193
|
+
discount?: any;
|
|
194
|
+
/**
|
|
195
|
+
* Has the value true if the object exists in live mode or the value false if the object exists in test mode
|
|
196
|
+
*/
|
|
197
|
+
livemode: boolean;
|
|
198
|
+
/**
|
|
199
|
+
* The customer's payment sources, if any
|
|
200
|
+
*/
|
|
201
|
+
sources?: any;
|
|
202
|
+
/**
|
|
203
|
+
* The customer's current subscriptions, if any
|
|
204
|
+
*/
|
|
205
|
+
subscriptions?: any;
|
|
206
|
+
/**
|
|
207
|
+
* The customer's tax IDs, if any
|
|
208
|
+
*/
|
|
209
|
+
taxIds?: any;
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Create and manage Stripe customers
|
|
213
|
+
*
|
|
214
|
+
* @example
|
|
215
|
+
* // Create a basic customer
|
|
216
|
+
* const basicCustomer = await Customer("basic-customer", {
|
|
217
|
+
* email: "john@example.com",
|
|
218
|
+
* name: "John Doe",
|
|
219
|
+
* description: "Premium customer",
|
|
220
|
+
* metadata: {
|
|
221
|
+
* tier: "premium",
|
|
222
|
+
* source: "website"
|
|
223
|
+
* }
|
|
224
|
+
* });
|
|
225
|
+
*
|
|
226
|
+
* @example
|
|
227
|
+
* // Create a customer with full address information
|
|
228
|
+
* const customerWithAddress = await Customer("customer-with-address", {
|
|
229
|
+
* email: "jane@example.com",
|
|
230
|
+
* name: "Jane Smith",
|
|
231
|
+
* phone: "+1-555-123-4567",
|
|
232
|
+
* address: {
|
|
233
|
+
* line1: "123 Main St",
|
|
234
|
+
* line2: "Apt 4B",
|
|
235
|
+
* city: "San Francisco",
|
|
236
|
+
* state: "CA",
|
|
237
|
+
* postalCode: "94105",
|
|
238
|
+
* country: "US"
|
|
239
|
+
* },
|
|
240
|
+
* shipping: {
|
|
241
|
+
* name: "Jane Smith",
|
|
242
|
+
* address: {
|
|
243
|
+
* line1: "456 Oak Ave",
|
|
244
|
+
* city: "Oakland",
|
|
245
|
+
* state: "CA",
|
|
246
|
+
* postalCode: "94612",
|
|
247
|
+
* country: "US"
|
|
248
|
+
* }
|
|
249
|
+
* }
|
|
250
|
+
* });
|
|
251
|
+
*
|
|
252
|
+
* @example
|
|
253
|
+
* // Create a business customer with tax exemption
|
|
254
|
+
* const businessCustomer = await Customer("business-customer", {
|
|
255
|
+
* email: "billing@acmecorp.com",
|
|
256
|
+
* name: "Acme Corporation",
|
|
257
|
+
* description: "Enterprise customer",
|
|
258
|
+
* taxExempt: "exempt",
|
|
259
|
+
* invoicePrefix: "ACME",
|
|
260
|
+
* preferredLocales: ["en"],
|
|
261
|
+
* metadata: {
|
|
262
|
+
* type: "business",
|
|
263
|
+
* industry: "technology",
|
|
264
|
+
* employees: "500+"
|
|
265
|
+
* }
|
|
266
|
+
* });
|
|
267
|
+
*/
|
|
268
|
+
export declare const Customer: (((this: any, id: string, props?: {}) => never) & (new (_: never) => never)) | ((this: Context<Customer>, _id: string, props: CustomerProps) => Promise<Customer>);
|
|
269
|
+
//# sourceMappingURL=customer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"customer.d.ts","sourceRoot":"","sources":["../../src/stripe/customer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAA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CAAC;IACvB;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;OAEG;IACH,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf;;OAEG;IACH,QAAQ,EAAE,OAAO,CAAC;IAClB;;OAEG;IACH,OAAO,CAAC,EAAE,GAAG,CAAC;IACd;;OAEG;IACH,aAAa,CAAC,EAAE,GAAG,CAAC;IACpB;;OAEG;IACH,MAAM,CAAC,EAAE,GAAG,CAAC;CACd;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AACH,eAAO,MAAM,QAAQ,yFAGX,OAAO,CAAC,QAAQ,CAAC,OAClB,MAAM,SACJ,aAAa,KACnB,OAAO,CAAC,QAAQ,CAAC,CAqPrB,CAAC"}
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
import { Resource } from "../resource.js";
|
|
2
|
+
import { createStripeClient, handleStripeDeleteError } from "./client.js";
|
|
3
|
+
/**
|
|
4
|
+
* Create and manage Stripe customers
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* // Create a basic customer
|
|
8
|
+
* const basicCustomer = await Customer("basic-customer", {
|
|
9
|
+
* email: "john@example.com",
|
|
10
|
+
* name: "John Doe",
|
|
11
|
+
* description: "Premium customer",
|
|
12
|
+
* metadata: {
|
|
13
|
+
* tier: "premium",
|
|
14
|
+
* source: "website"
|
|
15
|
+
* }
|
|
16
|
+
* });
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* // Create a customer with full address information
|
|
20
|
+
* const customerWithAddress = await Customer("customer-with-address", {
|
|
21
|
+
* email: "jane@example.com",
|
|
22
|
+
* name: "Jane Smith",
|
|
23
|
+
* phone: "+1-555-123-4567",
|
|
24
|
+
* address: {
|
|
25
|
+
* line1: "123 Main St",
|
|
26
|
+
* line2: "Apt 4B",
|
|
27
|
+
* city: "San Francisco",
|
|
28
|
+
* state: "CA",
|
|
29
|
+
* postalCode: "94105",
|
|
30
|
+
* country: "US"
|
|
31
|
+
* },
|
|
32
|
+
* shipping: {
|
|
33
|
+
* name: "Jane Smith",
|
|
34
|
+
* address: {
|
|
35
|
+
* line1: "456 Oak Ave",
|
|
36
|
+
* city: "Oakland",
|
|
37
|
+
* state: "CA",
|
|
38
|
+
* postalCode: "94612",
|
|
39
|
+
* country: "US"
|
|
40
|
+
* }
|
|
41
|
+
* }
|
|
42
|
+
* });
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* // Create a business customer with tax exemption
|
|
46
|
+
* const businessCustomer = await Customer("business-customer", {
|
|
47
|
+
* email: "billing@acmecorp.com",
|
|
48
|
+
* name: "Acme Corporation",
|
|
49
|
+
* description: "Enterprise customer",
|
|
50
|
+
* taxExempt: "exempt",
|
|
51
|
+
* invoicePrefix: "ACME",
|
|
52
|
+
* preferredLocales: ["en"],
|
|
53
|
+
* metadata: {
|
|
54
|
+
* type: "business",
|
|
55
|
+
* industry: "technology",
|
|
56
|
+
* employees: "500+"
|
|
57
|
+
* }
|
|
58
|
+
* });
|
|
59
|
+
*/
|
|
60
|
+
export const Customer = Resource("stripe::Customer", async function (_id, props) {
|
|
61
|
+
const stripe = createStripeClient({ apiKey: props.apiKey });
|
|
62
|
+
if (this.phase === "delete") {
|
|
63
|
+
try {
|
|
64
|
+
if (this.output?.id) {
|
|
65
|
+
await stripe.customers.del(this.output.id);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
handleStripeDeleteError(error, "Customer", this.output?.id);
|
|
70
|
+
}
|
|
71
|
+
return this.destroy();
|
|
72
|
+
}
|
|
73
|
+
try {
|
|
74
|
+
let customer;
|
|
75
|
+
if (this.phase === "update" && this.output?.id) {
|
|
76
|
+
const updateParams = {
|
|
77
|
+
address: props.address
|
|
78
|
+
? {
|
|
79
|
+
city: props.address.city,
|
|
80
|
+
country: props.address.country,
|
|
81
|
+
line1: props.address.line1,
|
|
82
|
+
line2: props.address.line2,
|
|
83
|
+
postal_code: props.address.postalCode,
|
|
84
|
+
state: props.address.state,
|
|
85
|
+
}
|
|
86
|
+
: undefined,
|
|
87
|
+
balance: props.balance,
|
|
88
|
+
coupon: props.coupon,
|
|
89
|
+
description: props.description,
|
|
90
|
+
email: props.email,
|
|
91
|
+
invoice_prefix: props.invoicePrefix,
|
|
92
|
+
metadata: props.metadata,
|
|
93
|
+
name: props.name,
|
|
94
|
+
next_invoice_sequence: props.nextInvoiceSequence,
|
|
95
|
+
phone: props.phone,
|
|
96
|
+
preferred_locales: props.preferredLocales,
|
|
97
|
+
promotion_code: props.promotionCode,
|
|
98
|
+
shipping: props.shipping,
|
|
99
|
+
source: props.source,
|
|
100
|
+
tax_exempt: props.taxExempt,
|
|
101
|
+
};
|
|
102
|
+
if (props.invoiceSettings) {
|
|
103
|
+
updateParams.invoice_settings = {
|
|
104
|
+
custom_fields: props.invoiceSettings.customFields,
|
|
105
|
+
default_payment_method: props.invoiceSettings.defaultPaymentMethod,
|
|
106
|
+
footer: props.invoiceSettings.footer,
|
|
107
|
+
rendering_options: props.invoiceSettings.renderingOptions
|
|
108
|
+
? {
|
|
109
|
+
amount_tax_display: props.invoiceSettings.renderingOptions.amountTaxDisplay,
|
|
110
|
+
}
|
|
111
|
+
: null,
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
customer = await stripe.customers.update(this.output.id, updateParams);
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
const createParams = {
|
|
118
|
+
address: props.address
|
|
119
|
+
? {
|
|
120
|
+
city: props.address.city,
|
|
121
|
+
country: props.address.country,
|
|
122
|
+
line1: props.address.line1,
|
|
123
|
+
line2: props.address.line2,
|
|
124
|
+
postal_code: props.address.postalCode,
|
|
125
|
+
state: props.address.state,
|
|
126
|
+
}
|
|
127
|
+
: undefined,
|
|
128
|
+
balance: props.balance,
|
|
129
|
+
coupon: props.coupon,
|
|
130
|
+
description: props.description,
|
|
131
|
+
email: props.email,
|
|
132
|
+
invoice_prefix: props.invoicePrefix,
|
|
133
|
+
metadata: props.metadata,
|
|
134
|
+
name: props.name,
|
|
135
|
+
next_invoice_sequence: props.nextInvoiceSequence,
|
|
136
|
+
payment_method: props.paymentMethod,
|
|
137
|
+
phone: props.phone,
|
|
138
|
+
preferred_locales: props.preferredLocales,
|
|
139
|
+
promotion_code: props.promotionCode,
|
|
140
|
+
shipping: props.shipping,
|
|
141
|
+
source: props.source,
|
|
142
|
+
tax_exempt: props.taxExempt,
|
|
143
|
+
test_clock: props.testClock,
|
|
144
|
+
};
|
|
145
|
+
if (props.invoiceSettings) {
|
|
146
|
+
createParams.invoice_settings = {
|
|
147
|
+
custom_fields: props.invoiceSettings.customFields,
|
|
148
|
+
default_payment_method: props.invoiceSettings.defaultPaymentMethod,
|
|
149
|
+
footer: props.invoiceSettings.footer,
|
|
150
|
+
rendering_options: props.invoiceSettings.renderingOptions
|
|
151
|
+
? {
|
|
152
|
+
amount_tax_display: props.invoiceSettings.renderingOptions.amountTaxDisplay,
|
|
153
|
+
}
|
|
154
|
+
: null,
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
if (props.adopt && props.email) {
|
|
158
|
+
const existingCustomers = await stripe.customers.list({
|
|
159
|
+
email: props.email,
|
|
160
|
+
limit: 1,
|
|
161
|
+
});
|
|
162
|
+
if (existingCustomers.data.length > 0) {
|
|
163
|
+
const existingCustomer = existingCustomers.data[0];
|
|
164
|
+
const adoptUpdateParams = {
|
|
165
|
+
address: props.address
|
|
166
|
+
? {
|
|
167
|
+
city: props.address.city,
|
|
168
|
+
country: props.address.country,
|
|
169
|
+
line1: props.address.line1,
|
|
170
|
+
line2: props.address.line2,
|
|
171
|
+
postal_code: props.address.postalCode,
|
|
172
|
+
state: props.address.state,
|
|
173
|
+
}
|
|
174
|
+
: undefined,
|
|
175
|
+
balance: props.balance,
|
|
176
|
+
coupon: props.coupon,
|
|
177
|
+
description: props.description,
|
|
178
|
+
email: props.email,
|
|
179
|
+
invoice_prefix: props.invoicePrefix,
|
|
180
|
+
metadata: props.metadata,
|
|
181
|
+
name: props.name,
|
|
182
|
+
next_invoice_sequence: props.nextInvoiceSequence,
|
|
183
|
+
phone: props.phone,
|
|
184
|
+
preferred_locales: props.preferredLocales,
|
|
185
|
+
promotion_code: props.promotionCode,
|
|
186
|
+
shipping: props.shipping,
|
|
187
|
+
source: props.source,
|
|
188
|
+
tax_exempt: props.taxExempt,
|
|
189
|
+
};
|
|
190
|
+
if (props.invoiceSettings) {
|
|
191
|
+
adoptUpdateParams.invoice_settings = {
|
|
192
|
+
custom_fields: props.invoiceSettings.customFields,
|
|
193
|
+
default_payment_method: props.invoiceSettings.defaultPaymentMethod,
|
|
194
|
+
footer: props.invoiceSettings.footer,
|
|
195
|
+
rendering_options: props.invoiceSettings.renderingOptions
|
|
196
|
+
? {
|
|
197
|
+
amount_tax_display: props.invoiceSettings.renderingOptions.amountTaxDisplay,
|
|
198
|
+
}
|
|
199
|
+
: null,
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
customer = await stripe.customers.update(existingCustomer.id, adoptUpdateParams);
|
|
203
|
+
}
|
|
204
|
+
else {
|
|
205
|
+
customer = await stripe.customers.create(createParams);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
else {
|
|
209
|
+
customer = await stripe.customers.create(createParams);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
return this({
|
|
213
|
+
id: customer.id,
|
|
214
|
+
object: customer.object,
|
|
215
|
+
address: customer.address
|
|
216
|
+
? {
|
|
217
|
+
city: customer.address.city || undefined,
|
|
218
|
+
country: customer.address.country || undefined,
|
|
219
|
+
line1: customer.address.line1 || undefined,
|
|
220
|
+
line2: customer.address.line2 || undefined,
|
|
221
|
+
postalCode: customer.address.postal_code || undefined,
|
|
222
|
+
state: customer.address.state || undefined,
|
|
223
|
+
}
|
|
224
|
+
: undefined,
|
|
225
|
+
balance: customer.balance || undefined,
|
|
226
|
+
created: customer.created,
|
|
227
|
+
currency: customer.currency || undefined,
|
|
228
|
+
defaultSource: typeof customer.default_source === "string"
|
|
229
|
+
? customer.default_source
|
|
230
|
+
: undefined,
|
|
231
|
+
delinquent: customer.delinquent || undefined,
|
|
232
|
+
description: customer.description || undefined,
|
|
233
|
+
discount: customer.discount || undefined,
|
|
234
|
+
email: customer.email || undefined,
|
|
235
|
+
invoicePrefix: customer.invoice_prefix || undefined,
|
|
236
|
+
invoiceSettings: customer.invoice_settings
|
|
237
|
+
? {
|
|
238
|
+
customFields: customer.invoice_settings.custom_fields?.map((field) => ({
|
|
239
|
+
name: field.name,
|
|
240
|
+
value: field.value,
|
|
241
|
+
})) || undefined,
|
|
242
|
+
defaultPaymentMethod: typeof customer.invoice_settings.default_payment_method ===
|
|
243
|
+
"string"
|
|
244
|
+
? customer.invoice_settings.default_payment_method
|
|
245
|
+
: customer.invoice_settings.default_payment_method?.id ||
|
|
246
|
+
undefined,
|
|
247
|
+
footer: customer.invoice_settings.footer || undefined,
|
|
248
|
+
renderingOptions: customer.invoice_settings.rendering_options
|
|
249
|
+
? {
|
|
250
|
+
amountTaxDisplay: customer.invoice_settings
|
|
251
|
+
.rendering_options.amount_tax_display,
|
|
252
|
+
}
|
|
253
|
+
: undefined,
|
|
254
|
+
}
|
|
255
|
+
: undefined,
|
|
256
|
+
livemode: customer.livemode,
|
|
257
|
+
metadata: customer.metadata || undefined,
|
|
258
|
+
name: customer.name || undefined,
|
|
259
|
+
nextInvoiceSequence: customer.next_invoice_sequence || undefined,
|
|
260
|
+
phone: customer.phone || undefined,
|
|
261
|
+
preferredLocales: customer.preferred_locales || undefined,
|
|
262
|
+
shipping: customer.shipping
|
|
263
|
+
? {
|
|
264
|
+
address: customer.shipping.address
|
|
265
|
+
? {
|
|
266
|
+
city: customer.shipping.address.city || undefined,
|
|
267
|
+
country: customer.shipping.address.country || undefined,
|
|
268
|
+
line1: customer.shipping.address.line1 || undefined,
|
|
269
|
+
line2: customer.shipping.address.line2 || undefined,
|
|
270
|
+
postalCode: customer.shipping.address.postal_code || undefined,
|
|
271
|
+
state: customer.shipping.address.state || undefined,
|
|
272
|
+
}
|
|
273
|
+
: undefined,
|
|
274
|
+
name: customer.shipping.name || undefined,
|
|
275
|
+
phone: customer.shipping.phone || undefined,
|
|
276
|
+
}
|
|
277
|
+
: undefined,
|
|
278
|
+
sources: customer.sources || undefined,
|
|
279
|
+
subscriptions: customer.subscriptions || undefined,
|
|
280
|
+
taxExempt: customer.tax_exempt || undefined,
|
|
281
|
+
taxIds: customer.tax_ids || undefined,
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
catch (error) {
|
|
285
|
+
console.error("Error creating/updating customer:", error);
|
|
286
|
+
throw error;
|
|
287
|
+
}
|
|
288
|
+
});
|
|
289
|
+
//# sourceMappingURL=customer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"customer.js","sourceRoot":"","sources":["../../src/stripe/customer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,OAAO,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAuN1E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,QAAQ,CAC9B,kBAAkB,EAClB,KAAK,WAEH,GAAW,EACX,KAAoB;IAEpB,MAAM,MAAM,GAAG,kBAAkB,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;IAE5D,IAAI,IAAI,CAAC,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC5B,IAAI,CAAC;YACH,IAAI,IAAI,CAAC,MAAM,EAAE,EAAE,EAAE,CAAC;gBACpB,MAAM,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;YAC7C,CAAC;QACH,CAAC;QA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AAC,CAAC;QAC1D,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC,CACF,CAAC"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { Context } from "../context.ts";
|
|
2
|
+
import { Resource } from "../resource.ts";
|
|
3
|
+
import type { Secret } from "../secret.ts";
|
|
4
|
+
/**
|
|
5
|
+
* Properties for creating a Stripe entitlements feature
|
|
6
|
+
*/
|
|
7
|
+
export interface EntitlementsFeatureProps {
|
|
8
|
+
/**
|
|
9
|
+
* The feature's name, for your own purpose, not meant to be displayable to the customer
|
|
10
|
+
*/
|
|
11
|
+
name: string;
|
|
12
|
+
/**
|
|
13
|
+
* A unique key you provide as your own system identifier. This may be up to 80 characters
|
|
14
|
+
*/
|
|
15
|
+
lookupKey?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Set of key-value pairs that you can attach to an object
|
|
18
|
+
*/
|
|
19
|
+
metadata?: Record<string, string>;
|
|
20
|
+
/**
|
|
21
|
+
* API key to use (overrides environment variable)
|
|
22
|
+
*/
|
|
23
|
+
apiKey?: Secret;
|
|
24
|
+
/**
|
|
25
|
+
* If true, adopt existing resource if creation fails due to conflict
|
|
26
|
+
*/
|
|
27
|
+
adopt?: boolean;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Output from the Stripe entitlements feature
|
|
31
|
+
*/
|
|
32
|
+
export interface EntitlementsFeature extends Resource<"stripe::EntitlementsFeature">, EntitlementsFeatureProps {
|
|
33
|
+
/**
|
|
34
|
+
* The ID of the feature
|
|
35
|
+
*/
|
|
36
|
+
id: string;
|
|
37
|
+
/**
|
|
38
|
+
* String representing the object's type
|
|
39
|
+
*/
|
|
40
|
+
object: "entitlements.feature";
|
|
41
|
+
/**
|
|
42
|
+
* Has the value true if the object exists in live mode or the value false if the object exists in test mode
|
|
43
|
+
*/
|
|
44
|
+
livemode: boolean;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Create and manage Stripe entitlements features
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* // Create a basic feature for API access
|
|
51
|
+
* const apiFeature = await EntitlementsFeature("api-access", {
|
|
52
|
+
* name: "API Access",
|
|
53
|
+
* lookupKey: "api_access_v1",
|
|
54
|
+
* metadata: {
|
|
55
|
+
* tier: "premium",
|
|
56
|
+
* category: "api"
|
|
57
|
+
* }
|
|
58
|
+
* });
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* // Create a feature for advanced analytics
|
|
62
|
+
* const analyticsFeature = await EntitlementsFeature("advanced-analytics", {
|
|
63
|
+
* name: "Advanced Analytics",
|
|
64
|
+
* lookupKey: "analytics_advanced",
|
|
65
|
+
* metadata: {
|
|
66
|
+
* tier: "enterprise",
|
|
67
|
+
* category: "analytics"
|
|
68
|
+
* }
|
|
69
|
+
* });
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* // Create a feature for custom integrations
|
|
73
|
+
* const integrationsFeature = await EntitlementsFeature("custom-integrations", {
|
|
74
|
+
* name: "Custom Integrations",
|
|
75
|
+
* lookupKey: "integrations_custom",
|
|
76
|
+
* metadata: {
|
|
77
|
+
* tier: "enterprise",
|
|
78
|
+
* category: "integrations",
|
|
79
|
+
* limit: "unlimited"
|
|
80
|
+
* }
|
|
81
|
+
* });
|
|
82
|
+
*/
|
|
83
|
+
export declare const EntitlementsFeature: (((this: any, id: string, props?: {}) => never) & (new (_: never) => never)) | ((this: Context<EntitlementsFeature>, _id: string, props: EntitlementsFeatureProps) => Promise<EntitlementsFeature>);
|
|
84
|
+
//# sourceMappingURL=entitlements-feature.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entitlements-feature.d.ts","sourceRoot":"","sources":["../../src/stripe/entitlements-feature.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAG3C;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAElC;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,mBACf,SAAQ,QAAQ,CAAC,6BAA6B,CAAC,EAC7C,wBAAwB;IAC1B;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IAEX;;OAEG;IACH,MAAM,EAAE,sBAAsB,CAAC;IAE/B;;OAEG;IACH,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,eAAO,MAAM,mBAAmB,yFAGtB,OAAO,CAAC,mBAAmB,CAAC,OAC7B,MAAM,SACJ,wBAAwB,KAC9B,OAAO,CAAC,mBAAmB,CAAC,CAmEhC,CAAC"}
|