@tap-payments/apple-pay-button 0.0.86-development → 0.0.88-development
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 -1
- package/build/@types/enums.d.ts +5 -25
- package/build/@types/enums.js +6 -30
- package/build/api.d.ts +3 -1
- package/build/features/ApplePayButton/ApplePayButton.js +3 -4
- package/build/hooks/useApplePay.d.ts +8 -80
- package/build/hooks/useApplePay.js +56 -100
- package/build/hooks/useMerchantApplePay.d.ts +4 -3
- package/build/hooks/useMerchantApplePay.js +3 -2
- package/build/index.d.ts +2 -1
- package/build/index.js +2 -1
- package/build/utils/config.d.ts +4 -4
- 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
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,8 @@ 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
|
+
WEBVIEW = "webview"
|
|
45
|
+
}
|
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,9 @@ 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["WEBVIEW"] = "webview";
|
|
52
|
+
})(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;
|
|
@@ -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,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
interface
|
|
3
|
-
buttonProps:
|
|
1
|
+
import { ApplePayDataToLunchSDKFromMerchantSide, ApplePayRequestData } from '../@types';
|
|
2
|
+
interface UseApplePayParams {
|
|
3
|
+
buttonProps: any;
|
|
4
4
|
}
|
|
5
|
-
export declare const useApplePay: ({ buttonProps }:
|
|
5
|
+
export declare const useApplePay: ({ buttonProps }: UseApplePayParams) => {
|
|
6
6
|
onClick: () => void;
|
|
7
7
|
loading: boolean;
|
|
8
8
|
isIframeIntegration: boolean;
|
|
@@ -10,84 +10,12 @@ export declare const useApplePay: ({ buttonProps }: UsaApplePayProps) => {
|
|
|
10
10
|
disabled: boolean;
|
|
11
11
|
applePayRequestData: ApplePayRequestData | undefined;
|
|
12
12
|
applePayRequestConfiguration: Omit<ApplePayDataToLunchSDKFromMerchantSide, "applePayRequestData"> | undefined;
|
|
13
|
-
mappedProps:
|
|
14
|
-
|
|
15
|
-
locale?: import("@tap-payments/acceptance-sdk").Locale | undefined;
|
|
16
|
-
theme?: import("@tap-payments/acceptance-sdk").ThemeMode | undefined;
|
|
17
|
-
edges?: import("@tap-payments/acceptance-sdk").Edges | undefined;
|
|
18
|
-
colorStyle?: import("@tap-payments/acceptance-sdk").ColorStyle | undefined;
|
|
19
|
-
loader?: boolean | undefined;
|
|
20
|
-
userExperience?: "popup" | "page" | undefined;
|
|
21
|
-
powered?: boolean | undefined;
|
|
22
|
-
direction?: import("@tap-payments/acceptance-sdk").Direction | undefined;
|
|
23
|
-
cardDirection?: import("@tap-payments/acceptance-sdk").Direction | undefined;
|
|
24
|
-
} | undefined;
|
|
25
|
-
operator: {
|
|
26
|
-
publicKey: string;
|
|
27
|
-
hashstring?: string | undefined;
|
|
28
|
-
};
|
|
29
|
-
merchant: {
|
|
30
|
-
id: string;
|
|
31
|
-
identifier?: string | undefined;
|
|
32
|
-
};
|
|
33
|
-
scope: Scope;
|
|
34
|
-
customer?: import("../@types").Customer | undefined;
|
|
35
|
-
acceptance?: import("../@types").Acceptance | undefined;
|
|
36
|
-
transaction?: {
|
|
37
|
-
authentication?: boolean | undefined;
|
|
38
|
-
authorize?: {
|
|
39
|
-
auto: {
|
|
40
|
-
type: string;
|
|
41
|
-
time: number;
|
|
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
|
-
};
|
|
65
|
-
post?: {
|
|
66
|
-
url: string;
|
|
67
|
-
} | undefined;
|
|
68
|
-
redirect?: {
|
|
69
|
-
url: string;
|
|
70
|
-
} | undefined;
|
|
71
|
-
onOrderCreated?: ((orderId: string) => void) | undefined;
|
|
72
|
-
onCancel?: (() => void) | undefined;
|
|
73
|
-
onError?: ((error: any) => void) | undefined;
|
|
74
|
-
onSuccess?: ((data: Record<string, any>) => Promise<void>) | undefined;
|
|
75
|
-
onClick?: ((data?: ApplePayDataToLunchSDKFromMerchantSide | undefined) => void) | undefined;
|
|
76
|
-
onReady?: (() => void) | undefined;
|
|
77
|
-
metaData?: MetaData | undefined;
|
|
78
|
-
debug?: boolean | undefined;
|
|
79
|
-
integration?: "iframe" | "sdk" | "webview" | undefined;
|
|
80
|
-
headers?: {
|
|
81
|
-
mdn: string;
|
|
82
|
-
application: string;
|
|
83
|
-
} | undefined;
|
|
84
|
-
};
|
|
85
|
-
theme: import("../@types").ThemeMode;
|
|
86
|
-
initialLoading: boolean;
|
|
13
|
+
mappedProps: any;
|
|
14
|
+
theme: import("@tap-payments/acceptance-sdk").ThemeMode;
|
|
87
15
|
isRounded: boolean;
|
|
88
16
|
success: boolean;
|
|
89
17
|
error: boolean;
|
|
90
|
-
applePayPaymentMethodOptions: import("
|
|
91
|
-
profileData:
|
|
18
|
+
applePayPaymentMethodOptions: import("@tap-payments/acceptance-sdk").PaymentMethod | null;
|
|
19
|
+
profileData: import("@tap-payments/acceptance-sdk").CheckoutProfileResponse | undefined;
|
|
92
20
|
};
|
|
93
21
|
export {};
|
|
@@ -45,41 +45,28 @@ 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
49
|
import { ApplePayVersion, MW_BASE_URL } from '../constants';
|
|
61
50
|
import { prepareApplePayRequest, shallRenderApplePay } from '../utils/config';
|
|
62
|
-
import {
|
|
51
|
+
import { IntegrationType } from '../@types';
|
|
63
52
|
import { useMerchantApplePay } from './useMerchantApplePay';
|
|
64
53
|
import { getApplePayPaymentMethod, getDefaultThemeMode } from '../utils';
|
|
65
54
|
import appService, { getAxiosGlobalHeaders, setAxiosGlobalHeaders } from '../api';
|
|
66
|
-
import { ChargeCode, mappingInterface } from '@tap-payments/acceptance-sdk';
|
|
55
|
+
import { areAllTheObjectStringValuesValid, ChargeCode, mappingInterface, Scope } from '@tap-payments/acceptance-sdk';
|
|
67
56
|
export var useApplePay = function (_a) {
|
|
68
|
-
var _b;
|
|
69
57
|
var buttonProps = _a.buttonProps;
|
|
70
|
-
var
|
|
71
|
-
var
|
|
72
|
-
var
|
|
73
|
-
var
|
|
74
|
-
var
|
|
75
|
-
var
|
|
76
|
-
var
|
|
77
|
-
var _k = useState(false), loading = _k[0], setLoading = _k[1];
|
|
78
|
-
var _l = useState(false), isRounded = _l[0], setIsRounded = _l[1];
|
|
58
|
+
var _b = useState(), applePayRequestData = _b[0], setApplePayRequestData = _b[1];
|
|
59
|
+
var _c = useState(), applePayRequestConfiguration = _c[0], setApplePayRequestConfiguration = _c[1];
|
|
60
|
+
var _d = useState(false), disabled = _d[0], setDisabled = _d[1];
|
|
61
|
+
var _e = useState(false), error = _e[0], setError = _e[1];
|
|
62
|
+
var _f = useState(false), success = _f[0], setSuccess = _f[1];
|
|
63
|
+
var _g = useState(false), loading = _g[0], setLoading = _g[1];
|
|
64
|
+
var _h = useState(false), isRounded = _h[0], setIsRounded = _h[1];
|
|
79
65
|
var mappedProps = __assign(__assign({}, buttonProps), { interface: mappingInterface(buttonProps.interface) });
|
|
80
|
-
var interfaceObj =
|
|
81
|
-
var
|
|
82
|
-
var
|
|
66
|
+
var _j = mappedProps, interfaceObj = _j.interface, merchant = _j.merchant, customer = _j.customer, acceptance = _j.acceptance, scope = _j.scope, debug = _j.debug, onError = _j.onError, onSuccess = _j.onSuccess, onCancel = _j.onCancel, onReady = _j.onReady, metadata = _j.metadata, operator = _j.operator, order = _j.order, onOrderCreated = _j.onOrderCreated, transaction = _j.transaction, post = _j.post, redirect = _j.redirect, integration = _j.integration;
|
|
67
|
+
var _k = metadata || {}, profileData = _k.profileData, headers = _k.headers;
|
|
68
|
+
var isIframeIntegration = integration === IntegrationType.IFRAME;
|
|
69
|
+
var isWebViewIntegration = integration === IntegrationType.WEBVIEW;
|
|
83
70
|
useMerchantApplePay({
|
|
84
71
|
isIframeIntegration: isIframeIntegration,
|
|
85
72
|
onError: onError,
|
|
@@ -97,7 +84,7 @@ export var useApplePay = function (_a) {
|
|
|
97
84
|
setSuccess: setSuccess,
|
|
98
85
|
setLoading: setLoading
|
|
99
86
|
});
|
|
100
|
-
var theme =
|
|
87
|
+
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
88
|
var applePayPaymentMethodOptions = useMemo(function () {
|
|
102
89
|
if (!profileData)
|
|
103
90
|
return null;
|
|
@@ -106,101 +93,71 @@ export var useApplePay = function (_a) {
|
|
|
106
93
|
var merchantValidationRequestData = useMemo(function () {
|
|
107
94
|
if (!profileData)
|
|
108
95
|
return null;
|
|
96
|
+
var merchantIdentifierByIntegration = isWebViewIntegration
|
|
97
|
+
? applePayPaymentMethodOptions === null || applePayPaymentMethodOptions === void 0 ? void 0 : applePayPaymentMethodOptions.identifier
|
|
98
|
+
: merchant.identifier || merchant.id;
|
|
99
|
+
var merchantIdentifier = merchantIdentifierByIntegration || profileData.merchant.id;
|
|
109
100
|
return {
|
|
110
101
|
merchantId: merchant.id || (profileData === null || profileData === void 0 ? void 0 : profileData.merchant.id),
|
|
111
102
|
merchantName: profileData.merchant.name,
|
|
112
103
|
validationUrl: '',
|
|
113
|
-
origin:
|
|
114
|
-
|
|
104
|
+
origin: window.location.hostname,
|
|
105
|
+
merchantIdentifier: merchantIdentifier
|
|
115
106
|
};
|
|
116
107
|
}, [merchant, profileData === null || profileData === void 0 ? void 0 : profileData.merchant, isWebViewIntegration, applePayPaymentMethodOptions === null || applePayPaymentMethodOptions === void 0 ? void 0 : applePayPaymentMethodOptions.identifier]);
|
|
117
|
-
var initialize = function (
|
|
118
|
-
var
|
|
119
|
-
var
|
|
120
|
-
return __generator(this, function (
|
|
121
|
-
switch (
|
|
108
|
+
var initialize = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
109
|
+
var session, _a, id, api_version, contact, applePayPreparedData, err_1;
|
|
110
|
+
var _b, _c, _d;
|
|
111
|
+
return __generator(this, function (_e) {
|
|
112
|
+
switch (_e.label) {
|
|
122
113
|
case 0:
|
|
123
|
-
|
|
124
|
-
_o.label = 1;
|
|
125
|
-
case 1:
|
|
126
|
-
_o.trys.push([1, 7, , 8]);
|
|
114
|
+
_e.trys.push([0, 5, , 6]);
|
|
127
115
|
if (!shallRenderApplePay()) {
|
|
128
116
|
throw new Error('The device/customer is not eligible to use ApplePay');
|
|
129
117
|
}
|
|
130
|
-
if (
|
|
131
|
-
|
|
132
|
-
setAxiosGlobalHeaders(__assign({}, headers_1));
|
|
133
|
-
setProfile(rest);
|
|
134
|
-
applePayPreparedData_1 = prepareApplePayRequest(__assign(__assign({}, rest), { order: order, acceptance: acceptance, customer: customer }));
|
|
135
|
-
setApplePayRequestData(applePayPreparedData_1.applePaySessionRequest);
|
|
136
|
-
setInitialLoading(false);
|
|
137
|
-
return [2];
|
|
118
|
+
if (!profileData) {
|
|
119
|
+
throw new Error('000::Profile data is not available');
|
|
138
120
|
}
|
|
139
|
-
|
|
121
|
+
session = headers === null || headers === void 0 ? void 0 : headers.session;
|
|
122
|
+
setAxiosGlobalHeaders({ session: session });
|
|
123
|
+
if (!(headers && areAllTheObjectStringValuesValid(headers))) return [3, 2];
|
|
140
124
|
return [4, appService.setHttpHeaders(__assign(__assign({}, headers), { authorization: operator.publicKey }))];
|
|
141
|
-
case
|
|
142
|
-
|
|
143
|
-
return [3,
|
|
144
|
-
case
|
|
125
|
+
case 1:
|
|
126
|
+
_e.sent();
|
|
127
|
+
return [3, 4];
|
|
128
|
+
case 2: return [4, appService.setBrowserHeaders({
|
|
145
129
|
locale: interfaceObj === null || interfaceObj === void 0 ? void 0 : interfaceObj.locale,
|
|
146
130
|
domain: window.location.origin,
|
|
147
131
|
pk: operator.publicKey
|
|
148
132
|
})];
|
|
133
|
+
case 3:
|
|
134
|
+
_e.sent();
|
|
135
|
+
_e.label = 4;
|
|
149
136
|
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 }));
|
|
137
|
+
if (debug) {
|
|
138
|
+
_a = profileData.merchant, id = _a.id, api_version = _a.api_version, contact = _a.contact;
|
|
139
|
+
console.log('merchant configuration: ', {
|
|
140
|
+
id: id,
|
|
141
|
+
api_version: api_version,
|
|
142
|
+
contact: contact
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
applePayPreparedData = prepareApplePayRequest(__assign(__assign({}, profileData), { order: order, acceptance: acceptance, customer: customer }));
|
|
188
146
|
setApplePayRequestData(applePayPreparedData.applePaySessionRequest);
|
|
189
|
-
onOrderCreated === null || onOrderCreated === void 0 ? void 0 : onOrderCreated((
|
|
147
|
+
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
148
|
setApplePayRequestConfiguration({
|
|
191
149
|
BASE_URL: MW_BASE_URL,
|
|
192
150
|
headers: getAxiosGlobalHeaders(),
|
|
193
|
-
merchant: __assign(__assign({},
|
|
151
|
+
merchant: __assign(__assign({}, profileData.merchant), { id: merchant.id || ((_d = profileData.merchant) === null || _d === void 0 ? void 0 : _d.id) })
|
|
194
152
|
});
|
|
195
|
-
setInitialLoading(false);
|
|
196
153
|
onReady === null || onReady === void 0 ? void 0 : onReady();
|
|
197
|
-
return [3,
|
|
198
|
-
case
|
|
199
|
-
err_1 =
|
|
154
|
+
return [3, 6];
|
|
155
|
+
case 5:
|
|
156
|
+
err_1 = _e.sent();
|
|
200
157
|
onError === null || onError === void 0 ? void 0 : onError(err_1.errors || err_1);
|
|
201
158
|
console.log('error in initialize', err_1);
|
|
202
|
-
return [3,
|
|
203
|
-
case
|
|
159
|
+
return [3, 6];
|
|
160
|
+
case 6: return [2];
|
|
204
161
|
}
|
|
205
162
|
});
|
|
206
163
|
}); };
|
|
@@ -283,7 +240,7 @@ export var useApplePay = function (_a) {
|
|
|
283
240
|
_b = scope;
|
|
284
241
|
switch (_b) {
|
|
285
242
|
case Scope.APPLE_PAY_TOKEN: return [3, 2];
|
|
286
|
-
case Scope.
|
|
243
|
+
case Scope.TOKEN: return [3, 4];
|
|
287
244
|
case Scope.AUTHORIZE: return [3, 7];
|
|
288
245
|
case Scope.CHARGE: return [3, 7];
|
|
289
246
|
}
|
|
@@ -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'];
|
|
@@ -47,7 +47,8 @@ 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 { Scope } from '@tap-payments/acceptance-sdk';
|
|
51
52
|
var EVENT_NAME = 'TAP_BUTTON::APPLE_PAY_ON_PAYMENT_AUTHORIZED';
|
|
52
53
|
export var useMerchantApplePay = function (_a) {
|
|
53
54
|
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;
|
|
@@ -69,7 +70,7 @@ export var useMerchantApplePay = function (_a) {
|
|
|
69
70
|
_d = scope;
|
|
70
71
|
switch (_d) {
|
|
71
72
|
case Scope.APPLE_PAY_TOKEN: return [3, 2];
|
|
72
|
-
case Scope.
|
|
73
|
+
case Scope.TOKEN: return [3, 3];
|
|
73
74
|
case Scope.AUTHORIZE: return [3, 5];
|
|
74
75
|
case Scope.CHARGE: return [3, 5];
|
|
75
76
|
}
|
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
2
|
export declare const validateSupportedNetworks: (supportedNetworksOptions: Acceptance['supportedSchemes'], merchantSupportedNetworks?: Acceptance['supportedSchemes']) => Acceptance['supportedSchemes'];
|
|
3
|
-
export declare const getApplePayPaymentMethod: (paymentMethods:
|
|
3
|
+
export declare const getApplePayPaymentMethod: (paymentMethods: ProfileData['payment_options']['payment_methods']) => import("@tap-payments/acceptance-sdk").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;
|
|
13
13
|
};
|
|
14
14
|
export declare const shallRenderApplePay: () => boolean;
|
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.88-development",
|
|
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.58",
|
|
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
|
-
};
|