payment-kit 1.13.98 → 1.13.99
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.
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Op } from 'sequelize';
|
|
2
2
|
|
|
3
|
+
import { createEvent } from '../libs/audit';
|
|
3
4
|
import dayjs from '../libs/dayjs';
|
|
4
5
|
import logger from '../libs/logger';
|
|
5
6
|
import createQueue from '../libs/queue';
|
|
@@ -57,9 +58,18 @@ export const handleInvoice = async (job: InvoiceJob) => {
|
|
|
57
58
|
|
|
58
59
|
if (invoice.subscription_id) {
|
|
59
60
|
const subscription = await Subscription.findByPk(invoice.subscription_id);
|
|
60
|
-
if (subscription
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
if (subscription) {
|
|
62
|
+
if (subscription.status === 'incomplete') {
|
|
63
|
+
await subscription.start();
|
|
64
|
+
logger.info('invoice subscription updated', subscription.id);
|
|
65
|
+
} else {
|
|
66
|
+
if (invoice.billing_reason === 'subscription_cycle') {
|
|
67
|
+
createEvent('Subscription', 'customer.subscription.renewed', subscription).catch(console.error);
|
|
68
|
+
}
|
|
69
|
+
if (invoice.billing_reason === 'subscription_update') {
|
|
70
|
+
createEvent('Subscription', 'customer.subscription.upgraded', subscription).catch(console.error);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
63
73
|
}
|
|
64
74
|
}
|
|
65
75
|
|
|
@@ -78,6 +78,9 @@ export const handlePaymentSucceed = async (paymentIntent: PaymentIntent, invoice
|
|
|
78
78
|
if (invoice.billing_reason === 'subscription_cycle') {
|
|
79
79
|
createEvent('Subscription', 'customer.subscription.renewed', subscription).catch(console.error);
|
|
80
80
|
}
|
|
81
|
+
if (invoice.billing_reason === 'subscription_update') {
|
|
82
|
+
createEvent('Subscription', 'customer.subscription.upgraded', subscription).catch(console.error);
|
|
83
|
+
}
|
|
81
84
|
}
|
|
82
85
|
|
|
83
86
|
if (invoice.checkout_session_id) {
|
|
@@ -413,6 +413,7 @@ export type EventType = LiteralUnion<
|
|
|
413
413
|
| 'customer.subscription.pending_update_expired'
|
|
414
414
|
| 'customer.subscription.resumed'
|
|
415
415
|
| 'customer.subscription.renewed'
|
|
416
|
+
| 'customer.subscription.upgraded'
|
|
416
417
|
| 'customer.subscription.renew_failed'
|
|
417
418
|
| 'customer.subscription.trial_start'
|
|
418
419
|
| 'customer.subscription.trial_will_end'
|
package/blocklet.yml
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "payment-kit",
|
|
3
|
-
"version": "1.13.
|
|
3
|
+
"version": "1.13.99",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"dev": "COMPONENT_STORE_URL=https://test.store.blocklet.dev blocklet dev",
|
|
6
6
|
"eject": "vite eject",
|
|
@@ -110,7 +110,7 @@
|
|
|
110
110
|
"@abtnode/types": "1.16.21",
|
|
111
111
|
"@arcblock/eslint-config": "^0.2.4",
|
|
112
112
|
"@arcblock/eslint-config-ts": "^0.2.4",
|
|
113
|
-
"@did-pay/types": "1.13.
|
|
113
|
+
"@did-pay/types": "1.13.99",
|
|
114
114
|
"@types/cookie-parser": "^1.4.6",
|
|
115
115
|
"@types/cors": "^2.8.17",
|
|
116
116
|
"@types/dotenv-flow": "^3.3.3",
|
|
@@ -149,5 +149,5 @@
|
|
|
149
149
|
"parser": "typescript"
|
|
150
150
|
}
|
|
151
151
|
},
|
|
152
|
-
"gitHead": "
|
|
152
|
+
"gitHead": "abb8f6d451350b07f5755fe4d599e8a438b3cfe1"
|
|
153
153
|
}
|