payment-kit 1.13.42 → 1.13.44

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,9 +1,8 @@
1
- import { toBN } from '@ocap/util';
2
-
3
1
  import { wallet } from '../libs/auth';
4
2
  import dayjs from '../libs/dayjs';
5
3
  import CustomError from '../libs/error';
6
4
  import logger from '../libs/logger';
5
+ import { isDelegationSufficientForPayment } from '../libs/payment';
7
6
  import createQueue from '../libs/queue';
8
7
  import { MAX_RETRY_COUNT, getNextRetry } from '../libs/util';
9
8
  import { CheckoutSession } from '../store/models/checkout-session';
@@ -66,10 +65,14 @@ export const handlePayment = async (job: PaymentJob) => {
66
65
  const payer = paymentSettings?.payment_method_options.arcblock?.payer;
67
66
 
68
67
  // check balance before capture
69
- const result = await client.getAccountTokens({ address: payer, token: paymentCurrency.contract });
70
- const balance = result.tokens.find((x: any) => x.address === paymentCurrency.contract)?.balance;
71
- if (balance === undefined || toBN(balance).lt(toBN(paymentIntent.amount))) {
72
- throw new CustomError('INSUFFICIENT_BALANCE', 'payer balance not enough for this payment');
68
+ const result = await isDelegationSufficientForPayment({
69
+ paymentMethod,
70
+ paymentCurrency,
71
+ userDid: payer as string,
72
+ amount: paymentIntent.amount,
73
+ });
74
+ if (result.sufficient === false) {
75
+ throw new CustomError(result.reason, 'payer balance or delegation not sufficient for this payment');
73
76
  }
74
77
 
75
78
  // do the capture
@@ -363,7 +363,10 @@ router.post('/:id/checkout/:priceId', async (req, res) => {
363
363
  behavior: 'per_checkout_session',
364
364
  factory: req.query.nft_mint_factory as string,
365
365
  };
366
+ raw.nft_mint_status = 'pending';
366
367
  logger.info('use nft_mint_settings from query when checkout from pricing table', { v: raw.nft_mint_settings });
368
+ } else {
369
+ raw.nft_mint_status = 'disabled';
367
370
  }
368
371
 
369
372
  const session = await CheckoutSession.create(raw as any);
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.13.42
17
+ version: 1.13.44
18
18
  logo: logo.png
19
19
  files:
20
20
  - dist
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "payment-kit",
3
- "version": "1.13.42",
3
+ "version": "1.13.44",
4
4
  "scripts": {
5
5
  "dev": "blocklet dev",
6
6
  "eject": "vite eject",
@@ -103,7 +103,7 @@
103
103
  "@abtnode/types": "1.16.17",
104
104
  "@arcblock/eslint-config": "^0.2.4",
105
105
  "@arcblock/eslint-config-ts": "^0.2.4",
106
- "@did-pay/types": "1.13.42",
106
+ "@did-pay/types": "1.13.44",
107
107
  "@types/cookie-parser": "^1.4.5",
108
108
  "@types/cors": "^2.8.15",
109
109
  "@types/dotenv-flow": "^3.3.2",
@@ -140,5 +140,5 @@
140
140
  "parser": "typescript"
141
141
  }
142
142
  },
143
- "gitHead": "bc5cda38ac03844a02463f1dfa129dbb556038f4"
143
+ "gitHead": "77f57fdf65d8b465f818f81f410274adf2f60bc6"
144
144
  }