@tap-payments/apple-pay-button 1.0.6-test → 1.0.7-test
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/build/@types/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Scope, SupportedNetworks, ButtonType, Locale, Environment, ThemeMode, Edges } from '../constants';
|
|
2
|
-
import {
|
|
2
|
+
import { ApplePayPaymentContact, ApplePayPaymentMethod, ApplePayShippingMethod, ApplePayUpdateData, RequiredShippingContactField } from './ApplePaySession';
|
|
3
3
|
export * from './ApplePaySession';
|
|
4
4
|
export interface Interface {
|
|
5
5
|
locale?: typeof Locale[keyof typeof Locale];
|
|
@@ -22,20 +22,39 @@ export interface Customer {
|
|
|
22
22
|
number: string;
|
|
23
23
|
};
|
|
24
24
|
};
|
|
25
|
-
shippingContactFields?: Array<RequiredShippingContactField>;
|
|
26
25
|
}
|
|
27
26
|
export interface Acceptance {
|
|
28
27
|
supportedBrands?: Array<typeof SupportedNetworks[keyof typeof SupportedNetworks]>;
|
|
29
28
|
supportedCards?: Array<string>;
|
|
30
29
|
supportedCardsWithAuthentications?: Array<string>;
|
|
31
|
-
supportsCouponCode?: boolean;
|
|
32
30
|
}
|
|
33
31
|
export interface Transaction {
|
|
34
32
|
amount: string;
|
|
35
33
|
currency: string;
|
|
36
34
|
couponCode?: string;
|
|
37
35
|
shipping?: ApplePayShippingMethod[];
|
|
38
|
-
|
|
36
|
+
items?: Array<{
|
|
37
|
+
type?: 'final' | 'pending';
|
|
38
|
+
label?: string;
|
|
39
|
+
amount?: string;
|
|
40
|
+
paymentTiming?: 'immediate' | 'recurring' | 'deferred' | 'automaticReload';
|
|
41
|
+
scheduledPayment?: {
|
|
42
|
+
recurringStartDate?: Date;
|
|
43
|
+
recurringEndDate?: Date;
|
|
44
|
+
recurringIntervalUnit?: 'year' | 'month' | 'day' | 'hour' | 'minute';
|
|
45
|
+
recurringIntervalCount?: number;
|
|
46
|
+
};
|
|
47
|
+
deferredPayment?: {
|
|
48
|
+
deferredPaymentDate?: Date;
|
|
49
|
+
};
|
|
50
|
+
automaticReloadPayment?: {
|
|
51
|
+
thresholdAmount?: string;
|
|
52
|
+
};
|
|
53
|
+
}>;
|
|
54
|
+
}
|
|
55
|
+
export interface Features {
|
|
56
|
+
shippingContactFields?: Array<RequiredShippingContactField>;
|
|
57
|
+
supportsCouponCode?: boolean;
|
|
39
58
|
}
|
|
40
59
|
export interface ApplePayButtonProps {
|
|
41
60
|
scope?: typeof Scope[keyof typeof Scope];
|
|
@@ -50,6 +69,7 @@ export interface ApplePayButtonProps {
|
|
|
50
69
|
customer?: Customer;
|
|
51
70
|
acceptance: Acceptance;
|
|
52
71
|
transaction: Transaction;
|
|
72
|
+
features: Features;
|
|
53
73
|
onCancel?: () => void;
|
|
54
74
|
onError?: (error: any) => void;
|
|
55
75
|
onSuccess?: (data: Record<string, any>) => Promise<void>;
|
|
@@ -6,5 +6,5 @@ interface UseApplePayReturnProps {
|
|
|
6
6
|
onApplePayButtonClicked: () => Promise<void>;
|
|
7
7
|
abortApplePaySession: () => void;
|
|
8
8
|
}
|
|
9
|
-
export declare const useApplePay: ({ publicKey, merchant, transaction, interface: interfaceObj, customer, onCancel, onError, onSuccess, scope, acceptance, metaData, debug, environment, onReady, onMerchantValidation, onShippingMethodSelected, onShippingContactSelected, onPaymentMethodSelected, onCouponChanged }: UseApplePayProps) => UseApplePayReturnProps;
|
|
9
|
+
export declare const useApplePay: ({ publicKey, merchant, transaction, interface: interfaceObj, customer, onCancel, onError, onSuccess, scope, acceptance, features, metaData, debug, environment, onReady, onMerchantValidation, onShippingMethodSelected, onShippingContactSelected, onPaymentMethodSelected, onCouponChanged }: UseApplePayProps) => UseApplePayReturnProps;
|
|
10
10
|
export {};
|
|
@@ -52,7 +52,7 @@ import { setAxiosGlobalHeaders } from '../api/httpClient';
|
|
|
52
52
|
import { getApplePayPaymentMethod, getApplePayRequest, validateCurrency, validateSupportedNetworks } from '../utils/config';
|
|
53
53
|
import { getMerchantCapaplities } from '../utils/defaultValues';
|
|
54
54
|
export var useApplePay = function (_a) {
|
|
55
|
-
var publicKey = _a.publicKey, merchant = _a.merchant, transaction = _a.transaction, interfaceObj = _a.interface, customer = _a.customer, onCancel = _a.onCancel, onError = _a.onError, onSuccess = _a.onSuccess, scope = _a.scope, acceptance = _a.acceptance, metaData = _a.metaData, debug = _a.debug, environment = _a.environment, onReady = _a.onReady, onMerchantValidation = _a.onMerchantValidation, onShippingMethodSelected = _a.onShippingMethodSelected, onShippingContactSelected = _a.onShippingContactSelected, onPaymentMethodSelected = _a.onPaymentMethodSelected, onCouponChanged = _a.onCouponChanged;
|
|
55
|
+
var publicKey = _a.publicKey, merchant = _a.merchant, transaction = _a.transaction, interfaceObj = _a.interface, customer = _a.customer, onCancel = _a.onCancel, onError = _a.onError, onSuccess = _a.onSuccess, scope = _a.scope, acceptance = _a.acceptance, features = _a.features, metaData = _a.metaData, debug = _a.debug, environment = _a.environment, onReady = _a.onReady, onMerchantValidation = _a.onMerchantValidation, onShippingMethodSelected = _a.onShippingMethodSelected, onShippingContactSelected = _a.onShippingContactSelected, onPaymentMethodSelected = _a.onPaymentMethodSelected, onCouponChanged = _a.onCouponChanged;
|
|
56
56
|
var _b = useState(false), loading = _b[0], setLoading = _b[1];
|
|
57
57
|
var _c = useState(null), profileData = _c[0], setProfile = _c[1];
|
|
58
58
|
var _d = useState(false), disabled = _d[0], setDisabled = _d[1];
|
|
@@ -153,7 +153,7 @@ export var useApplePay = function (_a) {
|
|
|
153
153
|
currency = validateCurrency(transaction.currency, paymentMethod.supported_currencies);
|
|
154
154
|
cardBrands = validateSupportedNetworks(paymentMethod.supported_card_brands, acceptance.supportedBrands);
|
|
155
155
|
request = getApplePayRequest({
|
|
156
|
-
|
|
156
|
+
features: features,
|
|
157
157
|
countryCode: profileData.merchant.country_code,
|
|
158
158
|
transaction: __assign(__assign({}, transaction), { currency: currency }),
|
|
159
159
|
customer: customer,
|
package/build/utils/config.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { Acceptance, ApplePayButtonProps, ApplePayRequestData, PaymentMethod } f
|
|
|
2
2
|
import { SupportedNetworks } from '../constants';
|
|
3
3
|
export declare const validateSupportedNetworks: (supportedNetworksConfig: Array<(typeof SupportedNetworks)[keyof typeof SupportedNetworks]>, supportedNetworks: Acceptance['supportedBrands']) => ("amex" | "mada" | "masterCard" | "visa" | "chinaUnionPay" | "discover" | "electron" | "jcb" | "maestro")[];
|
|
4
4
|
export declare const validateCurrency: (currency: string, currencies: string[]) => string;
|
|
5
|
-
export declare const getApplePayRequest: ({ transaction, customer, supportedNetworks, merchantCapabilities, countryCode, name,
|
|
5
|
+
export declare const getApplePayRequest: ({ transaction, customer, supportedNetworks, merchantCapabilities, countryCode, name, features }: Pick<ApplePayButtonProps, "transaction" | "customer" | "features"> & {
|
|
6
6
|
supportedNetworks: Acceptance['supportedBrands'];
|
|
7
7
|
merchantCapabilities: ApplePayRequestData['merchantCapabilities'];
|
|
8
8
|
countryCode: string;
|
package/build/utils/config.js
CHANGED
|
@@ -24,8 +24,8 @@ export var validateCurrency = function (currency, currencies) {
|
|
|
24
24
|
return currency;
|
|
25
25
|
};
|
|
26
26
|
export var getApplePayRequest = function (_a) {
|
|
27
|
-
var _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
28
|
-
var transaction = _a.transaction, customer = _a.customer, supportedNetworks = _a.supportedNetworks, merchantCapabilities = _a.merchantCapabilities, countryCode = _a.countryCode, name = _a.name,
|
|
27
|
+
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
28
|
+
var transaction = _a.transaction, customer = _a.customer, supportedNetworks = _a.supportedNetworks, merchantCapabilities = _a.merchantCapabilities, countryCode = _a.countryCode, name = _a.name, features = _a.features;
|
|
29
29
|
return {
|
|
30
30
|
countryCode: countryCode,
|
|
31
31
|
currencyCode: transaction.currency,
|
|
@@ -41,11 +41,25 @@ export var getApplePayRequest = function (_a) {
|
|
|
41
41
|
amount: Number(transaction.amount),
|
|
42
42
|
label: name
|
|
43
43
|
},
|
|
44
|
-
supportsCouponCode:
|
|
44
|
+
supportsCouponCode: features.supportsCouponCode,
|
|
45
45
|
couponCode: transaction.couponCode,
|
|
46
|
-
requiredShippingContactFields:
|
|
46
|
+
requiredShippingContactFields: features === null || features === void 0 ? void 0 : features.shippingContactFields,
|
|
47
47
|
shippingMethods: transaction.shipping,
|
|
48
|
-
lineItems: transaction.
|
|
48
|
+
lineItems: (_l = transaction.items) === null || _l === void 0 ? void 0 : _l.map(function (item) {
|
|
49
|
+
var _a, _b, _c, _d, _e, _f;
|
|
50
|
+
return ({
|
|
51
|
+
type: item.type,
|
|
52
|
+
label: item.label,
|
|
53
|
+
amount: item.amount,
|
|
54
|
+
paymentTiming: item.paymentTiming,
|
|
55
|
+
recurringPaymentStartDate: (_a = item.scheduledPayment) === null || _a === void 0 ? void 0 : _a.recurringStartDate,
|
|
56
|
+
recurringPaymentIntervalUnit: (_b = item.scheduledPayment) === null || _b === void 0 ? void 0 : _b.recurringIntervalUnit,
|
|
57
|
+
recurringPaymentIntervalCount: (_c = item.scheduledPayment) === null || _c === void 0 ? void 0 : _c.recurringIntervalCount,
|
|
58
|
+
recurringPaymentEndDate: (_d = item.scheduledPayment) === null || _d === void 0 ? void 0 : _d.recurringEndDate,
|
|
59
|
+
deferredPaymentDate: (_e = item.deferredPayment) === null || _e === void 0 ? void 0 : _e.deferredPaymentDate,
|
|
60
|
+
automaticReloadPaymentThresholdAmount: (_f = item.automaticReloadPayment) === null || _f === void 0 ? void 0 : _f.thresholdAmount
|
|
61
|
+
});
|
|
62
|
+
})
|
|
49
63
|
};
|
|
50
64
|
};
|
|
51
65
|
export var getApplePayPaymentMethod = function (paymentMethods) {
|
|
@@ -17,6 +17,7 @@ export declare const getDefaultValues: (mainObject: ApplePayButtonProps) => {
|
|
|
17
17
|
customer?: import("../@types").Customer | undefined;
|
|
18
18
|
acceptance: import("../@types").Acceptance;
|
|
19
19
|
transaction: import("../@types").Transaction;
|
|
20
|
+
features: import("../@types").Features;
|
|
20
21
|
onCancel?: (() => void) | undefined;
|
|
21
22
|
onError?: ((error: any) => void) | undefined;
|
|
22
23
|
onSuccess?: ((data: Record<string, any>) => Promise<void>) | undefined;
|