payment-kit 1.13.237 → 1.13.239
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/routes/checkout-sessions.ts +4 -8
- package/api/src/routes/payment-links.ts +2 -0
- package/api/src/store/migrations/20240508-beneficiaries.ts +21 -0
- package/api/src/store/models/checkout-session.ts +4 -9
- package/api/src/store/models/payment-link.ts +12 -7
- package/api/src/store/models/types.ts +16 -5
- package/blocklet.yml +1 -1
- package/package.json +4 -4
|
@@ -535,6 +535,8 @@ router.put('/:id/submit', user, ensureCheckoutSessionOpen, async (req, res) => {
|
|
|
535
535
|
const paymentLink = checkoutSession.payment_link_id
|
|
536
536
|
? await PaymentLink.findByPk(checkoutSession.payment_link_id)
|
|
537
537
|
: null;
|
|
538
|
+
const beneficiaries =
|
|
539
|
+
paymentLink?.payment_intent_data?.beneficiaries || paymentLink?.donation_settings?.beneficiaries || [];
|
|
538
540
|
|
|
539
541
|
if (checkoutSession.payment_intent_id) {
|
|
540
542
|
paymentIntent = await PaymentIntent.findByPk(checkoutSession.payment_intent_id);
|
|
@@ -560,10 +562,7 @@ router.put('/:id/submit', user, ensureCheckoutSessionOpen, async (req, res) => {
|
|
|
560
562
|
payment_method_id: paymentMethod.id,
|
|
561
563
|
receipt_email: customer.email,
|
|
562
564
|
last_payment_error: null,
|
|
563
|
-
beneficiaries: createPaymentBeneficiaries(
|
|
564
|
-
checkoutSession.amount_total,
|
|
565
|
-
paymentLink?.donation_settings?.beneficiaries || []
|
|
566
|
-
),
|
|
565
|
+
beneficiaries: createPaymentBeneficiaries(checkoutSession.amount_total, beneficiaries),
|
|
567
566
|
});
|
|
568
567
|
logger.info('payment intent for checkout session reset', {
|
|
569
568
|
session: checkoutSession.id,
|
|
@@ -588,10 +587,7 @@ router.put('/:id/submit', user, ensureCheckoutSessionOpen, async (req, res) => {
|
|
|
588
587
|
checkoutSession.payment_intent_data?.statement_descriptor || getStatementDescriptor(lineItems),
|
|
589
588
|
statement_descriptor_suffix: '',
|
|
590
589
|
setup_future_usage: 'on_session',
|
|
591
|
-
beneficiaries: createPaymentBeneficiaries(
|
|
592
|
-
checkoutSession.amount_total,
|
|
593
|
-
paymentLink?.donation_settings?.beneficiaries || []
|
|
594
|
-
),
|
|
590
|
+
beneficiaries: createPaymentBeneficiaries(checkoutSession.amount_total, beneficiaries),
|
|
595
591
|
metadata: checkoutSession.payment_intent_data?.metadata || checkoutSession.metadata,
|
|
596
592
|
});
|
|
597
593
|
logger.info('paymentIntent created on checkout session submit', {
|
|
@@ -47,6 +47,7 @@ const formatBeforeSave = (payload: any) => {
|
|
|
47
47
|
},
|
|
48
48
|
submit_type: 'pay',
|
|
49
49
|
cross_sell_behavior: 'auto',
|
|
50
|
+
payment_intent_data: null,
|
|
50
51
|
donation_settings: null,
|
|
51
52
|
},
|
|
52
53
|
pick(payload, [
|
|
@@ -63,6 +64,7 @@ const formatBeforeSave = (payload: any) => {
|
|
|
63
64
|
'billing_address_collection',
|
|
64
65
|
'submit_type',
|
|
65
66
|
'subscription_data',
|
|
67
|
+
'payment_intent_data',
|
|
66
68
|
'nft_mint_settings',
|
|
67
69
|
'cross_sell_behavior',
|
|
68
70
|
'donation_settings',
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { DataTypes } from 'sequelize';
|
|
2
|
+
|
|
3
|
+
import { Migration, safeApplyColumnChanges } from '../migrate';
|
|
4
|
+
|
|
5
|
+
export const up: Migration = async ({ context }) => {
|
|
6
|
+
await safeApplyColumnChanges(context, {
|
|
7
|
+
payment_links: [
|
|
8
|
+
{
|
|
9
|
+
name: 'beneficiaries',
|
|
10
|
+
field: {
|
|
11
|
+
type: DataTypes.JSON,
|
|
12
|
+
allowNull: true,
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
],
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const down: Migration = async ({ context }) => {
|
|
20
|
+
await context.removeColumn('payment_links', 'beneficiaries');
|
|
21
|
+
};
|
|
@@ -23,6 +23,8 @@ import type {
|
|
|
23
23
|
NftMintDetails,
|
|
24
24
|
NftMintSettings,
|
|
25
25
|
PaymentDetails,
|
|
26
|
+
PaymentIntentData,
|
|
27
|
+
SubscriptionData,
|
|
26
28
|
} from './types';
|
|
27
29
|
|
|
28
30
|
export const nextCheckoutSessionId = createIdGenerator('cs', 58);
|
|
@@ -155,11 +157,8 @@ export class CheckoutSession extends Model<InferAttributes<CheckoutSession>, Inf
|
|
|
155
157
|
declare billing_address_collection?: LiteralUnion<'auto' | 'required', string>;
|
|
156
158
|
|
|
157
159
|
// When creating a subscription, the specified configuration data will be used.
|
|
158
|
-
declare subscription_data?: {
|
|
159
|
-
description: string;
|
|
160
|
-
trial_period_days: number;
|
|
160
|
+
declare subscription_data?: SubscriptionData & {
|
|
161
161
|
billing_cycle_anchor?: number;
|
|
162
|
-
billing_threshold_amount?: number;
|
|
163
162
|
metadata?: Record<string, any>;
|
|
164
163
|
proration_behavior?: LiteralUnion<'create_prorations' | 'none', string>;
|
|
165
164
|
trial_end?: number;
|
|
@@ -176,11 +175,7 @@ export class CheckoutSession extends Model<InferAttributes<CheckoutSession>, Inf
|
|
|
176
175
|
declare payment_details?: PaymentDetails;
|
|
177
176
|
|
|
178
177
|
// A subset of parameters to be passed to PaymentIntent creation for Checkout Sessions in payment mode.
|
|
179
|
-
declare payment_intent_data?:
|
|
180
|
-
description?: string;
|
|
181
|
-
statement_descriptor?: string;
|
|
182
|
-
metadata?: Record<string, any>;
|
|
183
|
-
};
|
|
178
|
+
declare payment_intent_data?: PaymentIntentData;
|
|
184
179
|
|
|
185
180
|
// Whether should we mint an nft to the customer on checkout complete
|
|
186
181
|
// Will use setting from payment method
|
|
@@ -4,7 +4,15 @@ import type { LiteralUnion } from 'type-fest';
|
|
|
4
4
|
|
|
5
5
|
import { createEvent } from '../../libs/audit';
|
|
6
6
|
import { createIdGenerator } from '../../libs/util';
|
|
7
|
-
import type {
|
|
7
|
+
import type {
|
|
8
|
+
AfterPayment,
|
|
9
|
+
CustomField,
|
|
10
|
+
DonationSettings,
|
|
11
|
+
LineItem,
|
|
12
|
+
NftMintSettings,
|
|
13
|
+
PaymentIntentData,
|
|
14
|
+
SubscriptionData,
|
|
15
|
+
} from './types';
|
|
8
16
|
|
|
9
17
|
export const nextPaymentLinkId = createIdGenerator('plink', 24);
|
|
10
18
|
|
|
@@ -66,11 +74,7 @@ export class PaymentLink extends Model<InferAttributes<PaymentLink>, InferCreati
|
|
|
66
74
|
declare submit_type: LiteralUnion<'auto' | 'book' | 'donate' | 'pay', string>;
|
|
67
75
|
|
|
68
76
|
// When creating a subscription, the specified configuration data will be used.
|
|
69
|
-
declare subscription_data?:
|
|
70
|
-
description: string;
|
|
71
|
-
trial_period_days: number;
|
|
72
|
-
billing_threshold_amount?: number;
|
|
73
|
-
};
|
|
77
|
+
declare subscription_data?: SubscriptionData;
|
|
74
78
|
|
|
75
79
|
declare nft_mint_settings?: NftMintSettings;
|
|
76
80
|
|
|
@@ -81,6 +85,8 @@ export class PaymentLink extends Model<InferAttributes<PaymentLink>, InferCreati
|
|
|
81
85
|
|
|
82
86
|
declare metadata?: Record<string, any>;
|
|
83
87
|
|
|
88
|
+
declare payment_intent_data?: PaymentIntentData;
|
|
89
|
+
|
|
84
90
|
// TODO: following fields not supported
|
|
85
91
|
// application_fee_amount
|
|
86
92
|
// application_fee_percent
|
|
@@ -89,7 +95,6 @@ export class PaymentLink extends Model<InferAttributes<PaymentLink>, InferCreati
|
|
|
89
95
|
// tax_id_collection
|
|
90
96
|
// consent_collection
|
|
91
97
|
// on_behalf_of
|
|
92
|
-
// payment_intent_data
|
|
93
98
|
// payment_method_collection
|
|
94
99
|
// shipping_address_collection
|
|
95
100
|
// shipping_options
|
|
@@ -330,6 +330,12 @@ export type DonationSettings = {
|
|
|
330
330
|
};
|
|
331
331
|
};
|
|
332
332
|
};
|
|
333
|
+
export type PaymentIntentData = {
|
|
334
|
+
description?: string;
|
|
335
|
+
statement_descriptor?: string;
|
|
336
|
+
beneficiaries?: PaymentBeneficiary[];
|
|
337
|
+
metadata?: Record<string, any>;
|
|
338
|
+
};
|
|
333
339
|
|
|
334
340
|
export type NftMintSettings = {
|
|
335
341
|
enabled: boolean;
|
|
@@ -351,6 +357,13 @@ export type NftMintDetails = {
|
|
|
351
357
|
ethereum?: NftMintItem;
|
|
352
358
|
};
|
|
353
359
|
|
|
360
|
+
export type SubscriptionData = {
|
|
361
|
+
description: string;
|
|
362
|
+
trial_period_days: number;
|
|
363
|
+
billing_threshold_amount?: number;
|
|
364
|
+
metadata?: Record<string, any>;
|
|
365
|
+
};
|
|
366
|
+
|
|
354
367
|
// Very similar to PaymentLink
|
|
355
368
|
export type PricingTableItem = {
|
|
356
369
|
price_id: string;
|
|
@@ -391,15 +404,13 @@ export type PricingTableItem = {
|
|
|
391
404
|
submit_type: LiteralUnion<'auto' | 'book' | 'donate' | 'pay', string>;
|
|
392
405
|
|
|
393
406
|
// When creating a subscription, the specified configuration data will be used.
|
|
394
|
-
subscription_data?:
|
|
395
|
-
description: string;
|
|
396
|
-
trial_period_days: number;
|
|
397
|
-
billing_threshold_amount?: number;
|
|
398
|
-
};
|
|
407
|
+
subscription_data?: SubscriptionData;
|
|
399
408
|
|
|
400
409
|
nft_mint_settings?: NftMintSettings;
|
|
401
410
|
|
|
402
411
|
cross_sell_behavior?: LiteralUnion<'auto' | 'required', string>;
|
|
412
|
+
|
|
413
|
+
payment_intent_data?: PaymentIntentData;
|
|
403
414
|
};
|
|
404
415
|
|
|
405
416
|
export type BrandSettings = {
|
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.239",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"dev": "cross-env COMPONENT_STORE_URL=https://test.store.blocklet.dev blocklet dev --open",
|
|
6
6
|
"eject": "vite eject",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"@arcblock/ux": "^2.9.75",
|
|
52
52
|
"@arcblock/validator": "^1.18.115",
|
|
53
53
|
"@blocklet/logger": "1.16.26",
|
|
54
|
-
"@blocklet/payment-react": "1.13.
|
|
54
|
+
"@blocklet/payment-react": "1.13.239",
|
|
55
55
|
"@blocklet/sdk": "1.16.26",
|
|
56
56
|
"@blocklet/ui-react": "^2.9.75",
|
|
57
57
|
"@blocklet/uploader": "^0.0.78",
|
|
@@ -116,7 +116,7 @@
|
|
|
116
116
|
"devDependencies": {
|
|
117
117
|
"@abtnode/types": "1.16.26",
|
|
118
118
|
"@arcblock/eslint-config-ts": "^0.3.0",
|
|
119
|
-
"@blocklet/payment-types": "1.13.
|
|
119
|
+
"@blocklet/payment-types": "1.13.239",
|
|
120
120
|
"@types/cookie-parser": "^1.4.7",
|
|
121
121
|
"@types/cors": "^2.8.17",
|
|
122
122
|
"@types/dotenv-flow": "^3.3.3",
|
|
@@ -155,5 +155,5 @@
|
|
|
155
155
|
"parser": "typescript"
|
|
156
156
|
}
|
|
157
157
|
},
|
|
158
|
-
"gitHead": "
|
|
158
|
+
"gitHead": "898fbcb595e77f6183aa0cac9fa69dbceb19d75f"
|
|
159
159
|
}
|