@blocklet/payment-react 1.13.223 → 1.13.225
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/es/util.d.ts +2 -4
- package/es/util.js +2 -1
- package/lib/util.d.ts +2 -4
- package/lib/util.js +6 -1
- package/package.json +3 -3
- package/src/util.ts +4 -2
package/es/util.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import type { PaymentDetails, PriceCurrency, PriceRecurring, TLineItemExpanded, TPaymentCurrency, TPaymentMethod, TPaymentMethodExpanded, TPrice, TSubscriptionExpanded, TSubscriptionItemExpanded } from '@blocklet/payment-types';
|
|
2
|
+
import type { PaymentDetails, PriceCurrency, PriceRecurring, TLineItemExpanded, TPaymentCurrency, TPaymentCurrencyExpanded, TPaymentMethod, TPaymentMethodExpanded, TPrice, TSubscriptionExpanded, TSubscriptionItemExpanded } from '@blocklet/payment-types';
|
|
3
3
|
export declare const PAYMENT_KIT_DID = "z2qaCNvKMv5GjouKdcDWexv6WqtHbpNPQDnAk";
|
|
4
4
|
export declare const isPaymentKitMounted: () => any;
|
|
5
5
|
export declare const getPrefix: () => any;
|
|
@@ -46,9 +46,7 @@ export declare function formatCheckoutHeadlines(items: TLineItemExpanded[], curr
|
|
|
46
46
|
secondary?: string;
|
|
47
47
|
};
|
|
48
48
|
export declare function formatAmount(amount: string, decimals: number): string;
|
|
49
|
-
export declare function findCurrency(methods: TPaymentMethodExpanded[], currencyId: string):
|
|
50
|
-
omit: never;
|
|
51
|
-
}> | null;
|
|
49
|
+
export declare function findCurrency(methods: TPaymentMethodExpanded[], currencyId: string): TPaymentCurrencyExpanded | null;
|
|
52
50
|
export declare function isValidCountry(code: string): boolean;
|
|
53
51
|
export declare function stopEvent(e: React.SyntheticEvent<any>): void;
|
|
54
52
|
export declare function sleep(ms: number): Promise<unknown>;
|
package/es/util.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { BN, fromUnitToToken } from "@ocap/util";
|
|
2
|
+
import omit from "lodash/omit";
|
|
2
3
|
import trimEnd from "lodash/trimEnd";
|
|
3
4
|
import numbro from "numbro";
|
|
4
5
|
import { defaultCountries } from "react-international-phone";
|
|
@@ -471,7 +472,7 @@ export function findCurrency(methods, currencyId) {
|
|
|
471
472
|
for (const method of methods) {
|
|
472
473
|
for (const currency of method.payment_currencies) {
|
|
473
474
|
if (currency.id === currencyId) {
|
|
474
|
-
return currency;
|
|
475
|
+
return { object: "payment_currency", ...currency, paymentMethod: omit(method, ["payment_currencies"]) };
|
|
475
476
|
}
|
|
476
477
|
}
|
|
477
478
|
}
|
package/lib/util.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import type { PaymentDetails, PriceCurrency, PriceRecurring, TLineItemExpanded, TPaymentCurrency, TPaymentMethod, TPaymentMethodExpanded, TPrice, TSubscriptionExpanded, TSubscriptionItemExpanded } from '@blocklet/payment-types';
|
|
2
|
+
import type { PaymentDetails, PriceCurrency, PriceRecurring, TLineItemExpanded, TPaymentCurrency, TPaymentCurrencyExpanded, TPaymentMethod, TPaymentMethodExpanded, TPrice, TSubscriptionExpanded, TSubscriptionItemExpanded } from '@blocklet/payment-types';
|
|
3
3
|
export declare const PAYMENT_KIT_DID = "z2qaCNvKMv5GjouKdcDWexv6WqtHbpNPQDnAk";
|
|
4
4
|
export declare const isPaymentKitMounted: () => any;
|
|
5
5
|
export declare const getPrefix: () => any;
|
|
@@ -46,9 +46,7 @@ export declare function formatCheckoutHeadlines(items: TLineItemExpanded[], curr
|
|
|
46
46
|
secondary?: string;
|
|
47
47
|
};
|
|
48
48
|
export declare function formatAmount(amount: string, decimals: number): string;
|
|
49
|
-
export declare function findCurrency(methods: TPaymentMethodExpanded[], currencyId: string):
|
|
50
|
-
omit: never;
|
|
51
|
-
}> | null;
|
|
49
|
+
export declare function findCurrency(methods: TPaymentMethodExpanded[], currencyId: string): TPaymentCurrencyExpanded | null;
|
|
52
50
|
export declare function isValidCountry(code: string): boolean;
|
|
53
51
|
export declare function stopEvent(e: React.SyntheticEvent<any>): void;
|
|
54
52
|
export declare function sleep(ms: number): Promise<unknown>;
|
package/lib/util.js
CHANGED
|
@@ -41,6 +41,7 @@ exports.mergeExtraParams = void 0;
|
|
|
41
41
|
exports.sleep = sleep;
|
|
42
42
|
exports.stopEvent = stopEvent;
|
|
43
43
|
var _util = require("@ocap/util");
|
|
44
|
+
var _omit = _interopRequireDefault(require("lodash/omit"));
|
|
44
45
|
var _trimEnd = _interopRequireDefault(require("lodash/trimEnd"));
|
|
45
46
|
var _numbro = _interopRequireDefault(require("numbro"));
|
|
46
47
|
var _reactInternationalPhone = require("react-international-phone");
|
|
@@ -559,7 +560,11 @@ function findCurrency(methods, currencyId) {
|
|
|
559
560
|
for (const method of methods) {
|
|
560
561
|
for (const currency of method.payment_currencies) {
|
|
561
562
|
if (currency.id === currencyId) {
|
|
562
|
-
return
|
|
563
|
+
return {
|
|
564
|
+
object: "payment_currency",
|
|
565
|
+
...currency,
|
|
566
|
+
paymentMethod: (0, _omit.default)(method, ["payment_currencies"])
|
|
567
|
+
};
|
|
563
568
|
}
|
|
564
569
|
}
|
|
565
570
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/payment-react",
|
|
3
|
-
"version": "1.13.
|
|
3
|
+
"version": "1.13.225",
|
|
4
4
|
"description": "Reusable react components for payment kit v2",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
"@babel/core": "^7.23.9",
|
|
91
91
|
"@babel/preset-env": "^7.23.9",
|
|
92
92
|
"@babel/preset-react": "^7.23.3",
|
|
93
|
-
"@blocklet/payment-types": "1.13.
|
|
93
|
+
"@blocklet/payment-types": "1.13.225",
|
|
94
94
|
"@storybook/addon-essentials": "^7.6.13",
|
|
95
95
|
"@storybook/addon-interactions": "^7.6.13",
|
|
96
96
|
"@storybook/addon-links": "^7.6.13",
|
|
@@ -119,5 +119,5 @@
|
|
|
119
119
|
"vite-plugin-babel": "^1.2.0",
|
|
120
120
|
"vite-plugin-node-polyfills": "^0.21.0"
|
|
121
121
|
},
|
|
122
|
-
"gitHead": "
|
|
122
|
+
"gitHead": "e5e5f94d4f17d582d7266b063dda56d09ffadf7c"
|
|
123
123
|
}
|
package/src/util.ts
CHANGED
|
@@ -6,6 +6,7 @@ import type {
|
|
|
6
6
|
PriceRecurring,
|
|
7
7
|
TLineItemExpanded,
|
|
8
8
|
TPaymentCurrency,
|
|
9
|
+
TPaymentCurrencyExpanded,
|
|
9
10
|
TPaymentMethod,
|
|
10
11
|
TPaymentMethodExpanded,
|
|
11
12
|
TPrice,
|
|
@@ -13,6 +14,7 @@ import type {
|
|
|
13
14
|
TSubscriptionItemExpanded,
|
|
14
15
|
} from '@blocklet/payment-types';
|
|
15
16
|
import { BN, fromUnitToToken } from '@ocap/util';
|
|
17
|
+
import omit from 'lodash/omit';
|
|
16
18
|
import trimEnd from 'lodash/trimEnd';
|
|
17
19
|
import numbro from 'numbro';
|
|
18
20
|
import { defaultCountries } from 'react-international-phone';
|
|
@@ -623,11 +625,11 @@ export function formatAmount(amount: string, decimals: number) {
|
|
|
623
625
|
return fromUnitToToken(amount, decimals);
|
|
624
626
|
}
|
|
625
627
|
|
|
626
|
-
export function findCurrency(methods: TPaymentMethodExpanded[], currencyId: string) {
|
|
628
|
+
export function findCurrency(methods: TPaymentMethodExpanded[], currencyId: string): TPaymentCurrencyExpanded | null {
|
|
627
629
|
for (const method of methods) {
|
|
628
630
|
for (const currency of method.payment_currencies) {
|
|
629
631
|
if (currency.id === currencyId) {
|
|
630
|
-
return currency;
|
|
632
|
+
return { object: 'payment_currency', ...currency, paymentMethod: omit(method, ['payment_currencies']) };
|
|
631
633
|
}
|
|
632
634
|
}
|
|
633
635
|
}
|