@tap-payments/apple-pay-button 0.0.5-staging → 0.0.6-staging
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/ApplePayButtonProps.d.ts +10 -89
- package/build/@types/charge.d.ts +1 -2
- package/build/@types/enums.d.ts +4 -25
- package/build/@types/enums.js +5 -30
- package/build/api.d.ts +3 -1
- package/build/constants/index.d.ts +1 -0
- package/build/constants/index.js +1 -0
- package/build/features/ApplePayButton/ApplePayButton.js +3 -4
- package/build/hooks/useApplePay.d.ts +45 -57
- package/build/hooks/useApplePay.js +95 -139
- package/build/hooks/useMerchantApplePay.d.ts +6 -4
- package/build/hooks/useMerchantApplePay.js +34 -32
- package/build/index.d.ts +2 -1
- package/build/index.js +2 -1
- package/build/utils/config.d.ts +4 -4
- package/build/utils/config.js +8 -14
- package/build/utils/index.d.ts +0 -1
- package/build/utils/index.js +0 -1
- package/build/utils/theme.d.ts +2 -1
- package/build/utils/theme.js +2 -1
- package/package.json +2 -2
- package/build/utils/html.d.ts +0 -1
- package/build/utils/html.js +0 -9
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { type ButtonSDKProps } from '@tap-payments/acceptance-sdk';
|
|
1
2
|
import { CheckoutProfileResponse } from './checkoutProfile';
|
|
2
|
-
import {
|
|
3
|
+
import { MerchantCapabilities, SupportedNetworks, IntegrationType } from './enums';
|
|
3
4
|
export interface ApplePayRequestData {
|
|
4
5
|
countryCode: string;
|
|
5
6
|
currencyCode: string;
|
|
@@ -19,107 +20,27 @@ export interface ApplePayRequestData {
|
|
|
19
20
|
export interface ApplePayDataToLunchSDKFromMerchantSide {
|
|
20
21
|
headers: Record<string, any>;
|
|
21
22
|
BASE_URL: string;
|
|
22
|
-
merchant: Record<string,
|
|
23
|
+
merchant: Record<string, any>;
|
|
23
24
|
applePayRequestData: ApplePayRequestData;
|
|
24
25
|
debug?: boolean;
|
|
25
26
|
applePaySDKVersion?: number;
|
|
26
27
|
}
|
|
27
|
-
export
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
colorStyle?: ColorStyle;
|
|
33
|
-
loader?: boolean;
|
|
34
|
-
}
|
|
35
|
-
export interface Customer {
|
|
36
|
-
id?: string;
|
|
37
|
-
name?: {
|
|
38
|
-
lang: Locale;
|
|
39
|
-
first: string;
|
|
40
|
-
last: string;
|
|
41
|
-
middle?: string;
|
|
42
|
-
}[];
|
|
43
|
-
contact?: {
|
|
44
|
-
email?: string;
|
|
45
|
-
phone?: {
|
|
46
|
-
countryCode: string;
|
|
47
|
-
number: string;
|
|
48
|
-
};
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
export interface Acceptance {
|
|
52
|
-
supportedSchemes?: Array<SupportedNetworks>;
|
|
53
|
-
supportedFundSource?: string[];
|
|
54
|
-
supportedPaymentAuthentications?: string[];
|
|
55
|
-
}
|
|
56
|
-
export interface ApplePayButtonProps {
|
|
57
|
-
operator: {
|
|
58
|
-
publicKey: string;
|
|
59
|
-
hashstring?: string;
|
|
60
|
-
};
|
|
61
|
-
merchant: {
|
|
62
|
-
id: string;
|
|
28
|
+
export type Acceptance = Exclude<ButtonSDKProps['acceptance'], undefined>;
|
|
29
|
+
export type ProfileData = Exclude<Exclude<ButtonSDKProps['metadata'], undefined>['profileData'], undefined>;
|
|
30
|
+
export type Transaction = Exclude<ButtonSDKProps['transaction'], undefined>;
|
|
31
|
+
export interface ApplePayButtonProps extends ButtonSDKProps {
|
|
32
|
+
merchant: ButtonSDKProps['merchant'] & {
|
|
63
33
|
identifier?: string;
|
|
64
34
|
};
|
|
65
|
-
scope: Scope;
|
|
66
|
-
interface?: Interface;
|
|
67
|
-
customer?: Customer;
|
|
68
|
-
acceptance?: Acceptance;
|
|
69
|
-
transaction?: {
|
|
70
|
-
authentication?: boolean;
|
|
71
|
-
authorize?: {
|
|
72
|
-
auto: {
|
|
73
|
-
type: string;
|
|
74
|
-
time: number;
|
|
75
|
-
};
|
|
76
|
-
};
|
|
77
|
-
metadata?: Record<string, string>;
|
|
78
|
-
reference?: string;
|
|
79
|
-
paymentAgreement?: {
|
|
80
|
-
id: string;
|
|
81
|
-
contract?: {
|
|
82
|
-
id: string;
|
|
83
|
-
};
|
|
84
|
-
};
|
|
85
|
-
destinations?: Record<string, any>;
|
|
86
|
-
};
|
|
87
|
-
invoice?: {
|
|
88
|
-
id: string;
|
|
89
|
-
};
|
|
90
|
-
order: {
|
|
91
|
-
amount: number;
|
|
92
|
-
currency: string;
|
|
93
|
-
id?: string;
|
|
94
|
-
description?: string;
|
|
95
|
-
metadata?: Record<string, string>;
|
|
96
|
-
reference?: string;
|
|
97
|
-
};
|
|
98
|
-
post?: {
|
|
99
|
-
url: string;
|
|
100
|
-
};
|
|
101
|
-
redirect?: {
|
|
102
|
-
url: string;
|
|
103
|
-
};
|
|
104
|
-
onOrderCreated?: (orderId: string) => void;
|
|
105
|
-
onCancel?: () => void;
|
|
106
|
-
onError?: (error: any) => void;
|
|
107
|
-
onSuccess?: (data: Record<string, any>) => Promise<void>;
|
|
108
35
|
onClick?: (data?: ApplePayDataToLunchSDKFromMerchantSide) => void;
|
|
109
|
-
|
|
110
|
-
metaData?: MetaData;
|
|
111
|
-
debug?: boolean;
|
|
112
|
-
integration?: 'sdk' | 'iframe' | 'webview';
|
|
113
|
-
headers?: {
|
|
114
|
-
mdn: string;
|
|
115
|
-
application: string;
|
|
116
|
-
};
|
|
36
|
+
integration?: IntegrationType;
|
|
117
37
|
}
|
|
118
38
|
export interface MerchantValidationRequestData {
|
|
119
39
|
validationUrl: string;
|
|
120
40
|
origin: string;
|
|
121
41
|
merchantId: string;
|
|
122
42
|
merchantName: string;
|
|
43
|
+
merchantIdentifier: string;
|
|
123
44
|
}
|
|
124
45
|
export interface MerchantResponse {
|
|
125
46
|
id: string;
|
package/build/@types/charge.d.ts
CHANGED
|
@@ -10,7 +10,6 @@ export interface ChargeRequestBody {
|
|
|
10
10
|
product: string;
|
|
11
11
|
threeDSecure?: boolean;
|
|
12
12
|
save_card: boolean;
|
|
13
|
-
fee: number;
|
|
14
13
|
customer: {
|
|
15
14
|
id?: string;
|
|
16
15
|
first_name?: string;
|
|
@@ -52,6 +51,6 @@ export interface ChargeRequestBody {
|
|
|
52
51
|
export interface AuthorizeRequestBody extends ChargeRequestBody {
|
|
53
52
|
auto?: {
|
|
54
53
|
type: string;
|
|
55
|
-
time:
|
|
54
|
+
time: string;
|
|
56
55
|
};
|
|
57
56
|
}
|
package/build/@types/enums.d.ts
CHANGED
|
@@ -1,28 +1,3 @@
|
|
|
1
|
-
export declare enum Locale {
|
|
2
|
-
EN = "en",
|
|
3
|
-
AR = "ar",
|
|
4
|
-
DYNAMIC = "dynamic"
|
|
5
|
-
}
|
|
6
|
-
export declare enum ThemeMode {
|
|
7
|
-
DARK = "dark",
|
|
8
|
-
LIGHT = "light",
|
|
9
|
-
DYNAMIC = "dynamic"
|
|
10
|
-
}
|
|
11
|
-
export declare enum Edges {
|
|
12
|
-
STRAIGHT = "straight",
|
|
13
|
-
CURVED = "curved",
|
|
14
|
-
CIRCULAR = "circular"
|
|
15
|
-
}
|
|
16
|
-
export declare enum ColorStyle {
|
|
17
|
-
COLORED = "colored",
|
|
18
|
-
MONOCHROME = "monochrome"
|
|
19
|
-
}
|
|
20
|
-
export declare enum Scope {
|
|
21
|
-
CHARGE = "charge",
|
|
22
|
-
AUTHORIZE = "authorize",
|
|
23
|
-
TAP_TOKEN = "taptoken",
|
|
24
|
-
APPLE_PAY_TOKEN = "applepaytoken"
|
|
25
|
-
}
|
|
26
1
|
export declare enum ButtonStyle {
|
|
27
2
|
Black = "black",
|
|
28
3
|
White = "white",
|
|
@@ -63,3 +38,7 @@ export declare enum SupportedNetworks {
|
|
|
63
38
|
Jcb = "jcb",
|
|
64
39
|
Maestro = "maestro"
|
|
65
40
|
}
|
|
41
|
+
export declare enum IntegrationType {
|
|
42
|
+
SDK = "sdk",
|
|
43
|
+
IFRAME = "iframe"
|
|
44
|
+
}
|
package/build/@types/enums.js
CHANGED
|
@@ -1,33 +1,3 @@
|
|
|
1
|
-
export var Locale;
|
|
2
|
-
(function (Locale) {
|
|
3
|
-
Locale["EN"] = "en";
|
|
4
|
-
Locale["AR"] = "ar";
|
|
5
|
-
Locale["DYNAMIC"] = "dynamic";
|
|
6
|
-
})(Locale || (Locale = {}));
|
|
7
|
-
export var ThemeMode;
|
|
8
|
-
(function (ThemeMode) {
|
|
9
|
-
ThemeMode["DARK"] = "dark";
|
|
10
|
-
ThemeMode["LIGHT"] = "light";
|
|
11
|
-
ThemeMode["DYNAMIC"] = "dynamic";
|
|
12
|
-
})(ThemeMode || (ThemeMode = {}));
|
|
13
|
-
export var Edges;
|
|
14
|
-
(function (Edges) {
|
|
15
|
-
Edges["STRAIGHT"] = "straight";
|
|
16
|
-
Edges["CURVED"] = "curved";
|
|
17
|
-
Edges["CIRCULAR"] = "circular";
|
|
18
|
-
})(Edges || (Edges = {}));
|
|
19
|
-
export var ColorStyle;
|
|
20
|
-
(function (ColorStyle) {
|
|
21
|
-
ColorStyle["COLORED"] = "colored";
|
|
22
|
-
ColorStyle["MONOCHROME"] = "monochrome";
|
|
23
|
-
})(ColorStyle || (ColorStyle = {}));
|
|
24
|
-
export var Scope;
|
|
25
|
-
(function (Scope) {
|
|
26
|
-
Scope["CHARGE"] = "charge";
|
|
27
|
-
Scope["AUTHORIZE"] = "authorize";
|
|
28
|
-
Scope["TAP_TOKEN"] = "taptoken";
|
|
29
|
-
Scope["APPLE_PAY_TOKEN"] = "applepaytoken";
|
|
30
|
-
})(Scope || (Scope = {}));
|
|
31
1
|
export var ButtonStyle;
|
|
32
2
|
(function (ButtonStyle) {
|
|
33
3
|
ButtonStyle["Black"] = "black";
|
|
@@ -74,3 +44,8 @@ export var SupportedNetworks;
|
|
|
74
44
|
SupportedNetworks["Jcb"] = "jcb";
|
|
75
45
|
SupportedNetworks["Maestro"] = "maestro";
|
|
76
46
|
})(SupportedNetworks || (SupportedNetworks = {}));
|
|
47
|
+
export var IntegrationType;
|
|
48
|
+
(function (IntegrationType) {
|
|
49
|
+
IntegrationType["SDK"] = "sdk";
|
|
50
|
+
IntegrationType["IFRAME"] = "iframe";
|
|
51
|
+
})(IntegrationType || (IntegrationType = {}));
|
package/build/api.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { CheckoutProfileRequest, ChargeRequestBody, AuthorizeRequestBody, MerchantValidationRequestData } from './@types';
|
|
2
|
-
export declare const setAxiosGlobalHeaders: (headers:
|
|
2
|
+
export declare const setAxiosGlobalHeaders: (headers: {
|
|
3
|
+
[x: string]: string | undefined;
|
|
4
|
+
}) => void;
|
|
3
5
|
export declare const getAxiosGlobalHeaders: () => {
|
|
4
6
|
[x: string]: import("axios").AxiosHeaderValue | undefined;
|
|
5
7
|
Accept?: import("axios").AxiosHeaderValue | undefined;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export declare const ApplePayVersion = 5;
|
|
2
2
|
export declare const RSA_MW_PUBLIC_KEY = "-----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCi9W5jyTvA4Iwv3V5sfNQ7VdSz\n7WqwBbnWFbIUL/GjaaE93mvDv4zbgRSznHaHQPH6pxrMhMh0tV58njkvjHvQ/tvg\npwM8SemNPKEEAPl69tnMvCrJRPh2dWL3OHY8yCW4c38Hyx4fy56Zd5cdoVWfCReu\njCsvASLGz+cfRrj2swIDAQAB\n-----END PUBLIC KEY-----";
|
|
3
3
|
export declare const MW_BASE_URL = "https://mw-sdk.staging.tap.company/v2/checkout";
|
|
4
|
+
export declare const APPLE_PAY_SCRIPT = "https://applepay.cdn-apple.com/jsapi/1.latest/apple-pay-sdk.js";
|
package/build/constants/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export var ApplePayVersion = 5;
|
|
2
2
|
export var RSA_MW_PUBLIC_KEY = "-----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCi9W5jyTvA4Iwv3V5sfNQ7VdSz\n7WqwBbnWFbIUL/GjaaE93mvDv4zbgRSznHaHQPH6pxrMhMh0tV58njkvjHvQ/tvg\npwM8SemNPKEEAPl69tnMvCrJRPh2dWL3OHY8yCW4c38Hyx4fy56Zd5cdoVWfCReu\njCsvASLGz+cfRrj2swIDAQAB\n-----END PUBLIC KEY-----";
|
|
3
3
|
export var MW_BASE_URL = 'https://mw-sdk.staging.tap.company/v2/checkout';
|
|
4
|
+
export var APPLE_PAY_SCRIPT = 'https://applepay.cdn-apple.com/jsapi/1.latest/apple-pay-sdk.js';
|
|
@@ -12,12 +12,11 @@ var __assign = (this && this.__assign) || function () {
|
|
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
13
|
import * as React from 'react';
|
|
14
14
|
import { createRoot } from 'react-dom/client';
|
|
15
|
-
import { findOrCreateElementAndInject } from '../../utils';
|
|
16
15
|
import { useApplePay } from '../../hooks/useApplePay';
|
|
17
|
-
import { Locale, PayButton } from '@tap-payments/acceptance-sdk';
|
|
16
|
+
import { findOrCreateElementAndInject, Locale, PayButton } from '@tap-payments/acceptance-sdk';
|
|
18
17
|
var ApplePay = React.memo(function (props) {
|
|
19
18
|
var _a, _b, _c;
|
|
20
|
-
var _d = useApplePay({ buttonProps: props }), onClick = _d.onClick,
|
|
19
|
+
var _d = useApplePay({ buttonProps: props }), onClick = _d.onClick, mappedProps = _d.mappedProps, theme = _d.theme, isRounded = _d.isRounded, success = _d.success, error = _d.error, applePayPaymentMethodOptions = _d.applePayPaymentMethodOptions, profileData = _d.profileData;
|
|
21
20
|
React.useEffect(function () {
|
|
22
21
|
if (props.debug) {
|
|
23
22
|
console.log('ApplePayButtonProps', props);
|
|
@@ -27,7 +26,7 @@ var ApplePay = React.memo(function (props) {
|
|
|
27
26
|
width: '100%',
|
|
28
27
|
display: 'flex',
|
|
29
28
|
justifyContent: 'center'
|
|
30
|
-
} }, { children: _jsx(PayButton, { shimmerLoader: !profileData ||
|
|
29
|
+
} }, { children: _jsx(PayButton, { shimmerLoader: !profileData || !applePayPaymentMethodOptions, locale: ((_a = mappedProps.interface) === null || _a === void 0 ? void 0 : _a.locale) || Locale.EN, theme: theme, edges: (_b = mappedProps.interface) === null || _b === void 0 ? void 0 : _b.edges, colorStyle: (_c = mappedProps.interface) === null || _c === void 0 ? void 0 : _c.colorStyle, isFailed: error, isRounded: isRounded, isSuccess: success, onClick: onClick, buttonStyle: applePayPaymentMethodOptions === null || applePayPaymentMethodOptions === void 0 ? void 0 : applePayPaymentMethodOptions.button_style }) })));
|
|
31
30
|
});
|
|
32
31
|
export function ApplePayButton(props) {
|
|
33
32
|
return _jsx(ApplePay, __assign({}, props));
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { ApplePayButtonProps, ApplePayDataToLunchSDKFromMerchantSide, ApplePayRequestData,
|
|
2
|
-
|
|
1
|
+
import { ApplePayButtonProps, ApplePayDataToLunchSDKFromMerchantSide, ApplePayRequestData, IntegrationType } from '../@types';
|
|
2
|
+
import { Scope } from '@tap-payments/acceptance-sdk';
|
|
3
|
+
interface UseApplePayParams {
|
|
3
4
|
buttonProps: ApplePayButtonProps;
|
|
4
5
|
}
|
|
5
|
-
export declare const useApplePay: ({ buttonProps }:
|
|
6
|
+
export declare const useApplePay: ({ buttonProps }: UseApplePayParams) => {
|
|
6
7
|
onClick: () => void;
|
|
7
8
|
loading: boolean;
|
|
8
9
|
isIframeIntegration: boolean;
|
|
@@ -17,77 +18,64 @@ export declare const useApplePay: ({ buttonProps }: UsaApplePayProps) => {
|
|
|
17
18
|
edges?: import("@tap-payments/acceptance-sdk").Edges | undefined;
|
|
18
19
|
colorStyle?: import("@tap-payments/acceptance-sdk").ColorStyle | undefined;
|
|
19
20
|
loader?: boolean | undefined;
|
|
20
|
-
userExperience?: "popup" | "page" | undefined;
|
|
21
|
+
userExperience?: (string & {}) | "popup" | "page" | undefined;
|
|
21
22
|
powered?: boolean | undefined;
|
|
22
23
|
direction?: import("@tap-payments/acceptance-sdk").Direction | undefined;
|
|
23
24
|
cardDirection?: import("@tap-payments/acceptance-sdk").Direction | undefined;
|
|
24
25
|
} | undefined;
|
|
25
|
-
|
|
26
|
-
publicKey: string;
|
|
27
|
-
hashstring?: string | undefined;
|
|
28
|
-
};
|
|
29
|
-
merchant: {
|
|
30
|
-
id: string;
|
|
26
|
+
merchant: import("@tap-payments/acceptance-sdk/build/@types").Merchant & {
|
|
31
27
|
identifier?: string | undefined;
|
|
32
28
|
};
|
|
29
|
+
onClick?: ((data?: ApplePayDataToLunchSDKFromMerchantSide | undefined) => void) | undefined;
|
|
30
|
+
integration?: IntegrationType | undefined;
|
|
31
|
+
debug?: boolean | undefined;
|
|
33
32
|
scope: Scope;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
};
|
|
43
|
-
} | undefined;
|
|
44
|
-
metadata?: Record<string, string> | undefined;
|
|
45
|
-
reference?: string | undefined;
|
|
46
|
-
paymentAgreement?: {
|
|
47
|
-
id: string;
|
|
48
|
-
contract?: {
|
|
49
|
-
id: string;
|
|
50
|
-
} | undefined;
|
|
51
|
-
} | undefined;
|
|
52
|
-
destinations?: Record<string, any> | undefined;
|
|
53
|
-
} | undefined;
|
|
54
|
-
invoice?: {
|
|
55
|
-
id: string;
|
|
56
|
-
} | undefined;
|
|
57
|
-
order: {
|
|
58
|
-
amount: number;
|
|
59
|
-
currency: string;
|
|
60
|
-
id?: string | undefined;
|
|
61
|
-
description?: string | undefined;
|
|
62
|
-
metadata?: Record<string, string> | undefined;
|
|
63
|
-
reference?: string | undefined;
|
|
64
|
-
};
|
|
33
|
+
order: import("@tap-payments/acceptance-sdk/build/@types").Order;
|
|
34
|
+
invoice?: import("@tap-payments/acceptance-sdk/build/@types").Invoice | undefined;
|
|
35
|
+
operator: import("@tap-payments/acceptance-sdk/build/@types").Operator;
|
|
36
|
+
customer: import("@tap-payments/acceptance-sdk").CustomerWithNameOnCard;
|
|
37
|
+
features?: import("@tap-payments/acceptance-sdk/build/@types").Features | undefined;
|
|
38
|
+
acceptance?: import("@tap-payments/acceptance-sdk/build/@types").Acceptance | undefined;
|
|
39
|
+
transaction?: import("@tap-payments/acceptance-sdk/build/@types").Transaction | undefined;
|
|
40
|
+
fieldVisibility?: import("@tap-payments/acceptance-sdk/build/@types").FieldVisibility | undefined;
|
|
65
41
|
post?: {
|
|
42
|
+
[key: string]: any;
|
|
66
43
|
url: string;
|
|
67
44
|
} | undefined;
|
|
68
45
|
redirect?: {
|
|
46
|
+
[key: string]: any;
|
|
69
47
|
url: string;
|
|
70
48
|
} | undefined;
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
49
|
+
metadata?: ({
|
|
50
|
+
headers?: ({
|
|
51
|
+
authorization: string;
|
|
52
|
+
mdn: string;
|
|
53
|
+
application: string;
|
|
54
|
+
ip?: string | undefined;
|
|
55
|
+
session?: string | undefined;
|
|
56
|
+
} & {
|
|
57
|
+
[x: string]: any;
|
|
58
|
+
}) | undefined;
|
|
59
|
+
profileData?: import("@tap-payments/acceptance-sdk").CheckoutProfileResponse | undefined;
|
|
60
|
+
} & {
|
|
61
|
+
[x: string]: any;
|
|
62
|
+
}) | undefined;
|
|
63
|
+
platform?: {
|
|
64
|
+
id: string;
|
|
83
65
|
} | undefined;
|
|
66
|
+
onReady?: (() => void) | undefined;
|
|
67
|
+
onError?: ((error: any) => void) | undefined;
|
|
68
|
+
onCancel?: (() => void) | undefined;
|
|
69
|
+
onSuccess?: ((data: any) => void) | undefined;
|
|
70
|
+
onBinIdentification?: ((data: any) => void) | undefined;
|
|
71
|
+
onChargeCreated?: ((charge: Record<string, any>) => void) | undefined;
|
|
72
|
+
onOrderCreated?: ((orderId: string) => void) | undefined;
|
|
84
73
|
};
|
|
85
|
-
theme: import("
|
|
86
|
-
initialLoading: boolean;
|
|
74
|
+
theme: import("@tap-payments/acceptance-sdk").ThemeMode;
|
|
87
75
|
isRounded: boolean;
|
|
88
76
|
success: boolean;
|
|
89
77
|
error: boolean;
|
|
90
|
-
applePayPaymentMethodOptions: import("
|
|
91
|
-
profileData:
|
|
78
|
+
applePayPaymentMethodOptions: import("@tap-payments/acceptance-sdk").PaymentMethod | undefined;
|
|
79
|
+
profileData: import("@tap-payments/acceptance-sdk").CheckoutProfileResponse | undefined;
|
|
92
80
|
};
|
|
93
81
|
export {};
|
|
@@ -45,41 +45,29 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
45
45
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
49
|
-
var t = {};
|
|
50
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
51
|
-
t[p] = s[p];
|
|
52
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
53
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
54
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
55
|
-
t[p[i]] = s[p[i]];
|
|
56
|
-
}
|
|
57
|
-
return t;
|
|
58
|
-
};
|
|
59
48
|
import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
60
|
-
import { ApplePayVersion, MW_BASE_URL } from '../constants';
|
|
61
|
-
import { prepareApplePayRequest, shallRenderApplePay } from '../utils/config';
|
|
62
|
-
import {
|
|
49
|
+
import { APPLE_PAY_SCRIPT, ApplePayVersion, MW_BASE_URL } from '../constants';
|
|
50
|
+
import { PAYMENT_METHOD_KEY, prepareApplePayRequest, shallRenderApplePay } from '../utils/config';
|
|
51
|
+
import { IntegrationType } from '../@types';
|
|
63
52
|
import { useMerchantApplePay } from './useMerchantApplePay';
|
|
64
|
-
import {
|
|
53
|
+
import { getDefaultThemeMode } from '../utils';
|
|
65
54
|
import appService, { getAxiosGlobalHeaders, setAxiosGlobalHeaders } from '../api';
|
|
66
|
-
import { ChargeCode, mappingInterface } from '@tap-payments/acceptance-sdk';
|
|
55
|
+
import { areAllTheObjectStringValuesValid, ChargeCode, getPaymentMethod, getSelectedCurrency, mappingInterface, Scope, useScript } from '@tap-payments/acceptance-sdk';
|
|
56
|
+
var FALLBACK_MERCHANT_IDENTIFIER = 'merchant.tap.gosell';
|
|
67
57
|
export var useApplePay = function (_a) {
|
|
68
|
-
var _b;
|
|
69
58
|
var buttonProps = _a.buttonProps;
|
|
70
|
-
var
|
|
71
|
-
var
|
|
72
|
-
var
|
|
73
|
-
var
|
|
74
|
-
var
|
|
75
|
-
var
|
|
76
|
-
var
|
|
77
|
-
|
|
78
|
-
var _l = useState(false), isRounded = _l[0], setIsRounded = _l[1];
|
|
59
|
+
var _b = useState(), applePayRequestData = _b[0], setApplePayRequestData = _b[1];
|
|
60
|
+
var _c = useState(), applePayRequestConfiguration = _c[0], setApplePayRequestConfiguration = _c[1];
|
|
61
|
+
var _d = useState(false), disabled = _d[0], setDisabled = _d[1];
|
|
62
|
+
var _e = useState(false), error = _e[0], setError = _e[1];
|
|
63
|
+
var _f = useState(false), success = _f[0], setSuccess = _f[1];
|
|
64
|
+
var _g = useState(false), loading = _g[0], setLoading = _g[1];
|
|
65
|
+
var _h = useState(false), isRounded = _h[0], setIsRounded = _h[1];
|
|
66
|
+
useScript(APPLE_PAY_SCRIPT);
|
|
79
67
|
var mappedProps = __assign(__assign({}, buttonProps), { interface: mappingInterface(buttonProps.interface) });
|
|
80
|
-
var interfaceObj = mappedProps.interface, merchant = mappedProps.merchant, customer = mappedProps.customer, acceptance = mappedProps.acceptance, scope = mappedProps.scope, debug = mappedProps.debug, onError = mappedProps.onError, onSuccess = mappedProps.onSuccess, onCancel = mappedProps.onCancel, onReady = mappedProps.onReady,
|
|
81
|
-
var
|
|
82
|
-
var
|
|
68
|
+
var interfaceObj = mappedProps.interface, merchant = mappedProps.merchant, customer = mappedProps.customer, acceptance = mappedProps.acceptance, scope = mappedProps.scope, debug = mappedProps.debug, onError = mappedProps.onError, onSuccess = mappedProps.onSuccess, onCancel = mappedProps.onCancel, onReady = mappedProps.onReady, metadata = mappedProps.metadata, operator = mappedProps.operator, order = mappedProps.order, onOrderCreated = mappedProps.onOrderCreated, transaction = mappedProps.transaction, post = mappedProps.post, redirect = mappedProps.redirect, integration = mappedProps.integration, features = mappedProps.features;
|
|
69
|
+
var _j = metadata || {}, profileData = _j.profileData, headers = _j.headers;
|
|
70
|
+
var isIframeIntegration = integration === IntegrationType.IFRAME;
|
|
83
71
|
useMerchantApplePay({
|
|
84
72
|
isIframeIntegration: isIframeIntegration,
|
|
85
73
|
onError: onError,
|
|
@@ -95,13 +83,14 @@ export var useApplePay = function (_a) {
|
|
|
95
83
|
redirect: redirect,
|
|
96
84
|
setError: setError,
|
|
97
85
|
setSuccess: setSuccess,
|
|
98
|
-
setLoading: setLoading
|
|
86
|
+
setLoading: setLoading,
|
|
87
|
+
features: features
|
|
99
88
|
});
|
|
100
|
-
var theme =
|
|
89
|
+
var theme = useMemo(function () { return getDefaultThemeMode(interfaceObj === null || interfaceObj === void 0 ? void 0 : interfaceObj.theme); }, [interfaceObj === null || interfaceObj === void 0 ? void 0 : interfaceObj.theme]);
|
|
101
90
|
var applePayPaymentMethodOptions = useMemo(function () {
|
|
102
91
|
if (!profileData)
|
|
103
|
-
return
|
|
104
|
-
return
|
|
92
|
+
return undefined;
|
|
93
|
+
return getPaymentMethod(profileData.payment_options.payment_methods || [], PAYMENT_METHOD_KEY);
|
|
105
94
|
}, [profileData]);
|
|
106
95
|
var merchantValidationRequestData = useMemo(function () {
|
|
107
96
|
if (!profileData)
|
|
@@ -110,97 +99,66 @@ export var useApplePay = function (_a) {
|
|
|
110
99
|
merchantId: merchant.id || (profileData === null || profileData === void 0 ? void 0 : profileData.merchant.id),
|
|
111
100
|
merchantName: profileData.merchant.name,
|
|
112
101
|
validationUrl: '',
|
|
113
|
-
origin:
|
|
114
|
-
|
|
102
|
+
origin: window.location.hostname,
|
|
103
|
+
merchantIdentifier: (applePayPaymentMethodOptions === null || applePayPaymentMethodOptions === void 0 ? void 0 : applePayPaymentMethodOptions.identifier) || FALLBACK_MERCHANT_IDENTIFIER
|
|
115
104
|
};
|
|
116
|
-
}, [merchant, profileData === null || profileData === void 0 ? void 0 : profileData.merchant,
|
|
117
|
-
var initialize = function (
|
|
118
|
-
var
|
|
119
|
-
var
|
|
120
|
-
return __generator(this, function (
|
|
121
|
-
switch (
|
|
105
|
+
}, [merchant, profileData === null || profileData === void 0 ? void 0 : profileData.merchant, applePayPaymentMethodOptions === null || applePayPaymentMethodOptions === void 0 ? void 0 : applePayPaymentMethodOptions.identifier]);
|
|
106
|
+
var initialize = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
107
|
+
var session, _a, id, api_version, contact, applePayPreparedData, err_1;
|
|
108
|
+
var _b, _c, _d;
|
|
109
|
+
return __generator(this, function (_e) {
|
|
110
|
+
switch (_e.label) {
|
|
122
111
|
case 0:
|
|
123
|
-
|
|
124
|
-
_o.label = 1;
|
|
125
|
-
case 1:
|
|
126
|
-
_o.trys.push([1, 7, , 8]);
|
|
112
|
+
_e.trys.push([0, 5, , 6]);
|
|
127
113
|
if (!shallRenderApplePay()) {
|
|
128
114
|
throw new Error('The device/customer is not eligible to use ApplePay');
|
|
129
115
|
}
|
|
130
|
-
if (
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
setApplePayRequestData(applePayPreparedData_1.applePaySessionRequest);
|
|
136
|
-
setInitialLoading(false);
|
|
137
|
-
return [2];
|
|
116
|
+
if (!applePayPaymentMethodOptions) {
|
|
117
|
+
throw new Error("000::".concat(PAYMENT_METHOD_KEY.toUpperCase(), " is not configured in your payment options"));
|
|
118
|
+
}
|
|
119
|
+
if (!profileData) {
|
|
120
|
+
throw new Error('000::Profile data is not available');
|
|
138
121
|
}
|
|
139
|
-
|
|
122
|
+
session = headers === null || headers === void 0 ? void 0 : headers.session;
|
|
123
|
+
setAxiosGlobalHeaders({ session: session });
|
|
124
|
+
if (!(headers && areAllTheObjectStringValuesValid(headers))) return [3, 2];
|
|
140
125
|
return [4, appService.setHttpHeaders(__assign(__assign({}, headers), { authorization: operator.publicKey }))];
|
|
141
|
-
case
|
|
142
|
-
|
|
143
|
-
return [3,
|
|
144
|
-
case
|
|
126
|
+
case 1:
|
|
127
|
+
_e.sent();
|
|
128
|
+
return [3, 4];
|
|
129
|
+
case 2: return [4, appService.setBrowserHeaders({
|
|
145
130
|
locale: interfaceObj === null || interfaceObj === void 0 ? void 0 : interfaceObj.locale,
|
|
146
131
|
domain: window.location.origin,
|
|
147
132
|
pk: operator.publicKey
|
|
148
133
|
})];
|
|
134
|
+
case 3:
|
|
135
|
+
_e.sent();
|
|
136
|
+
_e.label = 4;
|
|
149
137
|
case 4:
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
order: __assign(__assign({ id: order === null || order === void 0 ? void 0 : order.id, amount: Number(order.amount), currency: order.currency, description: order === null || order === void 0 ? void 0 : order.description, metadata: order === null || order === void 0 ? void 0 : order.metadata }, (customer && {
|
|
160
|
-
customer: {
|
|
161
|
-
id: customer === null || customer === void 0 ? void 0 : customer.id,
|
|
162
|
-
email: (_a = customer.contact) === null || _a === void 0 ? void 0 : _a.email,
|
|
163
|
-
first_name: ((_b = customer.name) === null || _b === void 0 ? void 0 : _b.length) ? customer.name[0].first : '',
|
|
164
|
-
last_name: ((_c = customer.name) === null || _c === void 0 ? void 0 : _c.length) ? customer.name[0].last : '',
|
|
165
|
-
phone: {
|
|
166
|
-
country_code: (_f = (_e = (_d = customer.contact) === null || _d === void 0 ? void 0 : _d.phone) === null || _e === void 0 ? void 0 : _e.countryCode) !== null && _f !== void 0 ? _f : '',
|
|
167
|
-
number: (_j = (_h = (_g = customer.contact) === null || _g === void 0 ? void 0 : _g.phone) === null || _h === void 0 ? void 0 : _h.number) !== null && _j !== void 0 ? _j : ''
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
})), { merchant: {
|
|
171
|
-
id: merchant === null || merchant === void 0 ? void 0 : merchant.id
|
|
172
|
-
}, items: [
|
|
173
|
-
{
|
|
174
|
-
amount: Number(order.amount),
|
|
175
|
-
currency: order.currency,
|
|
176
|
-
name: "apple pay sdk button order item",
|
|
177
|
-
quantity: 1,
|
|
178
|
-
description: "apple pay sdk button order item description"
|
|
179
|
-
}
|
|
180
|
-
] })
|
|
181
|
-
})];
|
|
182
|
-
case 6:
|
|
183
|
-
data = _o.sent();
|
|
184
|
-
if (debug)
|
|
185
|
-
console.log('merchant configuration: ', data);
|
|
186
|
-
setProfile(data);
|
|
187
|
-
applePayPreparedData = prepareApplePayRequest(__assign(__assign({}, data), { order: order, acceptance: acceptance, customer: customer }));
|
|
138
|
+
if (debug) {
|
|
139
|
+
_a = profileData.merchant, id = _a.id, api_version = _a.api_version, contact = _a.contact;
|
|
140
|
+
console.log('merchant configuration: ', {
|
|
141
|
+
id: id,
|
|
142
|
+
api_version: api_version,
|
|
143
|
+
contact: contact
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
applePayPreparedData = prepareApplePayRequest(__assign(__assign({}, profileData), { order: order, acceptance: acceptance, customer: customer }));
|
|
188
147
|
setApplePayRequestData(applePayPreparedData.applePaySessionRequest);
|
|
189
|
-
onOrderCreated === null || onOrderCreated === void 0 ? void 0 : onOrderCreated((
|
|
148
|
+
onOrderCreated === null || onOrderCreated === void 0 ? void 0 : onOrderCreated((_c = (_b = profileData.payment_options) === null || _b === void 0 ? void 0 : _b.order) === null || _c === void 0 ? void 0 : _c.id);
|
|
190
149
|
setApplePayRequestConfiguration({
|
|
191
150
|
BASE_URL: MW_BASE_URL,
|
|
192
151
|
headers: getAxiosGlobalHeaders(),
|
|
193
|
-
merchant: __assign(__assign({},
|
|
152
|
+
merchant: __assign(__assign({}, profileData.merchant), { id: merchant.id || ((_d = profileData.merchant) === null || _d === void 0 ? void 0 : _d.id) })
|
|
194
153
|
});
|
|
195
|
-
setInitialLoading(false);
|
|
196
154
|
onReady === null || onReady === void 0 ? void 0 : onReady();
|
|
197
|
-
return [3,
|
|
198
|
-
case
|
|
199
|
-
err_1 =
|
|
155
|
+
return [3, 6];
|
|
156
|
+
case 5:
|
|
157
|
+
err_1 = _e.sent();
|
|
200
158
|
onError === null || onError === void 0 ? void 0 : onError(err_1.errors || err_1);
|
|
201
159
|
console.log('error in initialize', err_1);
|
|
202
|
-
return [3,
|
|
203
|
-
case
|
|
160
|
+
return [3, 6];
|
|
161
|
+
case 6: return [2];
|
|
204
162
|
}
|
|
205
163
|
});
|
|
206
164
|
}); };
|
|
@@ -269,73 +227,72 @@ export var useApplePay = function (_a) {
|
|
|
269
227
|
});
|
|
270
228
|
}); };
|
|
271
229
|
session_1.onpaymentauthorized = function (event) { return __awaiter(void 0, void 0, void 0, function () {
|
|
272
|
-
var _a, paymentData, paymentMethod, transactionIdentifier, _b, data, tokenId,
|
|
273
|
-
var _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0;
|
|
274
|
-
return __generator(this, function (
|
|
275
|
-
switch (
|
|
230
|
+
var _a, paymentData, paymentMethod, transactionIdentifier, _b, data, tokenId, supportedCurrency, transactionRequest, transactionResponse, _c, successState, error_2;
|
|
231
|
+
var _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1;
|
|
232
|
+
return __generator(this, function (_2) {
|
|
233
|
+
switch (_2.label) {
|
|
276
234
|
case 0:
|
|
277
235
|
if (debug)
|
|
278
236
|
console.info('onpaymentauthorized event', event);
|
|
279
|
-
|
|
237
|
+
_2.label = 1;
|
|
280
238
|
case 1:
|
|
281
|
-
|
|
239
|
+
_2.trys.push([1, 16, 17, 18]);
|
|
282
240
|
_a = (_d = event.payment.token) !== null && _d !== void 0 ? _d : {}, paymentData = _a.paymentData, paymentMethod = _a.paymentMethod, transactionIdentifier = _a.transactionIdentifier;
|
|
283
241
|
_b = scope;
|
|
284
242
|
switch (_b) {
|
|
285
243
|
case Scope.APPLE_PAY_TOKEN: return [3, 2];
|
|
286
|
-
case Scope.
|
|
244
|
+
case Scope.TOKEN: return [3, 4];
|
|
287
245
|
case Scope.AUTHORIZE: return [3, 7];
|
|
288
246
|
case Scope.CHARGE: return [3, 7];
|
|
289
247
|
}
|
|
290
248
|
return [3, 14];
|
|
291
249
|
case 2: return [4, (onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(event.payment.token))];
|
|
292
250
|
case 3:
|
|
293
|
-
|
|
251
|
+
_2.sent();
|
|
294
252
|
session_1.completePayment({ status: ApplePaySession.STATUS_SUCCESS });
|
|
295
253
|
return [3, 15];
|
|
296
254
|
case 4:
|
|
297
255
|
setLoading(true);
|
|
298
256
|
return [4, appService.tapTokenization(__assign(__assign({}, paymentData), { paymentMethod: paymentMethod, transactionIdentifier: transactionIdentifier }))];
|
|
299
257
|
case 5:
|
|
300
|
-
data =
|
|
258
|
+
data = _2.sent();
|
|
301
259
|
setSuccess === null || setSuccess === void 0 ? void 0 : setSuccess(true);
|
|
302
260
|
return [4, (onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(data))];
|
|
303
261
|
case 6:
|
|
304
|
-
|
|
262
|
+
_2.sent();
|
|
305
263
|
session_1.completePayment({ status: ApplePaySession.STATUS_SUCCESS });
|
|
306
264
|
return [3, 15];
|
|
307
265
|
case 7:
|
|
308
266
|
setLoading(true);
|
|
309
267
|
return [4, appService.tapTokenization(__assign(__assign({}, paymentData), { paymentMethod: paymentMethod, transactionIdentifier: transactionIdentifier }))];
|
|
310
268
|
case 8:
|
|
311
|
-
tokenId = (
|
|
312
|
-
|
|
269
|
+
tokenId = (_2.sent()).id;
|
|
270
|
+
supportedCurrency = getSelectedCurrency((profileData === null || profileData === void 0 ? void 0 : profileData.payment_options.supported_currencies) || [], order, applePayPaymentMethodOptions);
|
|
313
271
|
transactionRequest = {
|
|
314
|
-
auto: (
|
|
315
|
-
amount: (
|
|
316
|
-
currency: (
|
|
317
|
-
selected_amount:
|
|
318
|
-
selected_currency:
|
|
272
|
+
auto: (_e = transaction === null || transaction === void 0 ? void 0 : transaction.authorize) === null || _e === void 0 ? void 0 : _e.auto,
|
|
273
|
+
amount: (_h = (_g = (_f = profileData === null || profileData === void 0 ? void 0 : profileData.payment_options) === null || _f === void 0 ? void 0 : _f.order) === null || _g === void 0 ? void 0 : _g.amount) !== null && _h !== void 0 ? _h : order.amount,
|
|
274
|
+
currency: (_l = (_k = (_j = profileData === null || profileData === void 0 ? void 0 : profileData.payment_options) === null || _j === void 0 ? void 0 : _j.order) === null || _k === void 0 ? void 0 : _k.currency) !== null && _l !== void 0 ? _l : order.currency,
|
|
275
|
+
selected_amount: supportedCurrency === null || supportedCurrency === void 0 ? void 0 : supportedCurrency.amount,
|
|
276
|
+
selected_currency: supportedCurrency === null || supportedCurrency === void 0 ? void 0 : supportedCurrency.currency,
|
|
319
277
|
customer: (customer === null || customer === void 0 ? void 0 : customer.id)
|
|
320
278
|
? { id: customer === null || customer === void 0 ? void 0 : customer.id }
|
|
321
279
|
: {
|
|
322
|
-
email: (
|
|
323
|
-
first_name: ((
|
|
324
|
-
last_name: ((
|
|
280
|
+
email: (_m = customer === null || customer === void 0 ? void 0 : customer.contact) === null || _m === void 0 ? void 0 : _m.email,
|
|
281
|
+
first_name: ((_o = customer === null || customer === void 0 ? void 0 : customer.name) === null || _o === void 0 ? void 0 : _o.length) ? customer.name[0].first : '',
|
|
282
|
+
last_name: ((_p = customer === null || customer === void 0 ? void 0 : customer.name) === null || _p === void 0 ? void 0 : _p.length) ? customer.name[0].last : '',
|
|
325
283
|
phone: {
|
|
326
|
-
country_code: (
|
|
327
|
-
number: (
|
|
284
|
+
country_code: (_s = (_r = (_q = customer === null || customer === void 0 ? void 0 : customer.contact) === null || _q === void 0 ? void 0 : _q.phone) === null || _r === void 0 ? void 0 : _r.countryCode) !== null && _s !== void 0 ? _s : '',
|
|
285
|
+
number: (_v = (_u = (_t = customer === null || customer === void 0 ? void 0 : customer.contact) === null || _t === void 0 ? void 0 : _t.phone) === null || _u === void 0 ? void 0 : _u.number) !== null && _v !== void 0 ? _v : ''
|
|
328
286
|
}
|
|
329
287
|
},
|
|
330
|
-
fee: 0,
|
|
331
288
|
merchant: {
|
|
332
|
-
id: (
|
|
289
|
+
id: (_x = (_w = profileData === null || profileData === void 0 ? void 0 : profileData.merchant) === null || _w === void 0 ? void 0 : _w.id) !== null && _x !== void 0 ? _x : ''
|
|
333
290
|
},
|
|
334
|
-
order: (
|
|
291
|
+
order: (_y = profileData === null || profileData === void 0 ? void 0 : profileData.payment_options) === null || _y === void 0 ? void 0 : _y.order,
|
|
335
292
|
product: 'Apple-Pay-Button',
|
|
336
|
-
save_card:
|
|
293
|
+
save_card: !!((_z = features === null || features === void 0 ? void 0 : features.customerCards) === null || _z === void 0 ? void 0 : _z.saveCard),
|
|
337
294
|
source: { id: tokenId !== null && tokenId !== void 0 ? tokenId : '' },
|
|
338
|
-
threeDSecure: transaction === null || transaction === void 0 ? void 0 : transaction.
|
|
295
|
+
threeDSecure: (_1 = (_0 = transaction === null || transaction === void 0 ? void 0 : transaction.authenticate) === null || _0 === void 0 ? void 0 : _0.required) !== null && _1 !== void 0 ? _1 : true,
|
|
339
296
|
hashstring: operator.hashstring,
|
|
340
297
|
redirect: redirect,
|
|
341
298
|
metadata: transaction === null || transaction === void 0 ? void 0 : transaction.metadata,
|
|
@@ -350,12 +307,12 @@ export var useApplePay = function (_a) {
|
|
|
350
307
|
if (!(scope === Scope.AUTHORIZE)) return [3, 10];
|
|
351
308
|
return [4, appService.createAuthorize(transactionRequest)];
|
|
352
309
|
case 9:
|
|
353
|
-
_c =
|
|
310
|
+
_c = _2.sent();
|
|
354
311
|
return [3, 12];
|
|
355
312
|
case 10: return [4, appService.createCharge(transactionRequest)];
|
|
356
313
|
case 11:
|
|
357
|
-
_c =
|
|
358
|
-
|
|
314
|
+
_c = _2.sent();
|
|
315
|
+
_2.label = 12;
|
|
359
316
|
case 12:
|
|
360
317
|
transactionResponse = _c;
|
|
361
318
|
successState = scope === Scope.AUTHORIZE ? ChargeCode.AUTHORIZED : ChargeCode.SUCCESS;
|
|
@@ -367,17 +324,17 @@ export var useApplePay = function (_a) {
|
|
|
367
324
|
}
|
|
368
325
|
return [4, (onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(transactionResponse))];
|
|
369
326
|
case 13:
|
|
370
|
-
|
|
327
|
+
_2.sent();
|
|
371
328
|
session_1.completePayment({ status: ApplePaySession.STATUS_SUCCESS });
|
|
372
329
|
return [3, 15];
|
|
373
330
|
case 14:
|
|
374
331
|
console.error('We only support AppleToken and TapToken for now');
|
|
375
332
|
console.info('Completing payment with status: STATUS_FAILURE');
|
|
376
333
|
session_1.completePayment({ status: ApplePaySession.STATUS_FAILURE });
|
|
377
|
-
|
|
334
|
+
_2.label = 15;
|
|
378
335
|
case 15: return [3, 18];
|
|
379
336
|
case 16:
|
|
380
|
-
error_2 =
|
|
337
|
+
error_2 = _2.sent();
|
|
381
338
|
if (debug)
|
|
382
339
|
console.error('error in onpaymentauthorized', error_2);
|
|
383
340
|
setError(true);
|
|
@@ -434,7 +391,7 @@ export var useApplePay = function (_a) {
|
|
|
434
391
|
merchantValidationRequestData
|
|
435
392
|
]);
|
|
436
393
|
useEffect(function () {
|
|
437
|
-
initialize(
|
|
394
|
+
initialize();
|
|
438
395
|
}, []);
|
|
439
396
|
useEffect(function () {
|
|
440
397
|
setIsRounded(error || success || loading);
|
|
@@ -459,7 +416,6 @@ export var useApplePay = function (_a) {
|
|
|
459
416
|
applePayRequestConfiguration: applePayRequestConfiguration,
|
|
460
417
|
mappedProps: mappedProps,
|
|
461
418
|
theme: theme,
|
|
462
|
-
initialLoading: initialLoading,
|
|
463
419
|
isRounded: isRounded,
|
|
464
420
|
success: success,
|
|
465
421
|
error: error,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { MetaData, ApplePayButtonProps,
|
|
1
|
+
import { MetaData, ApplePayButtonProps, ProfileData } from '../@types';
|
|
2
|
+
import { Scope } from '@tap-payments/acceptance-sdk';
|
|
2
3
|
interface ApplePayRequestData {
|
|
3
4
|
isIframeIntegration: boolean;
|
|
4
5
|
onError?: (error: any) => void;
|
|
@@ -6,8 +7,8 @@ interface ApplePayRequestData {
|
|
|
6
7
|
setLoading?: (loading: boolean) => void;
|
|
7
8
|
setSuccess?: (success: boolean) => void;
|
|
8
9
|
setError?: (error: boolean) => void;
|
|
9
|
-
scope:
|
|
10
|
-
profileData?:
|
|
10
|
+
scope: Scope;
|
|
11
|
+
profileData?: ProfileData;
|
|
11
12
|
merchant: Pick<MetaData['merchant'], 'id'>;
|
|
12
13
|
order: ApplePayButtonProps['order'];
|
|
13
14
|
customer: ApplePayButtonProps['customer'];
|
|
@@ -15,6 +16,7 @@ interface ApplePayRequestData {
|
|
|
15
16
|
operator: ApplePayButtonProps['operator'];
|
|
16
17
|
redirect?: ApplePayButtonProps['redirect'];
|
|
17
18
|
post?: ApplePayButtonProps['post'];
|
|
19
|
+
features?: ApplePayButtonProps['features'];
|
|
18
20
|
}
|
|
19
|
-
export declare const useMerchantApplePay: ({ isIframeIntegration, onError, onSuccess, setLoading, setError, setSuccess, scope, profileData, order, customer, transaction, operator, redirect, post }: ApplePayRequestData) => void;
|
|
21
|
+
export declare const useMerchantApplePay: ({ isIframeIntegration, onError, onSuccess, setLoading, setError, setSuccess, scope, profileData, order, customer, transaction, operator, redirect, post, features }: ApplePayRequestData) => void;
|
|
20
22
|
export {};
|
|
@@ -47,29 +47,32 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
47
47
|
};
|
|
48
48
|
import * as React from 'react';
|
|
49
49
|
import appService from '../api';
|
|
50
|
-
import {
|
|
50
|
+
import { CHARGE_CODE } from '../@types';
|
|
51
|
+
import { getPaymentMethod, Scope, getSelectedCurrency } from '@tap-payments/acceptance-sdk';
|
|
52
|
+
import { PAYMENT_METHOD_KEY } from '../utils';
|
|
51
53
|
var EVENT_NAME = 'TAP_BUTTON::APPLE_PAY_ON_PAYMENT_AUTHORIZED';
|
|
52
54
|
export var useMerchantApplePay = function (_a) {
|
|
53
|
-
var isIframeIntegration = _a.isIframeIntegration, onError = _a.onError, onSuccess = _a.onSuccess, setLoading = _a.setLoading, setError = _a.setError, setSuccess = _a.setSuccess, scope = _a.scope, profileData = _a.profileData, order = _a.order, customer = _a.customer, transaction = _a.transaction, operator = _a.operator, redirect = _a.redirect, post = _a.post;
|
|
55
|
+
var isIframeIntegration = _a.isIframeIntegration, onError = _a.onError, onSuccess = _a.onSuccess, setLoading = _a.setLoading, setError = _a.setError, setSuccess = _a.setSuccess, scope = _a.scope, profileData = _a.profileData, order = _a.order, customer = _a.customer, transaction = _a.transaction, operator = _a.operator, redirect = _a.redirect, post = _a.post, features = _a.features;
|
|
54
56
|
var onMessageReceived = React.useCallback(function (_a) {
|
|
55
57
|
var message = _a.data;
|
|
56
58
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
57
|
-
var _b, event, data, _c, paymentData, paymentMethod, transactionIdentifier, _d, response, tokenId,
|
|
58
|
-
var _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2;
|
|
59
|
-
return __generator(this, function (
|
|
60
|
-
switch (
|
|
59
|
+
var _b, event, data, _c, paymentData, paymentMethod, transactionIdentifier, applyPayPaymentMethod, _d, response, tokenId, supportedCurrency, transactionRequest, transactionResponse, _e, successState, e_1;
|
|
60
|
+
var _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3;
|
|
61
|
+
return __generator(this, function (_4) {
|
|
62
|
+
switch (_4.label) {
|
|
61
63
|
case 0:
|
|
62
64
|
_b = message !== null && message !== void 0 ? message : {}, event = _b.event, data = _b.data;
|
|
63
65
|
if (!data || event !== EVENT_NAME)
|
|
64
66
|
return [2];
|
|
65
67
|
_c = data !== null && data !== void 0 ? data : {}, paymentData = _c.paymentData, paymentMethod = _c.paymentMethod, transactionIdentifier = _c.transactionIdentifier;
|
|
66
|
-
|
|
68
|
+
applyPayPaymentMethod = getPaymentMethod((profileData === null || profileData === void 0 ? void 0 : profileData.payment_options.payment_methods) || [], PAYMENT_METHOD_KEY);
|
|
69
|
+
_4.label = 1;
|
|
67
70
|
case 1:
|
|
68
|
-
|
|
71
|
+
_4.trys.push([1, 13, 14, 15]);
|
|
69
72
|
_d = scope;
|
|
70
73
|
switch (_d) {
|
|
71
74
|
case Scope.APPLE_PAY_TOKEN: return [3, 2];
|
|
72
|
-
case Scope.
|
|
75
|
+
case Scope.TOKEN: return [3, 3];
|
|
73
76
|
case Scope.AUTHORIZE: return [3, 5];
|
|
74
77
|
case Scope.CHARGE: return [3, 5];
|
|
75
78
|
}
|
|
@@ -81,7 +84,7 @@ export var useMerchantApplePay = function (_a) {
|
|
|
81
84
|
setLoading === null || setLoading === void 0 ? void 0 : setLoading(true);
|
|
82
85
|
return [4, appService.tapTokenization(__assign(__assign({}, paymentData), { paymentMethod: paymentMethod, transactionIdentifier: transactionIdentifier }))];
|
|
83
86
|
case 4:
|
|
84
|
-
response =
|
|
87
|
+
response = _4.sent();
|
|
85
88
|
setSuccess === null || setSuccess === void 0 ? void 0 : setSuccess(true);
|
|
86
89
|
onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(response);
|
|
87
90
|
return [3, 12];
|
|
@@ -89,34 +92,33 @@ export var useMerchantApplePay = function (_a) {
|
|
|
89
92
|
setLoading === null || setLoading === void 0 ? void 0 : setLoading(true);
|
|
90
93
|
return [4, appService.tapTokenization(__assign(__assign({}, paymentData), { paymentMethod: paymentMethod, transactionIdentifier: transactionIdentifier }))];
|
|
91
94
|
case 6:
|
|
92
|
-
tokenId = (
|
|
93
|
-
|
|
95
|
+
tokenId = (_4.sent()).id;
|
|
96
|
+
supportedCurrency = getSelectedCurrency((profileData === null || profileData === void 0 ? void 0 : profileData.payment_options.supported_currencies) || [], order, applyPayPaymentMethod);
|
|
94
97
|
transactionRequest = {
|
|
95
|
-
auto: (
|
|
96
|
-
amount: (
|
|
97
|
-
currency: (
|
|
98
|
-
selected_amount:
|
|
99
|
-
selected_currency:
|
|
98
|
+
auto: (_f = transaction === null || transaction === void 0 ? void 0 : transaction.authorize) === null || _f === void 0 ? void 0 : _f.auto,
|
|
99
|
+
amount: (_j = (_h = (_g = profileData === null || profileData === void 0 ? void 0 : profileData.payment_options) === null || _g === void 0 ? void 0 : _g.order) === null || _h === void 0 ? void 0 : _h.amount) !== null && _j !== void 0 ? _j : order.amount,
|
|
100
|
+
currency: (_m = (_l = (_k = profileData === null || profileData === void 0 ? void 0 : profileData.payment_options) === null || _k === void 0 ? void 0 : _k.order) === null || _l === void 0 ? void 0 : _l.currency) !== null && _m !== void 0 ? _m : order.currency,
|
|
101
|
+
selected_amount: supportedCurrency === null || supportedCurrency === void 0 ? void 0 : supportedCurrency.amount,
|
|
102
|
+
selected_currency: supportedCurrency === null || supportedCurrency === void 0 ? void 0 : supportedCurrency.currency,
|
|
100
103
|
customer: (customer === null || customer === void 0 ? void 0 : customer.id)
|
|
101
104
|
? { id: customer === null || customer === void 0 ? void 0 : customer.id }
|
|
102
105
|
: {
|
|
103
|
-
email: (
|
|
104
|
-
first_name: ((
|
|
105
|
-
last_name: ((
|
|
106
|
+
email: (_o = customer === null || customer === void 0 ? void 0 : customer.contact) === null || _o === void 0 ? void 0 : _o.email,
|
|
107
|
+
first_name: ((_p = customer === null || customer === void 0 ? void 0 : customer.name) === null || _p === void 0 ? void 0 : _p.length) ? customer.name[0].first : '',
|
|
108
|
+
last_name: ((_q = customer === null || customer === void 0 ? void 0 : customer.name) === null || _q === void 0 ? void 0 : _q.length) ? customer.name[0].last : '',
|
|
106
109
|
phone: {
|
|
107
|
-
country_code: (
|
|
108
|
-
number: (
|
|
110
|
+
country_code: (_t = (_s = (_r = customer === null || customer === void 0 ? void 0 : customer.contact) === null || _r === void 0 ? void 0 : _r.phone) === null || _s === void 0 ? void 0 : _s.countryCode) !== null && _t !== void 0 ? _t : '',
|
|
111
|
+
number: (_w = (_v = (_u = customer === null || customer === void 0 ? void 0 : customer.contact) === null || _u === void 0 ? void 0 : _u.phone) === null || _v === void 0 ? void 0 : _v.number) !== null && _w !== void 0 ? _w : ''
|
|
109
112
|
}
|
|
110
113
|
},
|
|
111
|
-
fee: 0,
|
|
112
114
|
merchant: {
|
|
113
|
-
id: (
|
|
115
|
+
id: (_y = (_x = profileData === null || profileData === void 0 ? void 0 : profileData.merchant) === null || _x === void 0 ? void 0 : _x.id) !== null && _y !== void 0 ? _y : ''
|
|
114
116
|
},
|
|
115
|
-
order: (
|
|
117
|
+
order: (_z = profileData === null || profileData === void 0 ? void 0 : profileData.payment_options) === null || _z === void 0 ? void 0 : _z.order,
|
|
116
118
|
product: 'Apple-Pay-Button',
|
|
117
|
-
save_card:
|
|
119
|
+
save_card: !!((_0 = features === null || features === void 0 ? void 0 : features.customerCards) === null || _0 === void 0 ? void 0 : _0.saveCard),
|
|
118
120
|
source: { id: tokenId !== null && tokenId !== void 0 ? tokenId : '' },
|
|
119
|
-
threeDSecure: transaction === null || transaction === void 0 ? void 0 : transaction.
|
|
121
|
+
threeDSecure: (_2 = (_1 = transaction === null || transaction === void 0 ? void 0 : transaction.authenticate) === null || _1 === void 0 ? void 0 : _1.required) !== null && _2 !== void 0 ? _2 : true,
|
|
120
122
|
hashstring: operator.hashstring,
|
|
121
123
|
redirect: redirect,
|
|
122
124
|
metadata: transaction === null || transaction === void 0 ? void 0 : transaction.metadata,
|
|
@@ -131,12 +133,12 @@ export var useMerchantApplePay = function (_a) {
|
|
|
131
133
|
if (!(scope === Scope.AUTHORIZE)) return [3, 8];
|
|
132
134
|
return [4, appService.createAuthorize(transactionRequest)];
|
|
133
135
|
case 7:
|
|
134
|
-
_e =
|
|
136
|
+
_e = _4.sent();
|
|
135
137
|
return [3, 10];
|
|
136
138
|
case 8: return [4, appService.createCharge(transactionRequest)];
|
|
137
139
|
case 9:
|
|
138
|
-
_e =
|
|
139
|
-
|
|
140
|
+
_e = _4.sent();
|
|
141
|
+
_4.label = 10;
|
|
140
142
|
case 10:
|
|
141
143
|
transactionResponse = _e;
|
|
142
144
|
successState = scope === Scope.AUTHORIZE ? CHARGE_CODE.AUTHORIZED : CHARGE_CODE.SUCCESS;
|
|
@@ -154,14 +156,14 @@ export var useMerchantApplePay = function (_a) {
|
|
|
154
156
|
return [3, 12];
|
|
155
157
|
case 12: return [3, 15];
|
|
156
158
|
case 13:
|
|
157
|
-
e_1 =
|
|
159
|
+
e_1 = _4.sent();
|
|
158
160
|
if (!onError)
|
|
159
161
|
return [2];
|
|
160
162
|
if (e_1.errors) {
|
|
161
163
|
onError(e_1.errors);
|
|
162
164
|
return [2];
|
|
163
165
|
}
|
|
164
|
-
if ((
|
|
166
|
+
if ((_3 = e_1.response) === null || _3 === void 0 ? void 0 : _3.data.errors) {
|
|
165
167
|
onError(e_1.response.data.errors);
|
|
166
168
|
return [2];
|
|
167
169
|
}
|
package/build/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
+
import { Edges, Locale, Scope, ThemeMode } from '@tap-payments/acceptance-sdk';
|
|
1
2
|
import { ApplePayButtonProps, ApplePayButton, ApplePayRequestData } from './features/ApplePayButton';
|
|
2
|
-
import {
|
|
3
|
+
import { SupportedNetworks, ButtonType, MerchantCapabilities } from './@types/enums';
|
|
3
4
|
export type { ApplePayButtonProps, ApplePayRequestData };
|
|
4
5
|
export { ApplePayButton, ThemeMode, Scope, SupportedNetworks, Locale, ButtonType, Edges, MerchantCapabilities };
|
package/build/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { Edges, Locale, Scope, ThemeMode } from '@tap-payments/acceptance-sdk';
|
|
1
2
|
import { ApplePayButton, renderApplePayButton } from './features/ApplePayButton';
|
|
2
|
-
import {
|
|
3
|
+
import { SupportedNetworks, ButtonType, MerchantCapabilities } from './@types/enums';
|
|
3
4
|
export { ApplePayButton, ThemeMode, Scope, SupportedNetworks, Locale, ButtonType, Edges, MerchantCapabilities };
|
|
4
5
|
window['TapSDKs'] = {
|
|
5
6
|
renderApplePayButton: renderApplePayButton,
|
package/build/utils/config.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { Acceptance, ApplePayButtonProps, ApplePayRequestData,
|
|
1
|
+
import { Acceptance, ApplePayButtonProps, ApplePayRequestData, ProfileData } from '../@types';
|
|
2
|
+
export declare const PAYMENT_METHOD_KEY = "apple_pay";
|
|
2
3
|
export declare const validateSupportedNetworks: (supportedNetworksOptions: Acceptance['supportedSchemes'], merchantSupportedNetworks?: Acceptance['supportedSchemes']) => Acceptance['supportedSchemes'];
|
|
3
|
-
export declare const getApplePayPaymentMethod: (paymentMethods: Array<PaymentMethod>) => PaymentMethod;
|
|
4
4
|
export declare const getApplePayRequest: ({ order, customer, supportedNetworks, merchantCapabilities, countryCode, name }: Pick<ApplePayButtonProps, "order" | "customer"> & {
|
|
5
5
|
supportedNetworks: Acceptance['supportedSchemes'];
|
|
6
6
|
merchantCapabilities: ApplePayRequestData['merchantCapabilities'];
|
|
7
7
|
countryCode: string;
|
|
8
8
|
name: string;
|
|
9
9
|
}) => ApplePayRequestData;
|
|
10
|
-
export declare const prepareApplePayRequest: ({ payment_options, merchant, order, customer, acceptance }:
|
|
10
|
+
export declare const prepareApplePayRequest: ({ payment_options, merchant, order, customer, acceptance }: ProfileData & Pick<ApplePayButtonProps, 'order' | 'customer' | 'acceptance'>) => {
|
|
11
11
|
applePaySessionRequest: ApplePayRequestData;
|
|
12
|
-
paymentMethod: PaymentMethod;
|
|
12
|
+
paymentMethod: import("@tap-payments/acceptance-sdk").PaymentMethod | undefined;
|
|
13
13
|
};
|
|
14
14
|
export declare const shallRenderApplePay: () => boolean;
|
package/build/utils/config.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { getMerchantCapabilities } from './defaultValues';
|
|
2
|
+
import { getPaymentMethod, getSelectedCurrency } from '@tap-payments/acceptance-sdk';
|
|
3
|
+
export var PAYMENT_METHOD_KEY = 'apple_pay';
|
|
2
4
|
export var validateSupportedNetworks = function (supportedNetworksOptions, merchantSupportedNetworks) {
|
|
3
5
|
var toLowerCase = function (item) { return item.toLowerCase(); };
|
|
4
6
|
if (!supportedNetworksOptions)
|
|
@@ -15,16 +17,6 @@ export var validateSupportedNetworks = function (supportedNetworksOptions, merch
|
|
|
15
17
|
}
|
|
16
18
|
return supportedNetworks.map(toLowerCase);
|
|
17
19
|
};
|
|
18
|
-
export var getApplePayPaymentMethod = function (paymentMethods) {
|
|
19
|
-
var paymentMethod = paymentMethods.find(function (_a) {
|
|
20
|
-
var name = _a.name, payment_type = _a.payment_type;
|
|
21
|
-
return [name, payment_type].some(function (item) { return item.toLowerCase() === 'apple_pay'; });
|
|
22
|
-
});
|
|
23
|
-
if (!paymentMethod) {
|
|
24
|
-
throw new Error('apple_pay is not configured in your payment options');
|
|
25
|
-
}
|
|
26
|
-
return paymentMethod;
|
|
27
|
-
};
|
|
28
20
|
export var getApplePayRequest = function (_a) {
|
|
29
21
|
var _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
30
22
|
var order = _a.order, customer = _a.customer, supportedNetworks = _a.supportedNetworks, merchantCapabilities = _a.merchantCapabilities, countryCode = _a.countryCode, name = _a.name;
|
|
@@ -40,18 +32,20 @@ export var getApplePayRequest = function (_a) {
|
|
|
40
32
|
familyName: ((_j = customer.name) === null || _j === void 0 ? void 0 : _j.length) ? (_k = customer.name[0]) === null || _k === void 0 ? void 0 : _k.last : ''
|
|
41
33
|
},
|
|
42
34
|
total: {
|
|
43
|
-
amount: Number(
|
|
35
|
+
amount: Number(order.amount),
|
|
44
36
|
label: name
|
|
45
37
|
}
|
|
46
38
|
};
|
|
47
39
|
};
|
|
48
40
|
export var prepareApplePayRequest = function (_a) {
|
|
49
41
|
var payment_options = _a.payment_options, merchant = _a.merchant, order = _a.order, customer = _a.customer, acceptance = _a.acceptance;
|
|
50
|
-
var paymentMethod =
|
|
51
|
-
var supportedNetworks = validateSupportedNetworks(paymentMethod.supported_card_brands, acceptance === null || acceptance === void 0 ? void 0 : acceptance.supportedSchemes);
|
|
42
|
+
var paymentMethod = getPaymentMethod(payment_options.payment_methods || [], PAYMENT_METHOD_KEY);
|
|
43
|
+
var supportedNetworks = validateSupportedNetworks(paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.supported_card_brands, acceptance === null || acceptance === void 0 ? void 0 : acceptance.supportedSchemes);
|
|
44
|
+
var applypayMethod = getPaymentMethod(payment_options.payment_methods || [], PAYMENT_METHOD_KEY);
|
|
45
|
+
var supportedCurrency = getSelectedCurrency(payment_options.supported_currencies || [], order, applypayMethod);
|
|
52
46
|
var request = getApplePayRequest({
|
|
53
47
|
countryCode: merchant.country_code,
|
|
54
|
-
order:
|
|
48
|
+
order: supportedCurrency,
|
|
55
49
|
customer: customer,
|
|
56
50
|
supportedNetworks: supportedNetworks,
|
|
57
51
|
merchantCapabilities: getMerchantCapabilities(acceptance === null || acceptance === void 0 ? void 0 : acceptance.supportedFundSource),
|
package/build/utils/index.d.ts
CHANGED
package/build/utils/index.js
CHANGED
package/build/utils/theme.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { TapThemeResponse } from '../@types';
|
|
2
|
-
import {
|
|
2
|
+
import { FullThemeMode } from '../@types/enums';
|
|
3
3
|
import { ApplePayButtonProps } from '..';
|
|
4
|
+
import { ColorStyle, Locale, ThemeMode } from '@tap-payments/acceptance-sdk';
|
|
4
5
|
export declare const mappingInterface: (interfaceParam?: ApplePayButtonProps['interface']) => ApplePayButtonProps['interface'];
|
|
5
6
|
export declare const getDefaultThemeMode: (themeMode?: ThemeMode) => ThemeMode;
|
|
6
7
|
export declare const getDefaultLocale: (locale?: Locale) => Locale;
|
package/build/utils/theme.js
CHANGED
|
@@ -9,7 +9,8 @@ var __assign = (this && this.__assign) || function () {
|
|
|
9
9
|
};
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
|
-
import {
|
|
12
|
+
import { FullThemeMode } from '../@types/enums';
|
|
13
|
+
import { ColorStyle, Edges, Locale, ThemeMode } from '@tap-payments/acceptance-sdk';
|
|
13
14
|
export var mappingInterface = function (interfaceParam) {
|
|
14
15
|
return __assign(__assign({ edges: Edges.CURVED, colorStyle: ColorStyle.COLORED, loader: true }, interfaceParam), { locale: getDefaultLocale(interfaceParam === null || interfaceParam === void 0 ? void 0 : interfaceParam.locale), theme: getDefaultThemeMode(interfaceParam === null || interfaceParam === void 0 ? void 0 : interfaceParam.theme) });
|
|
15
16
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tap-payments/apple-pay-button",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6-staging",
|
|
4
4
|
"description": "Apple Pay Button React Component",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"module": "build/index.js",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
},
|
|
30
30
|
"license": "ISC",
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@tap-payments/acceptance-sdk": "
|
|
32
|
+
"@tap-payments/acceptance-sdk": "0.0.64",
|
|
33
33
|
"@tap-payments/browser-info": "^1.0.2",
|
|
34
34
|
"@tap-payments/web-error-handing": "^1.0.1",
|
|
35
35
|
"axios": "^1.2.2",
|
package/build/utils/html.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const findOrCreateElementAndInject: (id: string) => HTMLElement;
|
package/build/utils/html.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export var findOrCreateElementAndInject = function (id) {
|
|
2
|
-
var findElement = document.getElementById(id);
|
|
3
|
-
if (findElement)
|
|
4
|
-
return findElement;
|
|
5
|
-
var element = document.createElement('div');
|
|
6
|
-
element.setAttribute('id', id);
|
|
7
|
-
document.body.appendChild(element);
|
|
8
|
-
return element;
|
|
9
|
-
};
|