payment-kit 1.13.59 → 1.13.60
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/jobs/payment.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { ensureStakedForGas } from '../integrations/blockchain/stake';
|
|
1
2
|
import { wallet } from '../libs/auth';
|
|
2
3
|
import dayjs from '../libs/dayjs';
|
|
3
4
|
import CustomError from '../libs/error';
|
|
5
|
+
import { events } from '../libs/event';
|
|
4
6
|
import logger from '../libs/logger';
|
|
5
7
|
import { getGasPayerExtra, isDelegationSufficientForPayment } from '../libs/payment';
|
|
6
8
|
import createQueue from '../libs/queue';
|
|
@@ -246,6 +248,15 @@ export const paymentQueue = createQueue<PaymentJob>({
|
|
|
246
248
|
});
|
|
247
249
|
|
|
248
250
|
export const startPaymentQueue = async () => {
|
|
251
|
+
// Do gas stake as soon as possible after payment succeed
|
|
252
|
+
events.on('payment_intent.succeeded', async (paymentIntent: PaymentIntent) => {
|
|
253
|
+
const paymentMethod = await PaymentMethod.findByPk(paymentIntent.payment_method_id);
|
|
254
|
+
if (paymentMethod && paymentMethod.type === 'arcblock') {
|
|
255
|
+
ensureStakedForGas();
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
// Restore previous payments
|
|
249
260
|
const payments = await PaymentIntent.findAll({
|
|
250
261
|
where: {
|
|
251
262
|
status: ['requires_capture', 'processing'],
|
|
@@ -721,6 +721,7 @@ router.put('/:id/submit', user, ensureCheckoutSessionOpen, async (req, res) => {
|
|
|
721
721
|
await invoice.update({ auto_advance: true, payment_settings: paymentSettings });
|
|
722
722
|
invoiceQueue.push({ id: invoice.id, job: { invoiceId: invoice.id, retryOnError: false } });
|
|
723
723
|
} else {
|
|
724
|
+
await paymentIntent.update({ status: 'requires_capture' });
|
|
724
725
|
paymentQueue.push({
|
|
725
726
|
id: paymentIntent.id,
|
|
726
727
|
job: { paymentIntentId: paymentIntent.id, paymentSettings, retryOnError: false },
|
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.60",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"dev": "blocklet dev",
|
|
6
6
|
"eject": "vite eject",
|
|
@@ -104,7 +104,7 @@
|
|
|
104
104
|
"@abtnode/types": "1.16.18",
|
|
105
105
|
"@arcblock/eslint-config": "^0.2.4",
|
|
106
106
|
"@arcblock/eslint-config-ts": "^0.2.4",
|
|
107
|
-
"@did-pay/types": "1.13.
|
|
107
|
+
"@did-pay/types": "1.13.60",
|
|
108
108
|
"@types/cookie-parser": "^1.4.6",
|
|
109
109
|
"@types/cors": "^2.8.17",
|
|
110
110
|
"@types/dotenv-flow": "^3.3.3",
|
|
@@ -141,5 +141,5 @@
|
|
|
141
141
|
"parser": "typescript"
|
|
142
142
|
}
|
|
143
143
|
},
|
|
144
|
-
"gitHead": "
|
|
144
|
+
"gitHead": "8e15e9d178ebb2c038066ae2b17f95415b6919cb"
|
|
145
145
|
}
|