@stacksjs/payments 0.64.6 → 0.65.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/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "@stacksjs/payments",
3
3
  "type": "module",
4
- "version": "0.64.6",
4
+ "version": "0.65.0",
5
5
  "description": "The Stacks payments package. Currently supporting Stripe.",
6
6
  "author": "Chris Breuer",
7
+ "contributors": ["Chris Breuer <chris@stacksjs.org>"],
7
8
  "license": "MIT",
8
9
  "funding": "https://github.com/sponsors/chrisbbreuer",
9
10
  "homepage": "https://github.com/stacksjs/stacks/tree/main/storage/framework/core/payments#readme",
@@ -36,26 +37,19 @@
36
37
  },
37
38
  "module": "dist/index.js",
38
39
  "types": "dist/index.d.ts",
39
- "contributors": [
40
- "Chris Breuer <chris@stacksjs.org>"
41
- ],
42
- "files": [
43
- "README.md",
44
- "dist",
45
- "src"
46
- ],
40
+ "files": ["README.md", "dist", "src"],
47
41
  "scripts": {
48
- "build": "bun --bun build.ts",
49
- "typecheck": "bun --bun tsc --noEmit",
42
+ "build": "bun build.ts",
43
+ "typecheck": "bun tsc --noEmit",
50
44
  "prepublishOnly": "bun run build"
51
45
  },
52
46
  "dependencies": {
53
- "@stacksjs/utils": "latest",
54
- "@stripe/stripe-js": "^4.4.0",
55
- "stripe": "^16.8.0"
47
+ "@stacksjs/utils": "0.64.6",
48
+ "@stripe/stripe-js": "^4.8.0",
49
+ "stripe": "^17.2.0"
56
50
  },
57
51
  "devDependencies": {
58
- "@stacksjs/config": "latest",
59
- "@stacksjs/development": "latest"
52
+ "@stacksjs/config": "0.64.6",
53
+ "@stacksjs/development": "0.64.6"
60
54
  }
61
55
  }
@@ -2,114 +2,155 @@ import Stripe from 'stripe'
2
2
 
3
3
  const apiKey = ''
4
4
 
5
- const stripe = new Stripe(apiKey, {
6
- apiVersion: '2023-10-16',
5
+ const client = new Stripe(apiKey, {
6
+ apiVersion: '2024-06-20',
7
7
  })
8
8
 
9
9
  // TODO: learn about subscriptions
10
- export const paymentIntent = (() => {
10
+ export interface PaymentIntent {
11
+ create: (params: Stripe.PaymentIntentCreateParams) => Promise<Stripe.Response<Stripe.PaymentIntent>>
12
+ retrieve: (stripeId: string) => Promise<Stripe.Response<Stripe.PaymentIntent>>
13
+ update: (stripeId: string, params: Stripe.PaymentIntentCreateParams) => Promise<Stripe.Response<Stripe.PaymentIntent>>
14
+ cancel: (stripeId: string) => Promise<Stripe.Response<Stripe.PaymentIntent>>
15
+ }
16
+
17
+ export const paymentIntent: PaymentIntent = (() => {
11
18
  async function create(params: Stripe.PaymentIntentCreateParams) {
12
- return await stripe.paymentIntents.create(params)
19
+ return await client.paymentIntents.create(params)
13
20
  }
14
21
 
15
22
  async function retrieve(stripeId: string) {
16
- return await stripe.paymentIntents.retrieve(stripeId)
23
+ return await client.paymentIntents.retrieve(stripeId)
17
24
  }
18
25
 
19
26
  async function update(stripeId: string, params: Stripe.PaymentIntentCreateParams) {
20
- return await stripe.paymentIntents.update(stripeId, params)
27
+ return await client.paymentIntents.update(stripeId, params)
21
28
  }
22
29
 
23
30
  async function cancel(stripeId: string) {
24
- return await stripe.paymentIntents.cancel(stripeId)
31
+ return await client.paymentIntents.cancel(stripeId)
25
32
  }
26
33
 
27
34
  return { create, retrieve, update, cancel }
28
35
  })()
29
36
 
30
- export const balance = (() => {
37
+ export interface Balance {
38
+ retrieve: () => Promise<Stripe.Response<Stripe.Balance>>
39
+ }
40
+
41
+ export const balance: Balance = (() => {
31
42
  async function retrieve() {
32
- return await stripe.balance.retrieve()
43
+ return await client.balance.retrieve()
33
44
  }
34
45
 
35
46
  return { retrieve }
36
47
  })()
37
48
 
38
- export const customer = (() => {
49
+ export interface Customer {
50
+ create: (params: Stripe.CustomerCreateParams) => Promise<Stripe.Response<Stripe.Customer>>
51
+ update: (stripeId: string, params: Stripe.CustomerCreateParams) => Promise<Stripe.Response<Stripe.Customer>>
52
+ retrieve: (stripeId: string) => Promise<Stripe.Response<Stripe.Customer | Stripe.DeletedCustomer>>
53
+ }
54
+
55
+ export const customer: Customer = (() => {
39
56
  async function create(params: Stripe.CustomerCreateParams) {
40
- return await stripe.customers.create(params)
57
+ return await client.customers.create(params)
41
58
  }
42
59
 
43
60
  async function update(stripeId: string, params: Stripe.CustomerCreateParams) {
44
- return await stripe.customers.update(stripeId, params)
61
+ return await client.customers.update(stripeId, params)
45
62
  }
46
63
 
47
64
  async function retrieve(stripeId: string) {
48
- return await stripe.customers.retrieve(stripeId)
65
+ return await client.customers.retrieve(stripeId)
49
66
  }
50
67
 
51
68
  return { create, update, retrieve }
52
69
  })()
53
70
 
54
- export const charge = (() => {
71
+ export interface Charge {
72
+ create: (params: Stripe.ChargeCreateParams) => Promise<Stripe.Response<Stripe.Charge>>
73
+ update: (stripeId: string, params: Stripe.ChargeCreateParams) => Promise<Stripe.Response<Stripe.Charge>>
74
+ capture: (stripeId: string) => Promise<Stripe.Response<Stripe.Charge>>
75
+ retrieve: (stripeId: string) => Promise<Stripe.Response<Stripe.Charge>>
76
+ }
77
+
78
+ export const charge: Charge = (() => {
55
79
  async function create(params: Stripe.ChargeCreateParams) {
56
- return await stripe.charges.create(params)
80
+ return await client.charges.create(params)
57
81
  }
58
82
 
59
83
  async function update(stripeId: string, params: Stripe.ChargeCreateParams) {
60
- return await stripe.charges.update(stripeId, params)
84
+ return await client.charges.update(stripeId, params)
61
85
  }
62
86
 
63
87
  async function capture(stripeId: string) {
64
- return await stripe.charges.capture(stripeId)
88
+ return await client.charges.capture(stripeId)
65
89
  }
66
90
 
67
91
  async function retrieve(stripeId: string) {
68
- return await stripe.charges.retrieve(stripeId)
92
+ return await client.charges.retrieve(stripeId)
69
93
  }
70
94
 
71
95
  return { create, update, retrieve, capture }
72
96
  })()
73
97
 
74
- export const balanceTransactions = (() => {
98
+ export interface BalanceTransactions {
99
+ retrieve: (stripeId: string) => Promise<Stripe.Response<Stripe.BalanceTransaction>>
100
+ list: (limit: number) => Promise<Stripe.Response<Stripe.ApiList<Stripe.BalanceTransaction>>>
101
+ }
102
+
103
+ export const balanceTransactions: BalanceTransactions = (() => {
75
104
  async function retrieve(stripeId: string) {
76
- await stripe.balanceTransactions.retrieve(stripeId)
105
+ return await client.balanceTransactions.retrieve(stripeId)
77
106
  }
78
107
 
79
108
  async function list(limit: number) {
80
- await stripe.balanceTransactions.list({ limit })
109
+ return await client.balanceTransactions.list({ limit })
81
110
  }
82
111
 
83
112
  return { retrieve, list }
84
113
  })()
85
114
 
86
- export const dispute = (() => {
115
+ export interface Dispute {
116
+ retrieve: (stripeId: string) => Promise<Stripe.Response<Stripe.Dispute>>
117
+ update: (stripeId: string, params: Stripe.DisputeUpdateParams) => Promise<Stripe.Response<Stripe.Dispute>>
118
+ close: (stripeId: string) => Promise<Stripe.Response<Stripe.Dispute>>
119
+ list: (limit: number) => Promise<Stripe.Response<Stripe.ApiList<Stripe.Dispute>>>
120
+ }
121
+
122
+ export const dispute: Dispute = (() => {
87
123
  async function retrieve(stripeId: string) {
88
- return await stripe.disputes.retrieve(stripeId)
124
+ return await client.disputes.retrieve(stripeId)
89
125
  }
90
126
 
91
127
  async function update(stripeId: string, params: Stripe.DisputeUpdateParams) {
92
- return await stripe.disputes.update(stripeId, params)
128
+ return await client.disputes.update(stripeId, params)
93
129
  }
94
130
 
95
131
  async function close(stripeId: string) {
96
- return await stripe.disputes.close(stripeId)
132
+ return await client.disputes.close(stripeId)
97
133
  }
98
134
 
99
135
  async function list(limit: number) {
100
- return await stripe.disputes.list({ limit })
136
+ return await client.disputes.list({ limit })
101
137
  }
102
138
 
103
139
  return { retrieve, update, close, list }
104
140
  })()
105
141
 
106
- export const events = (() => {
142
+ export interface PaymentEvents {
143
+ retrieve: (stripeId: string) => Promise<Stripe.Response<Stripe.Event>>
144
+ list: (limit: number) => Promise<Stripe.Response<Stripe.ApiList<Stripe.Event>>>
145
+ }
146
+
147
+ export const events: PaymentEvents = (() => {
107
148
  async function retrieve(stripeId: string) {
108
- await stripe.events.retrieve(stripeId)
149
+ return await client.events.retrieve(stripeId)
109
150
  }
110
151
 
111
152
  async function list(limit: number) {
112
- await stripe.events.list({ limit })
153
+ return await client.events.list({ limit })
113
154
  }
114
155
 
115
156
  return { retrieve, list }