@storecraft/payments-stripe 1.0.1 → 1.0.3
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 +31 -1
- package/adapter.html.js +1 -1
- package/adapter.js +10 -12
- package/package.json +4 -3
package/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
<div style="text-align:center">
|
4
4
|
<img src='https://storecraft.app/storecraft-color.svg'
|
5
|
-
width='90%'
|
5
|
+
width='90%' />
|
6
6
|
</div><hr/><br/>
|
7
7
|
|
8
8
|
[Stripe](https://docs.stripe.com/payments/place-a-hold-on-a-payment-method) integration
|
@@ -51,6 +51,36 @@ const config = {
|
|
51
51
|
new Stripe(config);
|
52
52
|
```
|
53
53
|
|
54
|
+
## In Storecraft App
|
55
|
+
|
56
|
+
```ts
|
57
|
+
import { App } from '@storecraft/core';
|
58
|
+
import { MongoDB } from '@storecraft/database-mongodb';
|
59
|
+
import { NodePlatform } from '@storecraft/core/platform/node';
|
60
|
+
import { GoogleStorage } from '@storecraft/storage-google';
|
61
|
+
import { PaypalStandard } from '@storecraft/payments-paypal-standard'
|
62
|
+
|
63
|
+
const app = new App(config)
|
64
|
+
.withPlatform(new NodePlatform())
|
65
|
+
.withDatabase(new MongoDB())
|
66
|
+
.withStorage(new GoogleStorage())
|
67
|
+
.withPaymentGateways(
|
68
|
+
{
|
69
|
+
'stripe': new Stripe(
|
70
|
+
{
|
71
|
+
publishable_key: process.env.STRIPE_PUBLISHABLE_KEY,
|
72
|
+
secret_key: process.env.STRIPE_SECRET_KEY,
|
73
|
+
webhook_endpoint_secret: process.env.STRIPE_WEBHOOK_SECRET
|
74
|
+
}
|
75
|
+
),
|
76
|
+
}
|
77
|
+
);
|
78
|
+
|
79
|
+
await app.init();
|
80
|
+
|
81
|
+
```
|
82
|
+
|
83
|
+
|
54
84
|
## Developer info and test
|
55
85
|
|
56
86
|
First, some resources from `stripe`
|
package/adapter.html.js
CHANGED
@@ -12,7 +12,7 @@
|
|
12
12
|
* - CVC code: 897
|
13
13
|
*
|
14
14
|
* @param {import("./types.public.d.ts").Config} config
|
15
|
-
* @param {Partial<import("@storecraft/core/
|
15
|
+
* @param {Partial<import("@storecraft/core/api").OrderData>} order_data
|
16
16
|
*/
|
17
17
|
export default function html_buy_ui(config, order_data) {
|
18
18
|
|
package/adapter.js
CHANGED
@@ -1,15 +1,17 @@
|
|
1
|
-
import {
|
2
|
-
|
1
|
+
import {
|
2
|
+
CheckoutStatusEnum, PaymentOptionsEnum
|
3
|
+
} from '@storecraft/core/api/types.api.enums.js';
|
4
|
+
import { StorecraftError } from '@storecraft/core/api/utils.func.js';
|
3
5
|
import html_buy_ui from './adapter.html.js';
|
4
6
|
import { Stripe as StripeCls } from 'stripe'
|
5
7
|
|
6
8
|
/**
|
7
9
|
* @typedef {StripeCls.Response<StripeCls.PaymentIntent>} CheckoutCreateResult
|
8
|
-
* @typedef {import('@storecraft/core/
|
9
|
-
* @typedef {import('@storecraft/core/
|
10
|
-
* @typedef {import('@storecraft/core/
|
10
|
+
* @typedef {import('@storecraft/core/api').PaymentGatewayStatus} PaymentGatewayStatus
|
11
|
+
* @typedef {import('@storecraft/core/api').CheckoutStatusEnum} CheckoutStatusOptions
|
12
|
+
* @typedef {import('@storecraft/core/api').OrderData} OrderData
|
11
13
|
* @typedef {import('./types.public.d.ts').Config} Config
|
12
|
-
* @typedef {import('@storecraft/core/
|
14
|
+
* @typedef {import('@storecraft/core/payments').payment_gateway<Config, CheckoutCreateResult>} payment_gateway
|
13
15
|
*/
|
14
16
|
|
15
17
|
/**
|
@@ -266,8 +268,8 @@ export class Stripe {
|
|
266
268
|
|
267
269
|
/**
|
268
270
|
* @description [https://docs.stripe.com/webhooks](https://docs.stripe.com/webhooks)
|
269
|
-
* @param {import('@storecraft/core').ApiRequest} request
|
270
|
-
* @param {import('@storecraft/core').ApiResponse} response
|
271
|
+
* @param {import('@storecraft/core/rest').ApiRequest} request
|
272
|
+
* @param {import('@storecraft/core/rest').ApiResponse} response
|
271
273
|
*
|
272
274
|
* @type {payment_gateway["webhook"]}
|
273
275
|
*/
|
@@ -325,13 +327,9 @@ export class Stripe {
|
|
325
327
|
console.log(`Unhandled event type ${event.type}`);
|
326
328
|
}
|
327
329
|
|
328
|
-
console.log('CCCC')
|
329
|
-
|
330
330
|
// Return a response to acknowledge receipt of the event
|
331
331
|
response.sendJson({received: true});
|
332
332
|
|
333
|
-
console.log('DDDD')
|
334
|
-
|
335
333
|
return {
|
336
334
|
order_id,
|
337
335
|
status: {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@storecraft/payments-stripe",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.3",
|
4
4
|
"description": "Official Storecraft <-> Stripe integration",
|
5
5
|
"license": "MIT",
|
6
6
|
"author": "Tomer Shalev (https://github.com/store-craft)",
|
@@ -8,7 +8,7 @@
|
|
8
8
|
"repository": {
|
9
9
|
"type": "git",
|
10
10
|
"url": "https://github.com/store-craft/storecraft.git",
|
11
|
-
"directory": "packages/payments-stripe"
|
11
|
+
"directory": "packages/payments/payments-stripe"
|
12
12
|
},
|
13
13
|
"keywords": [
|
14
14
|
"commerce",
|
@@ -21,7 +21,8 @@
|
|
21
21
|
"types": "types.public.d.ts",
|
22
22
|
"scripts": {
|
23
23
|
"payments-stripe:test": "uvu -c",
|
24
|
-
"
|
24
|
+
"test": "npm run payments-stripe:test",
|
25
|
+
"prepublishOnly": "npm version patch --force"
|
25
26
|
},
|
26
27
|
"dependencies": {
|
27
28
|
"stripe": "^16.6.0"
|