payment-kit 1.13.83 → 1.13.85

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.
@@ -146,17 +146,28 @@ export const handleSubscription = async (job: SubscriptionJob) => {
146
146
  // @link https://stripe.com/docs/products-prices/pricing-models#usage-types
147
147
  if (x.price.recurring?.usage_type === 'metered') {
148
148
  const duration = setup.cycle / 1000;
149
- x.quantity = await UsageRecord.getSummary(
149
+ const rawQuantity = await UsageRecord.getSummary(
150
150
  x.id,
151
151
  // FIXME: this causes inconsistency when subscription is paused or billing_cycle_anchor reset
152
152
  setup.period.start - duration,
153
153
  setup.period.end - duration,
154
154
  x.price.recurring?.aggregate_usage
155
155
  );
156
+ if (x.price.transform_quantity) {
157
+ if (x.price.transform_quantity.round === 'up') {
158
+ x.quantity = Math.ceil(rawQuantity / x.price.transform_quantity.divide_by);
159
+ } else {
160
+ x.quantity = Math.floor(rawQuantity / x.price.transform_quantity.divide_by);
161
+ }
162
+ } else {
163
+ x.quantity = rawQuantity;
164
+ }
156
165
  logger.info('Invoice.usageRecordSummary', {
157
166
  subscriptionId: subscription.id,
158
167
  subscriptionItemId: x.id,
159
168
  priceId: x.price_id,
169
+ transformQuantity: x.price.transform_quantity,
170
+ rawQuantity,
160
171
  quantity: x.quantity,
161
172
  start: setup.period.start - duration,
162
173
  end: setup.period.end - duration,
@@ -7,7 +7,18 @@ import logger from '../libs/logger';
7
7
  import { sequelize } from './sequelize';
8
8
 
9
9
  const umzug = new Umzug({
10
- migrations: { glob: ['migrations/*.{ts,js}', { cwd: __dirname }] },
10
+ migrations: {
11
+ glob: ['migrations/*.{ts,js}', { cwd: __dirname }],
12
+ resolve: ({ name, path, context }) => {
13
+ // eslint-disable-next-line import/no-dynamic-require, global-require
14
+ const migration = require(path!);
15
+ return {
16
+ name: name.replace(/\.ts$/, '.js'),
17
+ up: () => migration.up({ context }),
18
+ down: () => migration.down({ context }),
19
+ };
20
+ },
21
+ },
11
22
  context: sequelize.getQueryInterface(),
12
23
  storage: new SequelizeStorage({ sequelize }),
13
24
  logger,
@@ -254,6 +254,8 @@ export class Price extends Model<InferAttributes<Price>, InferCreationAttributes
254
254
 
255
255
  if (price.model !== 'package') {
256
256
  price.transform_quantity = null;
257
+ } else if (price.transform_quantity) {
258
+ price.transform_quantity.divide_by = Number(price.transform_quantity.divide_by) || 1;
257
259
  }
258
260
  }
259
261
 
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.83
17
+ version: 1.13.85
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.83",
3
+ "version": "1.13.85",
4
4
  "scripts": {
5
5
  "dev": "COMPONENT_STORE_URL=https://test.store.blocklet.dev blocklet dev",
6
6
  "eject": "vite eject",
@@ -52,7 +52,7 @@
52
52
  "@blocklet/logger": "1.16.21-beta-e828f413",
53
53
  "@blocklet/sdk": "1.16.21-beta-e828f413",
54
54
  "@blocklet/ui-react": "^2.8.23",
55
- "@blocklet/uploader": "^0.0.55",
55
+ "@blocklet/uploader": "^0.0.56",
56
56
  "@mui/icons-material": "^5.14.19",
57
57
  "@mui/lab": "^5.0.0-alpha.155",
58
58
  "@mui/material": "^5.14.20",
@@ -110,7 +110,7 @@
110
110
  "@abtnode/types": "1.16.21-beta-e828f413",
111
111
  "@arcblock/eslint-config": "^0.2.4",
112
112
  "@arcblock/eslint-config-ts": "^0.2.4",
113
- "@did-pay/types": "1.13.83",
113
+ "@did-pay/types": "1.13.85",
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": "e6357508c38296224f7c493b6630a45fd359d6bc"
152
+ "gitHead": "3d976b6a4bb4c0f910ddda7a60d42ec0e08ea5d9"
153
153
  }
@@ -65,7 +65,7 @@ export default function Uploader({ onUploaded, preview, maxFileSize, allowedFile
65
65
 
66
66
  Uploader.defaultProps = {
67
67
  preview: '',
68
- maxFileSize: 1024 * 1024 * 2,
68
+ maxFileSize: undefined,
69
69
  allowedFileTypes: ['image/png', 'image/jpeg', 'image/webp'],
70
70
  };
71
71