@tsed/stripe 6.100.2 → 6.102.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/.mocharc.js CHANGED
@@ -1,5 +1,5 @@
1
1
  module.exports = {
2
- ...require('@tsed/mocha-config')(),
2
+ ...require("@tsed/mocha-config")(),
3
3
  spec: ["{src,test}/**/*.spec.ts"],
4
- exclude: [],
4
+ exclude: []
5
5
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsed/stripe",
3
- "version": "6.100.2",
3
+ "version": "6.102.1",
4
4
  "description": "Stripe package for Ts.ED framework",
5
5
  "private": false,
6
6
  "keywords": [
@@ -31,21 +31,21 @@
31
31
  "tslib": "2.2.0"
32
32
  },
33
33
  "devDependencies": {
34
- "@tsed/common": "6.100.2",
35
- "@tsed/core": "6.100.2",
36
- "@tsed/di": "6.100.2",
37
- "@tsed/json-mapper": "6.100.2",
38
- "@tsed/openspec": "6.100.2",
39
- "@tsed/schema": "6.100.2",
34
+ "@tsed/common": "6.102.1",
35
+ "@tsed/core": "6.102.1",
36
+ "@tsed/di": "6.102.1",
37
+ "@tsed/json-mapper": "6.102.1",
38
+ "@tsed/openspec": "6.102.1",
39
+ "@tsed/schema": "6.102.1",
40
40
  "stripe": "^8.129.0"
41
41
  },
42
42
  "peerDependencies": {
43
- "@tsed/common": "^6.100.2",
44
- "@tsed/core": "^6.100.2",
45
- "@tsed/di": "^6.100.2",
46
- "@tsed/json-mapper": "^6.100.2",
47
- "@tsed/openspec": "^6.100.2",
48
- "@tsed/schema": "^6.100.2",
43
+ "@tsed/common": "^6.102.1",
44
+ "@tsed/core": "^6.102.1",
45
+ "@tsed/di": "^6.102.1",
46
+ "@tsed/json-mapper": "^6.102.1",
47
+ "@tsed/openspec": "^6.102.1",
48
+ "@tsed/schema": "^6.102.1",
49
49
  "@types/body-parser": "^1.19.0",
50
50
  "body-parser": "^1.19.0",
51
51
  "stripe": "^8.129.0"
package/readme.md CHANGED
@@ -32,7 +32,7 @@ A package of Ts.ED framework. See website: https://tsed.io/tutorials/stripe.html
32
32
  ## Feature
33
33
 
34
34
  Currently, `@tsed/stripe` allows you:
35
-
35
+
36
36
  - Configure stripe,
37
37
  - Create webhooks,
38
38
  - Use stripe API.
@@ -50,33 +50,34 @@ Then import `@tsed/stripe` in your Server:
50
50
 
51
51
  ```typescript
52
52
  import {Configuration, PlatformApplication} from "@tsed/common";
53
- import "@tsed/stripe";
53
+ import "@tsed/stripe";
54
54
  import {Stripe} from "stripe";
55
55
 
56
56
  @Configuration({
57
57
  stripe: {
58
58
  apiKey: process.env.STRIPE_SECRET_KEY,
59
59
  webhooks: {
60
- secret: process.env.STRIPE_WEBHOOK_SECRET,
60
+ secret: process.env.STRIPE_WEBHOOK_SECRET
61
61
  },
62
62
  // Stripe options
63
- apiVersion: '2019-08-08',
64
- httpProxy: new ProxyAgent(process.env.http_proxy),
63
+ apiVersion: "2019-08-08",
64
+ httpProxy: new ProxyAgent(process.env.http_proxy)
65
65
  }
66
66
  })
67
67
  export class Server {
68
68
  @Inject()
69
69
  stripe: Stripe;
70
-
70
+
71
71
  $afterInit() {
72
72
  // do something with stripe
73
73
  // this.stripe.customers
74
74
  }
75
75
  }
76
76
  ```
77
+
77
78
  > See Stripe options for more details: https://www.npmjs.com/package/stripe
78
79
 
79
- ## Inject Stripe
80
+ ## Inject Stripe
80
81
 
81
82
  ```typescript
82
83
  import {Injectable} from "@tsed/di";
@@ -85,15 +86,13 @@ import {Injectable} from "@tsed/di";
85
86
  class MyStripeService {
86
87
  @Inject()
87
88
  stripe: Stripe;
88
-
89
+
89
90
  $onInit() {
90
91
  // do something with stripe
91
- this.stripe.on('request', this.onRequest.bind(this));
92
- }
93
-
94
- protected onRequest(request: any) {
95
-
92
+ this.stripe.on("request", this.onRequest.bind(this));
96
93
  }
94
+
95
+ protected onRequest(request: any) {}
97
96
  }
98
97
  ```
99
98
 
@@ -102,7 +101,7 @@ class MyStripeService {
102
101
  Stripe can optionally sign the webhook events it sends to your endpoint, allowing you to validate that they were not sent by a third-party. You can read more about it [here](https://stripe.com/docs/webhooks#signatures).
103
102
 
104
103
  To register a Stripe webhook with Ts.ED, just use the `@WebhookEvent` decorator. It'll call for you the `stripe.webhooks.constructEvent` with the right parameters:
105
-
104
+
106
105
  ```typescript
107
106
  import {RawBodyParams, HeaderParams, Controller, Context} from "@tsed/common";
108
107
  import {Stripe} from "stripe";
@@ -111,15 +110,12 @@ import {Stripe} from "stripe";
111
110
  export class StripWebhookCtrl {
112
111
  @Inject()
113
112
  stripe: Stripe;
114
-
113
+
115
114
  @Post("/callback")
116
- successPaymentHook(
117
- @WebhookEvent() event: Stripe.Event,
118
- @Context() ctx: Context
119
- ) {
120
- ctx.logger.info({name: 'Webhook success', event});
121
-
122
- return {received: true}
115
+ successPaymentHook(@WebhookEvent() event: Stripe.Event, @Context() ctx: Context) {
116
+ ctx.logger.info({name: "Webhook success", event});
117
+
118
+ return {received: true};
123
119
  }
124
120
  }
125
121
  ```
@@ -133,41 +129,43 @@ import {Stripe} from "stripe";
133
129
  import {PlatformTest} from "@tsed/common";
134
130
  import {StripWebhookCtrl} from "./StripWebhookCtrl";
135
131
 
136
- describe('StripWebhookCtrl', () => {
137
- beforeEach(() => PlatformTest.create({
138
- stripe: {
139
- apiKey: 'fake_api_key',
140
- webhooks: {
141
- secret: 'whsec_test_secret',
142
- },
143
- // Stripe options
144
- apiVersion: '2019-08-08'
145
- }
146
- }))
147
- afterEach(PlatformTest.reset)
132
+ describe("StripWebhookCtrl", () => {
133
+ beforeEach(() =>
134
+ PlatformTest.create({
135
+ stripe: {
136
+ apiKey: "fake_api_key",
137
+ webhooks: {
138
+ secret: "whsec_test_secret"
139
+ },
140
+ // Stripe options
141
+ apiVersion: "2019-08-08"
142
+ }
143
+ })
144
+ );
145
+ afterEach(PlatformTest.reset);
148
146
  it("should call event", async () => {
149
- const stripe = PlatformTest.get<Stripe>(Stripe);
150
- const payload = {
151
- id: 'evt_test_webhook',
152
- object: 'event',
153
- };
154
- const payloadString = JSON.stringify(payload, null, 2);
155
-
156
- const header = stripe.webhooks.generateTestHeaderString({
157
- payload: payloadString,
158
- secret: 'whsec_test_secret',
159
- });
160
-
161
- const event = stripe.webhooks.constructEvent(payloadString, header, secret);
162
- const ctx = PlatformTest.createRequestContext()
163
-
164
- const ctrl = await PlatformTest.invoke<StripWebhookCtrl>(StripWebhookCtrl);
165
-
166
- const result = ctrl.successPaymentHook(event, ctx);
167
-
168
- expect(result).toEqual({received: true})
147
+ const stripe = PlatformTest.get<Stripe>(Stripe);
148
+ const payload = {
149
+ id: "evt_test_webhook",
150
+ object: "event"
151
+ };
152
+ const payloadString = JSON.stringify(payload, null, 2);
153
+
154
+ const header = stripe.webhooks.generateTestHeaderString({
155
+ payload: payloadString,
156
+ secret: "whsec_test_secret"
157
+ });
158
+
159
+ const event = stripe.webhooks.constructEvent(payloadString, header, secret);
160
+ const ctx = PlatformTest.createRequestContext();
161
+
162
+ const ctrl = await PlatformTest.invoke<StripWebhookCtrl>(StripWebhookCtrl);
163
+
164
+ const result = ctrl.successPaymentHook(event, ctx);
165
+
166
+ expect(result).toEqual({received: true});
169
167
  });
170
- })
168
+ });
171
169
  ```
172
170
 
173
171
  With SuperTest:
@@ -193,11 +191,13 @@ const utils = PlatformTestUtils.create({
193
191
 
194
192
  describe("Stripe", () => {
195
193
  let request: SuperTest.SuperTest<SuperTest.Test>;
196
- beforeEach(utils.bootstrap({
197
- mount: {
198
- "/rest": [StripWebhookCtrl]
199
- }
200
- }));
194
+ beforeEach(
195
+ utils.bootstrap({
196
+ mount: {
197
+ "/rest": [StripWebhookCtrl]
198
+ }
199
+ })
200
+ );
201
201
  beforeEach(() => {
202
202
  request = SuperTest.agent(PlatformTest.callback());
203
203
  });
@@ -217,33 +217,28 @@ describe("Stripe", () => {
217
217
  secret: "whsec_test_secret"
218
218
  });
219
219
 
220
- const response = await request
221
- .post("/rest/webhooks/callback")
222
- .send(payloadString)
223
- .set("stripe-signature", signature)
224
- .expect(200);
220
+ const response = await request.post("/rest/webhooks/callback").send(payloadString).set("stripe-signature", signature).expect(200);
225
221
 
226
222
  expect(response.body).to.deep.eq({
227
- "event": payload,
228
- "received": true
223
+ event: payload,
224
+ received: true
229
225
  });
230
226
  });
231
227
  });
232
228
  ```
233
229
 
234
230
  ## Contributors
231
+
235
232
  Please read [contributing guidelines here](https://tsed.io/CONTRIBUTING.html)
236
233
 
237
234
  <a href="https://github.com/tsedio/ts-express-decorators/graphs/contributors"><img src="https://opencollective.com/tsed/contributors.svg?width=890" /></a>
238
235
 
239
-
240
236
  ## Backers
241
237
 
242
238
  Thank you to all our backers! 🙏 [[Become a backer](https://opencollective.com/tsed#backer)]
243
239
 
244
240
  <a href="https://opencollective.com/tsed#backers" target="_blank"><img src="https://opencollective.com/tsed/backers.svg?width=890"></a>
245
241
 
246
-
247
242
  ## Sponsors
248
243
 
249
244
  Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [[Become a sponsor](https://opencollective.com/tsed#sponsor)]
@@ -8,16 +8,5 @@
8
8
  "declaration": true,
9
9
  "declarationDir": "./lib/types"
10
10
  },
11
- "exclude": [
12
- "node_modules",
13
- "test",
14
- "lib",
15
- "benchmark",
16
- "coverage",
17
- "spec",
18
- "**/*.benchmark.ts",
19
- "**/*.spec.ts",
20
- "keys",
21
- "jest.config.js"
22
- ]
11
+ "exclude": ["node_modules", "test", "lib", "benchmark", "coverage", "spec", "**/*.benchmark.ts", "**/*.spec.ts", "keys", "jest.config.js"]
23
12
  }