@storecraft/payments-stripe 1.0.8 → 1.0.10

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/adapter.html.js CHANGED
@@ -1,3 +1,8 @@
1
+ /**
2
+ * @import { Config } from './types.public.js'
3
+ * @import { OrderData } from '@storecraft/core/api'
4
+ */
5
+
1
6
  /**
2
7
  *
3
8
  * @description Official `Stripe` UI integration with `storecraft`.
@@ -11,8 +16,8 @@
11
16
  * - Expiry date: 12/2027
12
17
  * - CVC code: 897
13
18
  *
14
- * @param {import("./types.public.d.ts").Config} config
15
- * @param {Partial<import("@storecraft/core/api").OrderData>} order_data
19
+ * @param {Config} config
20
+ * @param {Partial<OrderData>} order_data
16
21
  */
17
22
  export default function html_buy_ui(config, order_data) {
18
23
 
package/adapter.js CHANGED
@@ -1,3 +1,11 @@
1
+ /**
2
+ * @import { Config } from './types.public.js'
3
+ * @import { OrderData, PaymentGatewayStatus } from '@storecraft/core/api'
4
+ * @import { payment_gateway } from '@storecraft/core/payments'
5
+ * @import { ApiRequest, ApiResponse } from '@storecraft/core/rest'
6
+ * @import { } from './types.private.js'
7
+ */
8
+
1
9
  import {
2
10
  CheckoutStatusEnum, PaymentOptionsEnum
3
11
  } from '@storecraft/core/api/types.api.enums.js';
@@ -7,11 +15,7 @@ import { Stripe as StripeCls } from 'stripe'
7
15
 
8
16
  /**
9
17
  * @typedef {StripeCls.Response<StripeCls.PaymentIntent>} CheckoutCreateResult
10
- * @typedef {import('@storecraft/core/api').PaymentGatewayStatus} PaymentGatewayStatus
11
- * @typedef {import('@storecraft/core/api').CheckoutStatusEnum} CheckoutStatusOptions
12
- * @typedef {import('@storecraft/core/api').OrderData} OrderData
13
- * @typedef {import('./types.public.d.ts').Config} Config
14
- * @typedef {import('@storecraft/core/payments').payment_gateway<Config, CheckoutCreateResult>} payment_gateway
18
+ * @typedef {payment_gateway<Config, CheckoutCreateResult>} Impl
15
19
  */
16
20
 
17
21
  /**
@@ -21,7 +25,7 @@ import { Stripe as StripeCls } from 'stripe'
21
25
  export const metadata_storecraft_order_id = 'storecraft_order_id'
22
26
 
23
27
  /**
24
- * @implements {payment_gateway}
28
+ * @implements {Impl}
25
29
  *
26
30
  * @description **Stripe** gateway (https://docs.stripe.com/payments/place-a-hold-on-a-payment-method)
27
31
  */
@@ -110,7 +114,7 @@ export class Stripe {
110
114
 
111
115
  /**
112
116
  *
113
- * @type {payment_gateway["invokeAction"]}
117
+ * @type {Impl["invokeAction"]}
114
118
  */
115
119
  invokeAction(action_handle) {
116
120
  switch (action_handle) {
@@ -129,9 +133,7 @@ export class Stripe {
129
133
  /**
130
134
  * @description (Optional) buy link ui
131
135
  *
132
- * @param {Partial<OrderData>} order
133
- *
134
- * @return {Promise<string>} html
136
+ * @type {Impl["onBuyLinkHtml"]}
135
137
  */
136
138
  async onBuyLinkHtml(order) {
137
139
 
@@ -143,9 +145,7 @@ export class Stripe {
143
145
  /**
144
146
  * @description on checkout create `hook`
145
147
  *
146
- * @param {OrderData} order
147
- *
148
- * @return {Promise<CheckoutCreateResult>}
148
+ * @type {Impl["onCheckoutCreate"]}
149
149
  */
150
150
  async onCheckoutCreate(order) {
151
151
 
@@ -169,12 +169,10 @@ export class Stripe {
169
169
  * client side into their servers, and then you are notified via a
170
170
  * webhook.
171
171
  *
172
- * @param {CheckoutCreateResult} create_result
173
- *
174
- * @return {ReturnType<payment_gateway["onCheckoutComplete"]>}
172
+ * @type {Impl["onCheckoutComplete"]}
175
173
  */
176
174
  async onCheckoutComplete(create_result) {
177
-
175
+
178
176
  const intent = await this.stripe.paymentIntents.confirm(
179
177
  create_result.id
180
178
  );
@@ -215,11 +213,7 @@ export class Stripe {
215
213
  /**
216
214
  * @description Fetch the order and analyze it's status
217
215
  *
218
- *
219
- * @param {CheckoutCreateResult} create_result
220
- *
221
- *
222
- * @returns {Promise<PaymentGatewayStatus>}
216
+ * @type {Impl["status"]}
223
217
  */
224
218
  async status(create_result) {
225
219
  const o = await this.retrieve_order(create_result);
@@ -268,10 +262,8 @@ export class Stripe {
268
262
 
269
263
  /**
270
264
  * @description [https://docs.stripe.com/webhooks](https://docs.stripe.com/webhooks)
271
- * @param {import('@storecraft/core/rest').ApiRequest} request
272
- * @param {import('@storecraft/core/rest').ApiResponse} response
273
265
  *
274
- * @type {payment_gateway["webhook"]}
266
+ * @type {Impl["webhook"]}
275
267
  */
276
268
  async webhook(request, response) {
277
269
  const sig = request.headers.get('Stripe-Signature');
@@ -295,6 +287,7 @@ export class Stripe {
295
287
  /** @type {StripeCls.PaymentIntent} */
296
288
  let payment_intent;
297
289
 
290
+ /** @type {PaymentOptionsEnum[keyof PaymentOptionsEnum]} */
298
291
  let payment_status = PaymentOptionsEnum.unpaid;
299
292
 
300
293
  // Handle the event
@@ -323,8 +316,10 @@ export class Stripe {
323
316
  case 'charge.refund.updated':
324
317
  payment_status = PaymentOptionsEnum.refunded;
325
318
 
326
- default:
319
+ default: {
327
320
  console.log(`Unhandled event type ${event.type}`);
321
+ return undefined;
322
+ }
328
323
  }
329
324
 
330
325
  // Return a response to acknowledge receipt of the event
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storecraft/payments-stripe",
3
- "version": "1.0.8",
3
+ "version": "1.0.10",
4
4
  "description": "Official Storecraft <-> Stripe integration",
5
5
  "license": "MIT",
6
6
  "author": "Tomer Shalev (https://github.com/store-craft)",