@tap-payments/apple-pay-button 0.0.0-test → 0.0.1
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/LICENSE +21 -21
- package/README.md +194 -120
- package/build/@types/index.d.ts +79 -74
- package/build/@types/index.js +1 -1
- package/build/api/app.service.d.ts +11 -11
- package/build/api/app.service.js +217 -217
- package/build/api/base.d.ts +9 -9
- package/build/api/base.js +45 -45
- package/build/api/httpClient.d.ts +2 -2
- package/build/api/httpClient.js +16 -16
- package/build/constants/index.d.ts +39 -21
- package/build/constants/index.js +39 -21
- package/build/features/ApplePayButton/ApplePayButton.css +12 -40
- package/build/features/ApplePayButton/ApplePayButton.d.ts +6 -8
- package/build/features/ApplePayButton/ApplePayButton.js +77 -43
- package/build/features/ApplePayButton/index.d.ts +3 -3
- package/build/features/ApplePayButton/index.js +2 -2
- package/build/hooks/index.d.ts +1 -1
- package/build/hooks/index.js +1 -1
- package/build/hooks/useApplePay.d.ts +9 -9
- package/build/hooks/useApplePay.js +223 -202
- package/build/hooks/useScript.d.ts +1 -1
- package/build/hooks/useScript.js +39 -39
- package/build/index.d.ts +4 -4
- package/build/index.js +9 -9
- package/build/utils/config.d.ts +9 -8
- package/build/utils/config.js +54 -54
- package/build/utils/html.d.ts +1 -3
- package/build/utils/html.js +9 -20
- package/build/utils/index.d.ts +1 -1
- package/build/utils/index.js +1 -1
- package/package.json +102 -102
package/build/constants/index.js
CHANGED
|
@@ -1,21 +1,39 @@
|
|
|
1
|
-
export var Scope = {
|
|
2
|
-
AppleToken: 'AppleToken',
|
|
3
|
-
TapToken: 'TapToken'
|
|
4
|
-
};
|
|
5
|
-
export var ButtonStyle = {
|
|
6
|
-
Black: 'black',
|
|
7
|
-
White: 'white',
|
|
8
|
-
WhiteOutline: '
|
|
9
|
-
};
|
|
10
|
-
export var
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
};
|
|
15
|
-
export var
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
export var Scope = {
|
|
2
|
+
AppleToken: 'AppleToken',
|
|
3
|
+
TapToken: 'TapToken'
|
|
4
|
+
};
|
|
5
|
+
export var ButtonStyle = {
|
|
6
|
+
Black: 'black',
|
|
7
|
+
White: 'white',
|
|
8
|
+
WhiteOutline: 'white-outline'
|
|
9
|
+
};
|
|
10
|
+
export var Locale = {
|
|
11
|
+
EN: 'en',
|
|
12
|
+
AR: 'ar',
|
|
13
|
+
FR: 'fr'
|
|
14
|
+
};
|
|
15
|
+
export var ButtonType = {
|
|
16
|
+
BOOK: 'book',
|
|
17
|
+
BUY: 'buy',
|
|
18
|
+
CHECK_OUT: 'check-out',
|
|
19
|
+
PAY: 'pay',
|
|
20
|
+
PLAIN: 'plain',
|
|
21
|
+
SUBSCRIBE: 'subscribe'
|
|
22
|
+
};
|
|
23
|
+
export var MerchantCapabilities = {
|
|
24
|
+
Supports3DS: 'supports3DS',
|
|
25
|
+
SupportsCredit: 'supportsCredit',
|
|
26
|
+
SupportsDebit: 'supportsDebit'
|
|
27
|
+
};
|
|
28
|
+
export var SupportedNetworks = {
|
|
29
|
+
Amex: 'amex',
|
|
30
|
+
Mada: 'mada',
|
|
31
|
+
MasterCard: 'masterCard',
|
|
32
|
+
Visa: 'visa',
|
|
33
|
+
ChinaUnionPay: 'chinaUnionPay',
|
|
34
|
+
Discover: 'discover',
|
|
35
|
+
Electron: 'electron',
|
|
36
|
+
Jcb: 'jcb',
|
|
37
|
+
Maestro: 'maestro'
|
|
38
|
+
};
|
|
39
|
+
export var ApplePayVersion = 5;
|
|
@@ -1,51 +1,23 @@
|
|
|
1
|
+
|
|
1
2
|
.button-applepay-tap {
|
|
2
|
-
appearance:
|
|
3
|
-
|
|
4
|
-
cursor: pointer;
|
|
5
|
-
-webkit-user-select: none;
|
|
6
|
-
user-select: none;
|
|
7
|
-
display: flex;
|
|
8
|
-
position: relative;
|
|
9
|
-
-webkit-box-pack: center;
|
|
10
|
-
-ms-flex-pack: center;
|
|
11
|
-
-webkit-justify-content: center;
|
|
12
|
-
justify-content: center;
|
|
13
|
-
-webkit-align-items: center;
|
|
14
|
-
-webkit-box-align: center;
|
|
15
|
-
-ms-flex-align: center;
|
|
16
|
-
align-items: center;
|
|
17
|
-
-webkit-margin-end: 8px;
|
|
18
|
-
margin-inline-end: 8px;
|
|
19
|
-
min-width: 96px;
|
|
20
|
-
max-width: 300px;
|
|
21
|
-
min-height: 40px;
|
|
22
|
-
border-radius: 9px;
|
|
23
|
-
background-color: white;
|
|
3
|
+
-webkit-appearance: -apple-pay-button;
|
|
4
|
+
display: block;
|
|
24
5
|
width: 100%;
|
|
6
|
+
height: 48px;
|
|
7
|
+
min-height: 30px;
|
|
8
|
+
cursor: pointer;
|
|
25
9
|
}
|
|
26
|
-
|
|
27
10
|
.button-applepay-tap:disabled {
|
|
28
11
|
cursor: default;
|
|
29
12
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
height: 24px;
|
|
33
|
-
max-width: 80px;
|
|
13
|
+
.black {
|
|
14
|
+
-apple-pay-button-style: black;
|
|
34
15
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
height: 100%;
|
|
38
|
-
width: 100%;
|
|
39
|
-
transform: scale(1.5);
|
|
40
|
-
filter: invert(0);
|
|
16
|
+
.white {
|
|
17
|
+
-apple-pay-button-style: white;
|
|
41
18
|
}
|
|
42
|
-
|
|
43
19
|
.whiteOutline {
|
|
20
|
+
-apple-pay-button-style: white;
|
|
44
21
|
border: solid 1px gray;
|
|
45
22
|
}
|
|
46
|
-
|
|
47
|
-
background-color: black;
|
|
48
|
-
}
|
|
49
|
-
.dark .img-container img {
|
|
50
|
-
filter: invert(1);
|
|
51
|
-
}
|
|
23
|
+
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { ApplePayButtonProps } from '../../@types';
|
|
3
|
-
import './ApplePayButton.css';
|
|
4
|
-
export type { ApplePayButtonProps };
|
|
5
|
-
export declare function ApplePayButton(props: ApplePayButtonProps): JSX.Element;
|
|
6
|
-
export declare
|
|
7
|
-
unmount: () => void;
|
|
8
|
-
};
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ApplePayButtonProps } from '../../@types';
|
|
3
|
+
import './ApplePayButton.css';
|
|
4
|
+
export type { ApplePayButtonProps };
|
|
5
|
+
export declare function ApplePayButton(props: ApplePayButtonProps): JSX.Element;
|
|
6
|
+
export declare const renderApplePayButton: (props: ApplePayButtonProps, elementId: string) => any;
|
|
@@ -1,43 +1,77 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
-
import React from 'react';
|
|
14
|
-
import { createRoot } from 'react-dom/client';
|
|
15
|
-
import {
|
|
16
|
-
import { useApplePay } from '../../hooks/useApplePay';
|
|
17
|
-
import { ButtonStyle, Scope } from '../../constants';
|
|
18
|
-
import './ApplePayButton.css';
|
|
19
|
-
var ApplePay = React.memo(function (_a) {
|
|
20
|
-
var publicKey = _a.publicKey, merchant = _a.merchant, transaction = _a.transaction, billingContact = _a.billingContact, supportedNetworks = _a.supportedNetworks, onCancel = _a.onCancel, onError = _a.onError, onSuccess = _a.onSuccess, _b = _a.scope, scope = _b === void 0 ? Scope.TapToken : _b, _c = _a.buttonStyle, buttonStyle = _c === void 0 ? ButtonStyle.WhiteOutline : _c;
|
|
21
|
-
var
|
|
22
|
-
publicKey: publicKey,
|
|
23
|
-
merchant: merchant,
|
|
24
|
-
transaction: transaction,
|
|
25
|
-
billingContact: billingContact,
|
|
26
|
-
supportedNetworks: supportedNetworks,
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
scope: scope
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import * as React from 'react';
|
|
14
|
+
import { createRoot } from 'react-dom/client';
|
|
15
|
+
import { findOrCreateElementAndInject } from '../../utils';
|
|
16
|
+
import { useApplePay } from '../../hooks/useApplePay';
|
|
17
|
+
import { ButtonStyle, ButtonType, Locale, Scope } from '../../constants';
|
|
18
|
+
import './ApplePayButton.css';
|
|
19
|
+
var ApplePay = React.memo(function (_a) {
|
|
20
|
+
var publicKey = _a.publicKey, merchant = _a.merchant, transaction = _a.transaction, billingContact = _a.billingContact, supportedNetworks = _a.supportedNetworks, onCancel = _a.onCancel, onError = _a.onError, onSuccess = _a.onSuccess, onClick = _a.onClick, metaData = _a.metaData, _b = _a.scope, scope = _b === void 0 ? Scope.TapToken : _b, _c = _a.buttonStyle, buttonStyle = _c === void 0 ? ButtonStyle.WhiteOutline : _c, _d = _a.type, type = _d === void 0 ? ButtonType.PLAIN : _d, _e = _a.locale, locale = _e === void 0 ? Locale.EN : _e, debug = _a.debug, merchantIdentifier = _a.merchantIdentifier;
|
|
21
|
+
var _f = useApplePay({
|
|
22
|
+
publicKey: publicKey,
|
|
23
|
+
merchant: merchant,
|
|
24
|
+
transaction: transaction,
|
|
25
|
+
billingContact: billingContact,
|
|
26
|
+
supportedNetworks: supportedNetworks,
|
|
27
|
+
onError: onError,
|
|
28
|
+
onSuccess: onSuccess,
|
|
29
|
+
onCancel: onCancel,
|
|
30
|
+
scope: scope,
|
|
31
|
+
metaData: metaData,
|
|
32
|
+
debug: debug,
|
|
33
|
+
merchantIdentifier: merchantIdentifier
|
|
34
|
+
}), loading = _f.loading, onApplePayButtonClicked = _f.onApplePayButtonClicked, disabled = _f.disabled;
|
|
35
|
+
React.useEffect(function () {
|
|
36
|
+
if (debug) {
|
|
37
|
+
console.log('ApplePayButtonProps', {
|
|
38
|
+
publicKey: publicKey,
|
|
39
|
+
merchant: merchant,
|
|
40
|
+
transaction: transaction,
|
|
41
|
+
billingContact: billingContact,
|
|
42
|
+
supportedNetworks: supportedNetworks,
|
|
43
|
+
metaData: metaData,
|
|
44
|
+
scope: scope,
|
|
45
|
+
buttonStyle: buttonStyle,
|
|
46
|
+
type: type,
|
|
47
|
+
locale: locale,
|
|
48
|
+
debug: debug
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}, []);
|
|
52
|
+
return (_jsx("button", { className: 'button-applepay-tap', style: {
|
|
53
|
+
'-apple-pay-button-type': type,
|
|
54
|
+
'-apple-pay-button-style': buttonStyle
|
|
55
|
+
}, onClick: function () {
|
|
56
|
+
onApplePayButtonClicked();
|
|
57
|
+
onClick === null || onClick === void 0 ? void 0 : onClick();
|
|
58
|
+
}, lang: locale, disabled: loading || disabled }));
|
|
59
|
+
});
|
|
60
|
+
export function ApplePayButton(props) {
|
|
61
|
+
return _jsx(ApplePay, __assign({}, props));
|
|
62
|
+
}
|
|
63
|
+
var tapConnectInstance = null;
|
|
64
|
+
export var renderApplePayButton = function (props, elementId) {
|
|
65
|
+
if (tapConnectInstance) {
|
|
66
|
+
return tapConnectInstance;
|
|
67
|
+
}
|
|
68
|
+
var el = findOrCreateElementAndInject(elementId);
|
|
69
|
+
var root = createRoot(el);
|
|
70
|
+
root.render(_jsx(ApplePayButton, __assign({}, props)));
|
|
71
|
+
var unmount = function () {
|
|
72
|
+
root.unmount();
|
|
73
|
+
tapConnectInstance = null;
|
|
74
|
+
};
|
|
75
|
+
tapConnectInstance = { unmount: unmount };
|
|
76
|
+
return tapConnectInstance;
|
|
77
|
+
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { ApplePayButtonProps, ApplePayButton, renderApplePayButton } from './ApplePayButton';
|
|
2
|
-
export { ApplePayButton, renderApplePayButton };
|
|
3
|
-
export type { ApplePayButtonProps };
|
|
1
|
+
import { ApplePayButtonProps, ApplePayButton, renderApplePayButton } from './ApplePayButton';
|
|
2
|
+
export { ApplePayButton, renderApplePayButton };
|
|
3
|
+
export type { ApplePayButtonProps };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { ApplePayButton, renderApplePayButton } from './ApplePayButton';
|
|
2
|
-
export { ApplePayButton, renderApplePayButton };
|
|
1
|
+
import { ApplePayButton, renderApplePayButton } from './ApplePayButton';
|
|
2
|
+
export { ApplePayButton, renderApplePayButton };
|
package/build/hooks/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './useScript';
|
|
1
|
+
export * from './useScript';
|
package/build/hooks/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './useScript';
|
|
1
|
+
export * from './useScript';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { ApplePayButtonProps } from '../@types';
|
|
2
|
-
declare type UseApplePayProps = Omit<ApplePayButtonProps, 'buttonStyle'>;
|
|
3
|
-
interface UseApplePayReturnProps {
|
|
4
|
-
loading: boolean;
|
|
5
|
-
onApplePayButtonClicked: () => Promise<void>;
|
|
6
|
-
disabled: boolean;
|
|
7
|
-
}
|
|
8
|
-
export declare const useApplePay: ({ publicKey, merchant, transaction, billingContact, onCancel, onError, onSuccess, scope, supportedNetworks }: UseApplePayProps) => UseApplePayReturnProps;
|
|
9
|
-
export {};
|
|
1
|
+
import { ApplePayButtonProps } from '../@types';
|
|
2
|
+
declare type UseApplePayProps = Omit<ApplePayButtonProps, 'buttonStyle'>;
|
|
3
|
+
interface UseApplePayReturnProps {
|
|
4
|
+
loading: boolean;
|
|
5
|
+
onApplePayButtonClicked: () => Promise<void>;
|
|
6
|
+
disabled: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare const useApplePay: ({ publicKey, merchant, transaction, billingContact, onCancel, onError, onSuccess, scope, supportedNetworks, metaData, debug, merchantIdentifier }: UseApplePayProps) => UseApplePayReturnProps;
|
|
9
|
+
export {};
|