payment-kit 1.18.9 → 1.18.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/api/src/libs/ws.ts +78 -12
- package/api/third.d.ts +1 -0
- package/blocklet.yml +42 -1
- package/package.json +13 -13
- package/src/global.css +0 -3
package/api/src/libs/ws.ts
CHANGED
|
@@ -1,25 +1,91 @@
|
|
|
1
1
|
import { sendToRelay } from '@blocklet/sdk/service/notification';
|
|
2
|
-
|
|
3
|
-
import type { CheckoutSession, Invoice, PaymentIntent } from '../store/models';
|
|
2
|
+
import { publish } from '@blocklet/sdk/service/eventbus';
|
|
3
|
+
import type { CheckoutSession, Invoice, PaymentIntent, Subscription, Refund } from '../store/models';
|
|
4
4
|
import { events } from './event';
|
|
5
5
|
|
|
6
|
-
export function broadcast(eventName: string, data: any) {
|
|
6
|
+
export function broadcast(eventName: string, data: any, extraParams?: Record<string, any>) {
|
|
7
7
|
sendToRelay('events', eventName, data).catch((err: any) => {
|
|
8
|
-
console.error(`Failed to broadcast event: ${eventName}`, err);
|
|
8
|
+
console.error(`Failed to broadcast event via relay: ${eventName}`, err);
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
publish(eventName, {
|
|
12
|
+
id: data.id,
|
|
13
|
+
time: new Date().toISOString(),
|
|
14
|
+
data: {
|
|
15
|
+
object: data,
|
|
16
|
+
extraParams,
|
|
17
|
+
},
|
|
18
|
+
}).catch((err: any) => {
|
|
19
|
+
console.error(`Failed to publish event via EventBus: ${eventName}`, err);
|
|
9
20
|
});
|
|
10
21
|
}
|
|
11
22
|
|
|
12
23
|
export function initEventBroadcast() {
|
|
13
|
-
|
|
14
|
-
|
|
24
|
+
// Checkout Events
|
|
25
|
+
events.on('checkout.session.completed', (data: CheckoutSession, extraParams?: Record<string, any>) => {
|
|
26
|
+
broadcast('checkout.session.completed', data, extraParams);
|
|
27
|
+
});
|
|
28
|
+
events.on('checkout.session.nft_minted', (data: CheckoutSession, extraParams?: Record<string, any>) => {
|
|
29
|
+
broadcast('checkout.session.nft_minted', data, extraParams);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
// Payment Events
|
|
33
|
+
events.on('payment_intent.succeeded', (data: PaymentIntent, extraParams?: Record<string, any>) => {
|
|
34
|
+
broadcast('payment_intent.succeeded', data, extraParams);
|
|
35
|
+
});
|
|
36
|
+
events.on('payment_intent.payment_failed', (data: PaymentIntent, extraParams?: Record<string, any>) => {
|
|
37
|
+
broadcast('payment_intent.payment_failed', data, extraParams);
|
|
38
|
+
});
|
|
39
|
+
events.on('invoice.paid', (data: Invoice, extraParams?: Record<string, any>) => {
|
|
40
|
+
broadcast('invoice.paid', data, extraParams);
|
|
41
|
+
});
|
|
42
|
+
events.on('refund.succeeded', (data: Refund, extraParams?: Record<string, any>) => {
|
|
43
|
+
broadcast('refund.succeeded', data, extraParams);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
// Subscription Events
|
|
47
|
+
events.on('customer.subscription.created', (data: Subscription, extraParams?: Record<string, any>) => {
|
|
48
|
+
broadcast('customer.subscription.created', data, extraParams);
|
|
15
49
|
});
|
|
16
|
-
events.on('
|
|
17
|
-
broadcast('
|
|
50
|
+
events.on('customer.subscription.started', (data: Subscription, extraParams?: Record<string, any>) => {
|
|
51
|
+
broadcast('customer.subscription.started', data, extraParams);
|
|
52
|
+
});
|
|
53
|
+
events.on('customer.subscription.renewed', (data: Subscription, extraParams?: Record<string, any>) => {
|
|
54
|
+
broadcast('customer.subscription.renewed', data, extraParams);
|
|
55
|
+
});
|
|
56
|
+
events.on('customer.subscription.upgraded', (data: Subscription, extraParams?: Record<string, any>) => {
|
|
57
|
+
broadcast('customer.subscription.upgraded', data, extraParams);
|
|
58
|
+
});
|
|
59
|
+
events.on('customer.subscription.updated', (data: Subscription, extraParams?: Record<string, any>) => {
|
|
60
|
+
broadcast('customer.subscription.updated', data, extraParams);
|
|
61
|
+
});
|
|
62
|
+
events.on('customer.subscription.deleted', (data: Subscription, extraParams?: Record<string, any>) => {
|
|
63
|
+
broadcast('customer.subscription.deleted', data, extraParams);
|
|
64
|
+
});
|
|
65
|
+
events.on('customer.subscription.paused', (data: Subscription, extraParams?: Record<string, any>) => {
|
|
66
|
+
broadcast('customer.subscription.paused', data, extraParams);
|
|
67
|
+
});
|
|
68
|
+
events.on('customer.subscription.resumed', (data: Subscription, extraParams?: Record<string, any>) => {
|
|
69
|
+
broadcast('customer.subscription.resumed', data, extraParams);
|
|
70
|
+
});
|
|
71
|
+
events.on('customer.subscription.past_due', (data: Subscription, extraParams?: Record<string, any>) => {
|
|
72
|
+
broadcast('customer.subscription.past_due', data, extraParams);
|
|
73
|
+
});
|
|
74
|
+
events.on('customer.subscription.recovered', (data: Subscription, extraParams?: Record<string, any>) => {
|
|
75
|
+
broadcast('customer.subscription.recovered', data, extraParams);
|
|
76
|
+
});
|
|
77
|
+
events.on('customer.subscription.renew_failed', (data: Subscription, extraParams?: Record<string, any>) => {
|
|
78
|
+
broadcast('customer.subscription.renew_failed', data, extraParams);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
// Trial Events
|
|
82
|
+
events.on('customer.subscription.trial_start', (data: Subscription, extraParams?: Record<string, any>) => {
|
|
83
|
+
broadcast('customer.subscription.trial_start', data, extraParams);
|
|
18
84
|
});
|
|
19
|
-
events.on('
|
|
20
|
-
broadcast('
|
|
85
|
+
events.on('customer.subscription.trial_will_end', (data: Subscription, extraParams?: Record<string, any>) => {
|
|
86
|
+
broadcast('customer.subscription.trial_will_end', data, extraParams);
|
|
21
87
|
});
|
|
22
|
-
events.on('
|
|
23
|
-
broadcast('
|
|
88
|
+
events.on('customer.subscription.trial_end', (data: Subscription, extraParams?: Record<string, any>) => {
|
|
89
|
+
broadcast('customer.subscription.trial_end', data, extraParams);
|
|
24
90
|
});
|
|
25
91
|
}
|
package/api/third.d.ts
CHANGED
package/blocklet.yml
CHANGED
|
@@ -14,7 +14,7 @@ repository:
|
|
|
14
14
|
type: git
|
|
15
15
|
url: git+https://github.com/blocklet/payment-kit.git
|
|
16
16
|
specVersion: 1.2.8
|
|
17
|
-
version: 1.18.
|
|
17
|
+
version: 1.18.10
|
|
18
18
|
logo: logo.png
|
|
19
19
|
files:
|
|
20
20
|
- dist
|
|
@@ -125,3 +125,44 @@ resource:
|
|
|
125
125
|
- type: paywall
|
|
126
126
|
description: Auto config paywall for your content
|
|
127
127
|
egress: true
|
|
128
|
+
events:
|
|
129
|
+
- type: checkout.session.completed
|
|
130
|
+
description: Payment checkout process has been successfully completed
|
|
131
|
+
- type: checkout.session.nft_minted
|
|
132
|
+
description: NFT has been successfully minted after payment
|
|
133
|
+
- type: customer.subscription.created
|
|
134
|
+
description: A new subscription has been successfully created
|
|
135
|
+
- type: customer.subscription.started
|
|
136
|
+
description: Subscription has been activated and billing cycle has begun
|
|
137
|
+
- type: customer.subscription.renewed
|
|
138
|
+
description: Subscription has been successfully renewed for next period
|
|
139
|
+
- type: customer.subscription.upgraded
|
|
140
|
+
description: Subscription plan has been changed to a different tier
|
|
141
|
+
- type: customer.subscription.updated
|
|
142
|
+
description: Subscription details or configuration has been modified
|
|
143
|
+
- type: customer.subscription.deleted
|
|
144
|
+
description: An existing subscription has been cancelled
|
|
145
|
+
- type: customer.subscription.renew_failed
|
|
146
|
+
description: Subscription renewal attempt has failed
|
|
147
|
+
- type: customer.subscription.trial_start
|
|
148
|
+
description: Subscription trial period has started
|
|
149
|
+
- type: customer.subscription.trial_will_end
|
|
150
|
+
description: Subscription trial period is about to end
|
|
151
|
+
- type: customer.subscription.trial_end
|
|
152
|
+
description: Subscription trial period has ended
|
|
153
|
+
- type: customer.subscription.paused
|
|
154
|
+
description: Subscription has been paused, payment collection suspended
|
|
155
|
+
- type: customer.subscription.resumed
|
|
156
|
+
description: Subscription has been resumed after being paused
|
|
157
|
+
- type: customer.subscription.past_due
|
|
158
|
+
description: Subscription payment is overdue
|
|
159
|
+
- type: customer.subscription.recovered
|
|
160
|
+
description: Subscription has been recovered from past due status
|
|
161
|
+
- type: payment_intent.succeeded
|
|
162
|
+
description: Payment has been successfully processed and confirmed
|
|
163
|
+
- type: payment_intent.payment_failed
|
|
164
|
+
description: Payment attempt has failed
|
|
165
|
+
- type: invoice.paid
|
|
166
|
+
description: Invoice has been fully paid and settled
|
|
167
|
+
- type: refund.succeeded
|
|
168
|
+
description: Refund has been successfully processed and completed
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "payment-kit",
|
|
3
|
-
"version": "1.18.
|
|
3
|
+
"version": "1.18.10",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"dev": "blocklet dev --open",
|
|
6
6
|
"eject": "vite eject",
|
|
@@ -43,19 +43,19 @@
|
|
|
43
43
|
]
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@abtnode/cron": "^1.16.
|
|
46
|
+
"@abtnode/cron": "^1.16.39",
|
|
47
47
|
"@arcblock/did": "^1.19.10",
|
|
48
48
|
"@arcblock/did-auth-storage-nedb": "^1.7.1",
|
|
49
|
-
"@arcblock/did-connect": "^2.11.
|
|
49
|
+
"@arcblock/did-connect": "^2.11.48",
|
|
50
50
|
"@arcblock/did-util": "^1.19.10",
|
|
51
51
|
"@arcblock/jwt": "^1.19.10",
|
|
52
|
-
"@arcblock/ux": "^2.11.
|
|
52
|
+
"@arcblock/ux": "^2.11.48",
|
|
53
53
|
"@arcblock/validator": "^1.19.10",
|
|
54
|
-
"@blocklet/js-sdk": "^1.16.
|
|
55
|
-
"@blocklet/logger": "^1.16.
|
|
56
|
-
"@blocklet/payment-react": "1.18.
|
|
57
|
-
"@blocklet/sdk": "^1.16.
|
|
58
|
-
"@blocklet/ui-react": "^2.11.
|
|
54
|
+
"@blocklet/js-sdk": "^1.16.39",
|
|
55
|
+
"@blocklet/logger": "^1.16.39",
|
|
56
|
+
"@blocklet/payment-react": "1.18.10",
|
|
57
|
+
"@blocklet/sdk": "^1.16.39",
|
|
58
|
+
"@blocklet/ui-react": "^2.11.48",
|
|
59
59
|
"@blocklet/uploader": "^0.1.70",
|
|
60
60
|
"@blocklet/xss": "^0.1.25",
|
|
61
61
|
"@mui/icons-material": "^5.16.6",
|
|
@@ -119,9 +119,9 @@
|
|
|
119
119
|
"web3": "^4.16.0"
|
|
120
120
|
},
|
|
121
121
|
"devDependencies": {
|
|
122
|
-
"@abtnode/types": "^1.16.
|
|
122
|
+
"@abtnode/types": "^1.16.39",
|
|
123
123
|
"@arcblock/eslint-config-ts": "^0.3.3",
|
|
124
|
-
"@blocklet/payment-types": "1.18.
|
|
124
|
+
"@blocklet/payment-types": "1.18.10",
|
|
125
125
|
"@types/cookie-parser": "^1.4.7",
|
|
126
126
|
"@types/cors": "^2.8.17",
|
|
127
127
|
"@types/debug": "^4.1.12",
|
|
@@ -151,7 +151,7 @@
|
|
|
151
151
|
"vite": "^5.3.5",
|
|
152
152
|
"vite-node": "^2.0.4",
|
|
153
153
|
"vite-plugin-babel-import": "^2.0.5",
|
|
154
|
-
"vite-plugin-blocklet": "^0.9.
|
|
154
|
+
"vite-plugin-blocklet": "^0.9.22",
|
|
155
155
|
"vite-plugin-node-polyfills": "^0.21.0",
|
|
156
156
|
"vite-plugin-svgr": "^4.2.0",
|
|
157
157
|
"vite-tsconfig-paths": "^4.3.2",
|
|
@@ -167,5 +167,5 @@
|
|
|
167
167
|
"parser": "typescript"
|
|
168
168
|
}
|
|
169
169
|
},
|
|
170
|
-
"gitHead": "
|
|
170
|
+
"gitHead": "942a9f4057f0cb1e7b3409d469b20c54ab7924a0"
|
|
171
171
|
}
|