payment-kit 1.13.15

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.
Files changed (222) hide show
  1. package/.eslintrc.js +15 -0
  2. package/README.md +3 -0
  3. package/api/dev.ts +6 -0
  4. package/api/hooks/pre-start.js +12 -0
  5. package/api/src/hooks/pre-start.ts +21 -0
  6. package/api/src/index.ts +92 -0
  7. package/api/src/jobs/event.ts +72 -0
  8. package/api/src/jobs/invoice.ts +148 -0
  9. package/api/src/jobs/payment.ts +208 -0
  10. package/api/src/jobs/subscription.ts +301 -0
  11. package/api/src/jobs/webhook.ts +113 -0
  12. package/api/src/libs/audit.ts +73 -0
  13. package/api/src/libs/auth.ts +40 -0
  14. package/api/src/libs/chain/arcblock.ts +13 -0
  15. package/api/src/libs/dayjs.ts +17 -0
  16. package/api/src/libs/env.ts +5 -0
  17. package/api/src/libs/hooks.ts +42 -0
  18. package/api/src/libs/logger.ts +27 -0
  19. package/api/src/libs/middleware.ts +12 -0
  20. package/api/src/libs/payment.ts +53 -0
  21. package/api/src/libs/queue/index.ts +263 -0
  22. package/api/src/libs/queue/store.ts +47 -0
  23. package/api/src/libs/security.ts +95 -0
  24. package/api/src/libs/session.ts +164 -0
  25. package/api/src/libs/util.ts +93 -0
  26. package/api/src/locales/en.ts +3 -0
  27. package/api/src/locales/index.ts +37 -0
  28. package/api/src/locales/zh.ts +3 -0
  29. package/api/src/routes/checkout-sessions.ts +536 -0
  30. package/api/src/routes/connect/collect.ts +109 -0
  31. package/api/src/routes/connect/pay.ts +116 -0
  32. package/api/src/routes/connect/setup.ts +121 -0
  33. package/api/src/routes/connect/shared.ts +410 -0
  34. package/api/src/routes/connect/subscribe.ts +128 -0
  35. package/api/src/routes/customers.ts +70 -0
  36. package/api/src/routes/events.ts +76 -0
  37. package/api/src/routes/index.ts +59 -0
  38. package/api/src/routes/invoices.ts +126 -0
  39. package/api/src/routes/payment-currencies.ts +38 -0
  40. package/api/src/routes/payment-intents.ts +122 -0
  41. package/api/src/routes/payment-links.ts +221 -0
  42. package/api/src/routes/payment-methods.ts +39 -0
  43. package/api/src/routes/prices.ts +134 -0
  44. package/api/src/routes/products.ts +191 -0
  45. package/api/src/routes/settings.ts +33 -0
  46. package/api/src/routes/subscription-items.ts +148 -0
  47. package/api/src/routes/subscriptions.ts +254 -0
  48. package/api/src/routes/usage-records.ts +120 -0
  49. package/api/src/routes/webhook-attempts.ts +57 -0
  50. package/api/src/routes/webhook-endpoints.ts +105 -0
  51. package/api/src/store/migrate.ts +16 -0
  52. package/api/src/store/migrations/20230905-genesis.ts +52 -0
  53. package/api/src/store/migrations/20230911-seeding.ts +145 -0
  54. package/api/src/store/models/checkout-session.ts +395 -0
  55. package/api/src/store/models/coupon.ts +137 -0
  56. package/api/src/store/models/customer.ts +199 -0
  57. package/api/src/store/models/discount.ts +116 -0
  58. package/api/src/store/models/event.ts +111 -0
  59. package/api/src/store/models/index.ts +165 -0
  60. package/api/src/store/models/invoice-item.ts +185 -0
  61. package/api/src/store/models/invoice.ts +492 -0
  62. package/api/src/store/models/job.ts +75 -0
  63. package/api/src/store/models/payment-currency.ts +139 -0
  64. package/api/src/store/models/payment-intent.ts +282 -0
  65. package/api/src/store/models/payment-link.ts +219 -0
  66. package/api/src/store/models/payment-method.ts +169 -0
  67. package/api/src/store/models/price.ts +266 -0
  68. package/api/src/store/models/product.ts +162 -0
  69. package/api/src/store/models/promotion-code.ts +112 -0
  70. package/api/src/store/models/setup-intent.ts +206 -0
  71. package/api/src/store/models/subscription-item.ts +103 -0
  72. package/api/src/store/models/subscription-schedule.ts +157 -0
  73. package/api/src/store/models/subscription.ts +307 -0
  74. package/api/src/store/models/types.ts +406 -0
  75. package/api/src/store/models/usage-record.ts +132 -0
  76. package/api/src/store/models/webhook-attempt.ts +96 -0
  77. package/api/src/store/models/webhook-endpoint.ts +96 -0
  78. package/api/src/store/sequelize.ts +15 -0
  79. package/api/third.d.ts +28 -0
  80. package/blocklet.md +3 -0
  81. package/blocklet.yml +89 -0
  82. package/index.html +14 -0
  83. package/logo.png +0 -0
  84. package/package.json +133 -0
  85. package/public/.gitkeep +0 -0
  86. package/screenshots/.gitkeep +0 -0
  87. package/screenshots/1-subscription.png +0 -0
  88. package/screenshots/2-customer-1.png +0 -0
  89. package/screenshots/3-customer-2.png +0 -0
  90. package/screenshots/4-admin-3.png +0 -0
  91. package/screenshots/5-admin-4.png +0 -0
  92. package/scripts/build-clean.js +6 -0
  93. package/scripts/bump-version.mjs +35 -0
  94. package/src/app.tsx +68 -0
  95. package/src/components/actions.tsx +85 -0
  96. package/src/components/blockchain/tx.tsx +29 -0
  97. package/src/components/checkout/amount.tsx +24 -0
  98. package/src/components/checkout/error.tsx +30 -0
  99. package/src/components/checkout/footer.tsx +12 -0
  100. package/src/components/checkout/form/address.tsx +38 -0
  101. package/src/components/checkout/form/index.tsx +295 -0
  102. package/src/components/checkout/header.tsx +23 -0
  103. package/src/components/checkout/pay.tsx +222 -0
  104. package/src/components/checkout/product-card.tsx +56 -0
  105. package/src/components/checkout/product-item.tsx +37 -0
  106. package/src/components/checkout/skeleton/overview.tsx +21 -0
  107. package/src/components/checkout/skeleton/payment.tsx +35 -0
  108. package/src/components/checkout/success.tsx +183 -0
  109. package/src/components/checkout/summary.tsx +34 -0
  110. package/src/components/collapse.tsx +50 -0
  111. package/src/components/confirm.tsx +55 -0
  112. package/src/components/copyable.tsx +38 -0
  113. package/src/components/currency.tsx +15 -0
  114. package/src/components/customer/actions.tsx +73 -0
  115. package/src/components/data.tsx +20 -0
  116. package/src/components/drawer-form.tsx +77 -0
  117. package/src/components/error-fallback.tsx +7 -0
  118. package/src/components/error.tsx +39 -0
  119. package/src/components/event/list.tsx +217 -0
  120. package/src/components/info-card.tsx +40 -0
  121. package/src/components/info-metric.tsx +35 -0
  122. package/src/components/info-row.tsx +28 -0
  123. package/src/components/input.tsx +40 -0
  124. package/src/components/invoice/action.tsx +94 -0
  125. package/src/components/invoice/list.tsx +225 -0
  126. package/src/components/invoice/table.tsx +110 -0
  127. package/src/components/layout.tsx +70 -0
  128. package/src/components/livemode.tsx +23 -0
  129. package/src/components/metadata/editor.tsx +57 -0
  130. package/src/components/metadata/form.tsx +45 -0
  131. package/src/components/payment-intent/actions.tsx +81 -0
  132. package/src/components/payment-intent/list.tsx +204 -0
  133. package/src/components/payment-link/actions.tsx +114 -0
  134. package/src/components/payment-link/after-pay.tsx +87 -0
  135. package/src/components/payment-link/before-pay.tsx +175 -0
  136. package/src/components/payment-link/item.tsx +135 -0
  137. package/src/components/payment-link/product-select.tsx +66 -0
  138. package/src/components/payment-link/rename.tsx +64 -0
  139. package/src/components/portal/invoice/list.tsx +110 -0
  140. package/src/components/portal/subscription/cancel.tsx +83 -0
  141. package/src/components/portal/subscription/list.tsx +232 -0
  142. package/src/components/price/actions.tsx +21 -0
  143. package/src/components/price/form.tsx +292 -0
  144. package/src/components/product/actions.tsx +125 -0
  145. package/src/components/product/add-price.tsx +59 -0
  146. package/src/components/product/create.tsx +97 -0
  147. package/src/components/product/edit-price.tsx +75 -0
  148. package/src/components/product/edit.tsx +67 -0
  149. package/src/components/product/features.tsx +32 -0
  150. package/src/components/product/form.tsx +76 -0
  151. package/src/components/relative-time.tsx +41 -0
  152. package/src/components/section/header.tsx +29 -0
  153. package/src/components/status.tsx +12 -0
  154. package/src/components/subscription/actions/cancel.tsx +66 -0
  155. package/src/components/subscription/actions/index.tsx +172 -0
  156. package/src/components/subscription/actions/pause.tsx +83 -0
  157. package/src/components/subscription/items/actions.tsx +31 -0
  158. package/src/components/subscription/items/index.tsx +107 -0
  159. package/src/components/subscription/list.tsx +200 -0
  160. package/src/components/switch.tsx +48 -0
  161. package/src/components/table.tsx +66 -0
  162. package/src/components/uploader.tsx +81 -0
  163. package/src/components/webhook/attempts.tsx +149 -0
  164. package/src/contexts/products.tsx +42 -0
  165. package/src/contexts/session.ts +10 -0
  166. package/src/contexts/settings.tsx +54 -0
  167. package/src/env.d.ts +17 -0
  168. package/src/global.css +97 -0
  169. package/src/hooks/mobile.ts +15 -0
  170. package/src/index.tsx +6 -0
  171. package/src/libs/api.ts +19 -0
  172. package/src/libs/dayjs.ts +17 -0
  173. package/src/libs/util.ts +474 -0
  174. package/src/locales/en.tsx +395 -0
  175. package/src/locales/index.tsx +8 -0
  176. package/src/locales/zh.tsx +389 -0
  177. package/src/pages/admin/billing/index.tsx +56 -0
  178. package/src/pages/admin/billing/invoices/detail.tsx +215 -0
  179. package/src/pages/admin/billing/invoices/index.tsx +5 -0
  180. package/src/pages/admin/billing/subscriptions/detail.tsx +237 -0
  181. package/src/pages/admin/billing/subscriptions/index.tsx +5 -0
  182. package/src/pages/admin/customers/customers/detail.tsx +209 -0
  183. package/src/pages/admin/customers/customers/index.tsx +109 -0
  184. package/src/pages/admin/customers/index.tsx +47 -0
  185. package/src/pages/admin/developers/events/detail.tsx +77 -0
  186. package/src/pages/admin/developers/events/index.tsx +5 -0
  187. package/src/pages/admin/developers/index.tsx +60 -0
  188. package/src/pages/admin/developers/logs.tsx +3 -0
  189. package/src/pages/admin/developers/overview.tsx +3 -0
  190. package/src/pages/admin/developers/webhooks/detail.tsx +109 -0
  191. package/src/pages/admin/developers/webhooks/index.tsx +102 -0
  192. package/src/pages/admin/index.tsx +120 -0
  193. package/src/pages/admin/overview.tsx +3 -0
  194. package/src/pages/admin/payments/index.tsx +65 -0
  195. package/src/pages/admin/payments/intents/detail.tsx +205 -0
  196. package/src/pages/admin/payments/intents/index.tsx +5 -0
  197. package/src/pages/admin/payments/links/create.tsx +141 -0
  198. package/src/pages/admin/payments/links/detail.tsx +318 -0
  199. package/src/pages/admin/payments/links/index.tsx +167 -0
  200. package/src/pages/admin/products/coupons/index.tsx +3 -0
  201. package/src/pages/admin/products/index.tsx +81 -0
  202. package/src/pages/admin/products/prices/actions.tsx +151 -0
  203. package/src/pages/admin/products/prices/detail.tsx +203 -0
  204. package/src/pages/admin/products/prices/list.tsx +95 -0
  205. package/src/pages/admin/products/pricing-tables.tsx +3 -0
  206. package/src/pages/admin/products/products/create.tsx +105 -0
  207. package/src/pages/admin/products/products/detail.tsx +246 -0
  208. package/src/pages/admin/products/products/index.tsx +154 -0
  209. package/src/pages/admin/settings/branding.tsx +3 -0
  210. package/src/pages/admin/settings/business.tsx +3 -0
  211. package/src/pages/admin/settings/index.tsx +47 -0
  212. package/src/pages/admin/settings/payment-methods.tsx +80 -0
  213. package/src/pages/checkout/index.tsx +38 -0
  214. package/src/pages/checkout/pay.tsx +89 -0
  215. package/src/pages/customer/index.tsx +93 -0
  216. package/src/pages/customer/invoice.tsx +147 -0
  217. package/src/pages/home.tsx +9 -0
  218. package/tsconfig.api.json +9 -0
  219. package/tsconfig.eslint.json +7 -0
  220. package/tsconfig.json +99 -0
  221. package/tsconfig.types.json +11 -0
  222. package/vite.config.ts +19 -0
@@ -0,0 +1,132 @@
1
+ import { CreationOptional, DataTypes, InferAttributes, InferCreationAttributes, Model, Op } from 'sequelize';
2
+ import type { LiteralUnion } from 'type-fest';
3
+
4
+ import { createIdGenerator } from '../../libs/util';
5
+
6
+ const nextId = createIdGenerator('mbur', 24);
7
+
8
+ // eslint-disable-next-line prettier/prettier
9
+ export class UsageRecord extends Model<InferAttributes<UsageRecord>, InferCreationAttributes<UsageRecord>> {
10
+ declare id: CreationOptional<string>;
11
+
12
+ declare livemode: boolean;
13
+
14
+ // The timestamp when this usage occurred.
15
+ declare timestamp: number;
16
+
17
+ // The usage quantity for the specified date.
18
+ declare quantity: number;
19
+
20
+ // The ID of the subscription item this usage record contains data for.
21
+ declare subscription_item_id: string;
22
+
23
+ // Props only exist on creation
24
+ // declare action: LiteralUnion<'increment' | 'set', string>;
25
+
26
+ declare metadata: Record<string, any>;
27
+
28
+ declare created_at: CreationOptional<Date>;
29
+ declare updated_at: CreationOptional<Date>;
30
+
31
+ public static readonly GENESIS_ATTRIBUTES = {
32
+ id: {
33
+ type: DataTypes.STRING(30),
34
+ primaryKey: true,
35
+ allowNull: false,
36
+ defaultValue: nextId,
37
+ },
38
+ livemode: {
39
+ type: DataTypes.BOOLEAN,
40
+ allowNull: false,
41
+ },
42
+ timestamp: {
43
+ type: DataTypes.INTEGER,
44
+ allowNull: false,
45
+ },
46
+ quantity: {
47
+ type: DataTypes.BIGINT,
48
+ allowNull: false,
49
+ },
50
+ subscription_item_id: {
51
+ type: DataTypes.STRING(30),
52
+ allowNull: false,
53
+ },
54
+ metadata: {
55
+ type: DataTypes.JSON,
56
+ allowNull: true,
57
+ },
58
+ created_at: {
59
+ type: DataTypes.DATE,
60
+ defaultValue: DataTypes.NOW,
61
+ allowNull: false,
62
+ },
63
+ updated_at: {
64
+ type: DataTypes.DATE,
65
+ defaultValue: DataTypes.NOW,
66
+ allowNull: false,
67
+ },
68
+ };
69
+
70
+ public static initialize(sequelize: any) {
71
+ this.init(UsageRecord.GENESIS_ATTRIBUTES, {
72
+ sequelize,
73
+ modelName: 'UsageRecord',
74
+ tableName: 'usage_records',
75
+ createdAt: 'created_at',
76
+ updatedAt: 'updated_at',
77
+ });
78
+ }
79
+
80
+ public static associate(models: any) {
81
+ this.belongsTo(models.SubscriptionItem, {
82
+ foreignKey: 'subscription_item_id',
83
+ as: 'subscription_item',
84
+ });
85
+ }
86
+
87
+ public static async getSummary(
88
+ subscription_item_id: string,
89
+ period_start: number,
90
+ period_end: number,
91
+ method: LiteralUnion<'sum' | 'last_during_period' | 'max' | 'last_ever', string>
92
+ ): Promise<number> {
93
+ const query = {
94
+ where: {
95
+ subscription_item_id,
96
+ timestamp: {
97
+ [Op.gte]: period_start,
98
+ [Op.lt]: period_end,
99
+ },
100
+ },
101
+ order: [['timestamp', 'DESC']],
102
+ };
103
+
104
+ if (method === 'sum') {
105
+ const sum = await this.sum('quantity', query);
106
+ return sum || 0;
107
+ }
108
+
109
+ if (method === 'max') {
110
+ const max = await this.max('quantity', query);
111
+ return (max as number) || 0;
112
+ }
113
+
114
+ if (method === 'last_during_period') {
115
+ // @ts-ignore
116
+ const item = await this.findOne(query);
117
+ return item ? item.quantity : 0;
118
+ }
119
+
120
+ if (method === 'last_ever') {
121
+ const item = await this.findOne({
122
+ where: { subscription_item_id },
123
+ order: [['timestamp', 'DESC']],
124
+ });
125
+ return item ? item.quantity : 0;
126
+ }
127
+
128
+ return 0;
129
+ }
130
+ }
131
+
132
+ export type TUsageRecord = InferAttributes<UsageRecord>;
@@ -0,0 +1,96 @@
1
+ import { CreationOptional, DataTypes, InferAttributes, InferCreationAttributes, Model } from 'sequelize';
2
+ import type { LiteralUnion } from 'type-fest';
3
+
4
+ import { createIdGenerator } from '../../libs/util';
5
+
6
+ const nextId = createIdGenerator('wa', 24);
7
+
8
+ // eslint-disable-next-line prettier/prettier
9
+ export class WebhookAttempt extends Model<InferAttributes<WebhookAttempt>, InferCreationAttributes<WebhookAttempt>> {
10
+ declare id: CreationOptional<string>;
11
+ declare livemode: boolean;
12
+
13
+ declare event_id: string;
14
+ declare webhook_endpoint_id: string;
15
+
16
+ declare status: LiteralUnion<'succeeded' | 'failed', string>;
17
+ declare response_status: number;
18
+ declare response_body: any;
19
+
20
+ declare retry_count: number;
21
+
22
+ declare created_at: CreationOptional<Date>;
23
+ declare updated_at: CreationOptional<Date>;
24
+
25
+ public static readonly GENESIS_ATTRIBUTES = {
26
+ id: {
27
+ type: DataTypes.STRING(30),
28
+ primaryKey: true,
29
+ allowNull: false,
30
+ defaultValue: nextId,
31
+ },
32
+ livemode: {
33
+ type: DataTypes.BOOLEAN,
34
+ allowNull: false,
35
+ },
36
+ event_id: {
37
+ type: DataTypes.STRING(30),
38
+ allowNull: false,
39
+ },
40
+ webhook_endpoint_id: {
41
+ type: DataTypes.STRING(30),
42
+ allowNull: false,
43
+ },
44
+ status: {
45
+ type: DataTypes.ENUM('enabled', 'disabled'),
46
+ allowNull: false,
47
+ },
48
+ response_status: {
49
+ type: DataTypes.INTEGER,
50
+ allowNull: false,
51
+ },
52
+ response_body: {
53
+ type: DataTypes.JSON,
54
+ allowNull: false,
55
+ },
56
+ retry_count: {
57
+ type: DataTypes.INTEGER,
58
+ defaultValue: 0,
59
+ },
60
+ created_at: {
61
+ type: DataTypes.DATE,
62
+ defaultValue: DataTypes.NOW,
63
+ allowNull: false,
64
+ },
65
+ updated_at: {
66
+ type: DataTypes.DATE,
67
+ defaultValue: DataTypes.NOW,
68
+ allowNull: false,
69
+ },
70
+ };
71
+
72
+ public static initialize(sequelize: any) {
73
+ this.init(WebhookAttempt.GENESIS_ATTRIBUTES, {
74
+ sequelize,
75
+ modelName: 'WebhookAttempt',
76
+ tableName: 'webhook_attempts',
77
+ createdAt: 'created_at',
78
+ updatedAt: 'updated_at',
79
+ });
80
+ }
81
+
82
+ public static associate(models: any) {
83
+ this.hasOne(models.WebhookEndpoint, {
84
+ sourceKey: 'webhook_endpoint_id',
85
+ foreignKey: 'id',
86
+ as: 'endpoint',
87
+ });
88
+ this.hasOne(models.Event, {
89
+ sourceKey: 'event_id',
90
+ foreignKey: 'id',
91
+ as: 'event',
92
+ });
93
+ }
94
+ }
95
+
96
+ export type TWebhookAttempt = InferAttributes<WebhookAttempt>;
@@ -0,0 +1,96 @@
1
+ import { CreationOptional, DataTypes, InferAttributes, InferCreationAttributes, Model } from 'sequelize';
2
+ import type { LiteralUnion } from 'type-fest';
3
+
4
+ import { createIdGenerator } from '../../libs/util';
5
+ import type { EventType } from './types';
6
+
7
+ const nextId = createIdGenerator('we', 24);
8
+
9
+ // eslint-disable-next-line prettier/prettier
10
+ export class WebhookEndpoint extends Model<InferAttributes<WebhookEndpoint>, InferCreationAttributes<WebhookEndpoint>> {
11
+ declare id: CreationOptional<string>;
12
+ declare livemode: boolean;
13
+ declare api_version: string;
14
+
15
+ declare url: string;
16
+ declare description: string;
17
+ declare enabled_events: EventType[];
18
+
19
+ declare metadata: Record<string, any>;
20
+
21
+ declare status: LiteralUnion<'enabled' | 'disabled', string>;
22
+
23
+ declare created_at: CreationOptional<Date>;
24
+ declare created_via: LiteralUnion<'api' | 'dashboard' | 'portal', string>;
25
+ declare updated_at: CreationOptional<Date>;
26
+
27
+ public static readonly GENESIS_ATTRIBUTES = {
28
+ id: {
29
+ type: DataTypes.STRING(30),
30
+ primaryKey: true,
31
+ allowNull: false,
32
+ defaultValue: nextId,
33
+ },
34
+ livemode: {
35
+ type: DataTypes.BOOLEAN,
36
+ allowNull: false,
37
+ },
38
+ api_version: {
39
+ type: DataTypes.STRING(16),
40
+ allowNull: false,
41
+ },
42
+ url: {
43
+ type: DataTypes.STRING(512),
44
+ allowNull: false,
45
+ },
46
+ description: {
47
+ type: DataTypes.STRING(512),
48
+ allowNull: true,
49
+ },
50
+ enabled_events: {
51
+ type: DataTypes.JSON,
52
+ allowNull: false,
53
+ },
54
+ metadata: {
55
+ type: DataTypes.JSON,
56
+ allowNull: true,
57
+ },
58
+ status: {
59
+ type: DataTypes.ENUM('enabled', 'disabled'),
60
+ allowNull: false,
61
+ },
62
+ created_at: {
63
+ type: DataTypes.DATE,
64
+ defaultValue: DataTypes.NOW,
65
+ allowNull: false,
66
+ },
67
+ created_via: {
68
+ type: DataTypes.ENUM('api', 'dashboard', 'portal'),
69
+ },
70
+ updated_at: {
71
+ type: DataTypes.DATE,
72
+ defaultValue: DataTypes.NOW,
73
+ allowNull: false,
74
+ },
75
+ };
76
+
77
+ public static initialize(sequelize: any) {
78
+ this.init(WebhookEndpoint.GENESIS_ATTRIBUTES, {
79
+ sequelize,
80
+ modelName: 'WebhookEndpoint',
81
+ tableName: 'webhook_endpoints',
82
+ createdAt: 'created_at',
83
+ updatedAt: 'updated_at',
84
+ });
85
+ }
86
+
87
+ public static associate(models: any) {
88
+ this.hasMany(models.WebhookAttempt, {
89
+ sourceKey: 'id',
90
+ foreignKey: 'webhook_endpoint_id',
91
+ as: 'attempts',
92
+ });
93
+ }
94
+ }
95
+
96
+ export type TWebhookEndpoint = InferAttributes<WebhookEndpoint>;
@@ -0,0 +1,15 @@
1
+ // NOTE: add next line to keep sqlite3 in the bundle
2
+ import 'sqlite3';
3
+
4
+ import { join } from 'path';
5
+
6
+ import { Sequelize } from 'sequelize';
7
+
8
+ import env from '../libs/env';
9
+
10
+ // eslint-disable-next-line import/prefer-default-export
11
+ export const sequelize = new Sequelize({
12
+ dialect: 'sqlite',
13
+ logging: false,
14
+ storage: join(env.dataDir, 'payment-kit.db'),
15
+ });
package/api/third.d.ts ADDED
@@ -0,0 +1,28 @@
1
+ declare module 'vite-plugin-blocklet';
2
+
3
+ declare module 'express-history-api-fallback';
4
+
5
+ declare module 'express-async-errors';
6
+
7
+ declare module 'morgan';
8
+
9
+ declare module 'flat';
10
+
11
+ namespace Express {
12
+ interface Request {
13
+ user?: {
14
+ did: string;
15
+ role: string;
16
+ provider: string;
17
+ fullName: string;
18
+ walletOS: string;
19
+ via?: string;
20
+ };
21
+ livemode?: boolean;
22
+ locale: string;
23
+ t: (key: string, ...args: any[]) => string;
24
+ doc?: any;
25
+ customer?: any;
26
+ currency: any;
27
+ }
28
+ }
package/blocklet.md ADDED
@@ -0,0 +1,3 @@
1
+ # Payment Kit
2
+
3
+ The decentralized stripe alike payment solution for blocklet platform.
package/blocklet.yml ADDED
@@ -0,0 +1,89 @@
1
+ name: z2qaCNvKMv5GjouKdcDWexv6WqtHbpNPQDnAk
2
+ title: Payment Kit
3
+ description: The decentralized stripe alike payment solution for blocklets.
4
+ keywords:
5
+ - payment
6
+ - stripe
7
+ group: dapp
8
+ did: z2qaCNvKMv5GjouKdcDWexv6WqtHbpNPQDnAk
9
+ main: api/dist/index.js
10
+ author:
11
+ name: wangshijun
12
+ email: wangshijun2010@gmail.com
13
+ repository:
14
+ type: git
15
+ url: git+https://github.com/blocklet/payment-kit.git
16
+ specVersion: 1.2.8
17
+ version: 1.13.15
18
+ logo: logo.png
19
+ files:
20
+ - dist
21
+ - logo.png
22
+ - screenshots
23
+ - api/dist/store/migrate.js
24
+ - api/dist/store/migrations/*.js
25
+ - api/hooks/pre-start.js
26
+ interfaces:
27
+ - type: web
28
+ name: publicUrl
29
+ path: /
30
+ prefix: '*'
31
+ port: BLOCKLET_PORT
32
+ protocol: http
33
+ community: ''
34
+ documentation: ''
35
+ homepage: ''
36
+ license: ''
37
+ payment:
38
+ price: []
39
+ share: []
40
+ timeout:
41
+ start: 60
42
+ requirements:
43
+ server: '>=1.16.15'
44
+ os: '*'
45
+ cpu: '*'
46
+ scripts:
47
+ preStart: node api/hooks/pre-start.js
48
+ dev: npm run start
49
+ environments: []
50
+ capabilities:
51
+ navigation: true
52
+ screenshots:
53
+ - 1-subscription.png
54
+ - 2-customer-1.png
55
+ - 3-customer-2.png
56
+ - 4-admin-3.png
57
+ - 5-admin-4.png
58
+ components:
59
+ - name: image-bin
60
+ required: true
61
+ source:
62
+ store: https://test.store.blocklet.dev
63
+ name: image-bin
64
+ version: latest
65
+ navigation:
66
+ - id: payments
67
+ title:
68
+ en: Payments
69
+ zh: 支付管理
70
+ icon: ion:card-outline
71
+ link: /admin
72
+ section:
73
+ - dashboard
74
+ role:
75
+ - admin
76
+ - owner
77
+ - id: billing
78
+ title:
79
+ en: Billing
80
+ zh: 订阅管理
81
+ icon: ion:receipt-outline
82
+ link: /customer
83
+ section:
84
+ - dashboard
85
+ role:
86
+ - owner
87
+ - admin
88
+ - member
89
+ - guest
package/index.html ADDED
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <link rel="icon" href="/favicon.ico?imageFilter=resize&w=32" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
7
+ <meta name="theme-color" content="#4F6AF5" />
8
+ </head>
9
+ <body>
10
+ <noscript>You need to enable JavaScript to run this app. </noscript>
11
+ <div id="app"></div>
12
+ <script type="module" src="/src/index.tsx"></script>
13
+ </body>
14
+ </html>
package/logo.png ADDED
Binary file
package/package.json ADDED
@@ -0,0 +1,133 @@
1
+ {
2
+ "name": "payment-kit",
3
+ "version": "1.13.15",
4
+ "scripts": {
5
+ "dev": "blocklet dev",
6
+ "eject": "vite eject",
7
+ "lint": "tsc --noEmit && eslint src api/src --ext .mjs,.js,.jsx,.ts,.tsx",
8
+ "lint:fix": "npm run lint -- --fix",
9
+ "format": "prettier -w src",
10
+ "start": "cross-env NODE_ENV=development nodemon api/dev.ts -w api",
11
+ "clean": "node scripts/build-clean.js",
12
+ "bundle": "tsc --noEmit && npm run bundle:client && npm run bundle:api",
13
+ "bundle:client": "vite build",
14
+ "bundle:api": "npm run clean && tsc -p tsconfig.api.json && blocklet bundle --zip --create-release",
15
+ "build": "npm run clean && tsc -p tsconfig.api.json && npm run bundle:client",
16
+ "types": "rm -rf types && tsc -p tsconfig.types.json && rm -f ../../packages/types/lib/*.d.ts && cp -f types/store/models/*.d.ts ../../packages/types/lib",
17
+ "deploy": "npm run bundle && blocklet deploy .blocklet/bundle",
18
+ "upload": "npm run bundle && blocklet upload .blocklet/release/blocklet.json",
19
+ "bump-version": "zx --quiet scripts/bump-version.mjs"
20
+ },
21
+ "lint-staged": {
22
+ "*.{mjs,js,jsx,ts,tsx}": [
23
+ "prettier --write",
24
+ "eslint"
25
+ ],
26
+ "*.{css,less,scss,json,graphql}": [
27
+ "prettier --write"
28
+ ]
29
+ },
30
+ "browserslist": {
31
+ "production": [
32
+ ">0.2%",
33
+ "not dead",
34
+ "not op_mini all"
35
+ ],
36
+ "development": [
37
+ "last 1 chrome version",
38
+ "last 1 firefox version",
39
+ "last 1 safari version"
40
+ ]
41
+ },
42
+ "dependencies": {
43
+ "@arcblock/did": "^1.18.92",
44
+ "@arcblock/did-auth-storage-nedb": "^1.7.1",
45
+ "@arcblock/did-connect": "^2.7.27",
46
+ "@arcblock/did-util": "^1.18.92",
47
+ "@arcblock/ux": "^2.7.27",
48
+ "@blocklet/logger": "^1.16.16",
49
+ "@blocklet/sdk": "^1.16.16",
50
+ "@blocklet/ui-react": "^2.7.27",
51
+ "@blocklet/uploader": "^0.0.26",
52
+ "@mui/icons-material": "^5.14.8",
53
+ "@mui/lab": "^5.0.0-alpha.145",
54
+ "@mui/material": "^5.14.8",
55
+ "@mui/styles": "^5.14.7",
56
+ "@mui/system": "^5.14.8",
57
+ "@ocap/client": "^1.18.92",
58
+ "@ocap/mcrypto": "^1.18.92",
59
+ "@ocap/util": "^1.18.92",
60
+ "@ocap/wallet": "^1.18.92",
61
+ "ahooks": "^3.7.8",
62
+ "axios": "^0.27.2",
63
+ "cookie-parser": "^1.4.6",
64
+ "cors": "^2.8.5",
65
+ "dayjs": "^1.11.9",
66
+ "dotenv-flow": "^3.2.0",
67
+ "express": "^4.18.2",
68
+ "express-async-errors": "^3.1.1",
69
+ "express-history-api-fallback": "^2.2.1",
70
+ "fastq": "^1.15.0",
71
+ "flat": "^5.0.2",
72
+ "iframe-resizer-react": "^1.1.0",
73
+ "joi": "^17.10.1",
74
+ "json-stable-stringify": "^1.0.2",
75
+ "lodash": "^4.17.21",
76
+ "morgan": "^1.10.0",
77
+ "nanoid": "3",
78
+ "p-wait-for": "^5.0.2",
79
+ "pretty-ms-i18n": "^1.0.3",
80
+ "react": "^18.2.0",
81
+ "react-dom": "^18.2.0",
82
+ "react-error-boundary": "^4.0.11",
83
+ "react-hook-form": "^7.46.1",
84
+ "react-router-dom": "^6.14.2",
85
+ "rimraf": "^3.0.2",
86
+ "sequelize": "^6.33.0",
87
+ "sqlite3": "^5.1.6",
88
+ "ufo": "^1.3.0",
89
+ "umzug": "^3.3.1",
90
+ "use-bus": "^2.5.2"
91
+ },
92
+ "devDependencies": {
93
+ "@arcblock/eslint-config": "^0.2.4",
94
+ "@arcblock/eslint-config-ts": "^0.2.4",
95
+ "@did-pay/types": "1.13.15",
96
+ "@types/cookie-parser": "^1.4.3",
97
+ "@types/cors": "^2.8.13",
98
+ "@types/dotenv-flow": "^3.2.0",
99
+ "@types/express": "^4.17.17",
100
+ "@types/node": "^18.17.1",
101
+ "@types/react": "^18.2.16",
102
+ "@types/react-dom": "^18.2.7",
103
+ "@vitejs/plugin-react": "^2.2.0",
104
+ "bumpp": "^8.2.1",
105
+ "cross-env": "^7.0.3",
106
+ "eslint": "^8.45.0",
107
+ "import-sort-style-module": "^6.0.0",
108
+ "lint-staged": "^12.5.0",
109
+ "nodemon": "^2.0.22",
110
+ "npm-run-all": "^4.1.5",
111
+ "prettier": "^2.8.8",
112
+ "prettier-plugin-import-sort": "^0.0.7",
113
+ "ts-node": "^10.9.1",
114
+ "type-fest": "^4.3.1",
115
+ "typescript": "^4.9.5",
116
+ "vite": "^4.4.7",
117
+ "vite-plugin-blocklet": "^0.6.15",
118
+ "vite-plugin-node-polyfills": "^0.7.0",
119
+ "vite-plugin-svgr": "^2.4.0",
120
+ "zx": "^7.2.3"
121
+ },
122
+ "importSort": {
123
+ ".js, .jsx, .mjs": {
124
+ "parser": "babylon",
125
+ "style": "module"
126
+ },
127
+ ".ts, .tsx": {
128
+ "style": "module",
129
+ "parser": "typescript"
130
+ }
131
+ },
132
+ "gitHead": "806b7f99c61884fd1f0ff60d14f44165448ce5c7"
133
+ }
File without changes
File without changes
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,6 @@
1
+ const rimraf = require('rimraf');
2
+
3
+ console.log('clean .blocklet folder');
4
+ rimraf.sync('.blocklet');
5
+ rimraf.sync('api/dist');
6
+ console.log('clean .blocklet folder done!');
@@ -0,0 +1,35 @@
1
+ /* eslint-disable no-console */
2
+ import { execSync } from 'child_process';
3
+ import { $, chalk, fs } from 'zx';
4
+
5
+ execSync('bumpp --no-tag --no-commit --no-push package.json', { stdio: 'inherit' });
6
+
7
+ const { version } = await fs.readJSON('package.json');
8
+ await fs.writeFileSync('version', version);
9
+
10
+ console.log(chalk.greenBright(`[info]: start to modify blocklet version to ${version}`));
11
+ await $`blocklet version ${version}`;
12
+ console.log(chalk.greenBright('[info]: blocklet version modified.'));
13
+
14
+ let newChangelog = '';
15
+ try {
16
+ const gitRes = await $`git log --pretty=format:"- %s" "main"...HEAD`;
17
+ newChangelog = gitRes.stdout.trim();
18
+ } catch {
19
+ console.error(chalk.redBright('Could not get git log, please write changelog manually.'));
20
+ }
21
+
22
+ const now = new Date();
23
+ const currentDate = `${now.getFullYear()}-${now.getMonth() + 1}-${now.getDate()}`;
24
+ const title = `## ${version} (${currentDate})`;
25
+
26
+ await fs.ensureFile('CHANGELOG.md');
27
+ const oldChangelog = await fs.readFile('CHANGELOG.md', 'utf8');
28
+ const changelog = [title, newChangelog, oldChangelog].filter((item) => !!item).join('\n\n');
29
+ await fs.writeFile('CHANGELOG.md', changelog);
30
+
31
+ console.log(`\nNow you can make adjustments to ${chalk.cyan('CHANGELOG.md')}. Then press enter to continue.`);
32
+
33
+ process.stdin.setRawMode(true);
34
+ process.stdin.resume();
35
+ process.stdin.on('data', process.exit.bind(process, 0));