@tap-payments/apple-pay-button 0.0.11-test → 0.0.13-test
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/@types/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Scope, ButtonStyle, MerchantCapabilities, SupportedNetworks } from '../constants';
|
|
1
|
+
import { Scope, ButtonStyle, MerchantCapabilities, SupportedNetworks, ButtonType, Locale } from '../constants';
|
|
2
2
|
export interface ApplePayRequestData {
|
|
3
3
|
countryCode: string;
|
|
4
4
|
currencyCode: string;
|
|
@@ -47,6 +47,8 @@ export interface ApplePayButtonProps {
|
|
|
47
47
|
onSuccess?: (data: Record<string, any>) => Promise<void>;
|
|
48
48
|
onClick?: () => void;
|
|
49
49
|
metaData?: ProfileResponse;
|
|
50
|
+
type?: typeof ButtonType[keyof typeof ButtonType];
|
|
51
|
+
locale?: typeof Locale[keyof typeof Locale];
|
|
50
52
|
}
|
|
51
53
|
export interface MerchantResponse {
|
|
52
54
|
id: string;
|
|
@@ -7,6 +7,19 @@ export declare const ButtonStyle: {
|
|
|
7
7
|
readonly White: "white";
|
|
8
8
|
readonly WhiteOutline: "whiteOutline";
|
|
9
9
|
};
|
|
10
|
+
export declare const Locale: {
|
|
11
|
+
readonly EN: "en";
|
|
12
|
+
readonly AR: "ar";
|
|
13
|
+
readonly FR: "fr";
|
|
14
|
+
};
|
|
15
|
+
export declare const ButtonType: {
|
|
16
|
+
readonly BOOK: "book";
|
|
17
|
+
readonly BUY: "buy";
|
|
18
|
+
readonly CHECK_OUT: "check-out";
|
|
19
|
+
readonly PAY: "pay";
|
|
20
|
+
readonly PLAIN: "plain";
|
|
21
|
+
readonly SUBSCRIBE: "subscribe";
|
|
22
|
+
};
|
|
10
23
|
export declare const MerchantCapabilities: {
|
|
11
24
|
readonly Supports3DS: "supports3DS";
|
|
12
25
|
readonly SupportsCredit: "supportsCredit";
|
package/build/constants/index.js
CHANGED
|
@@ -7,6 +7,19 @@ export var ButtonStyle = {
|
|
|
7
7
|
White: 'white',
|
|
8
8
|
WhiteOutline: 'whiteOutline'
|
|
9
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
|
+
};
|
|
10
23
|
export var MerchantCapabilities = {
|
|
11
24
|
Supports3DS: 'supports3DS',
|
|
12
25
|
SupportsCredit: 'supportsCredit',
|
|
@@ -1,51 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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;
|
|
1
|
+
|
|
2
|
+
.apple-pay-button-tap {
|
|
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
|
-
|
|
28
|
-
cursor: default;
|
|
10
|
+
.black {
|
|
11
|
+
-apple-pay-button-style: black;
|
|
29
12
|
}
|
|
30
13
|
|
|
31
|
-
.
|
|
32
|
-
|
|
33
|
-
max-width: 80px;
|
|
14
|
+
.white {
|
|
15
|
+
-apple-pay-button-style: white;
|
|
34
16
|
}
|
|
35
|
-
|
|
36
|
-
.img-container img {
|
|
37
|
-
height: 100%;
|
|
38
|
-
width: 100%;
|
|
39
|
-
transform: scale(1.5);
|
|
40
|
-
filter: invert(0);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
17
|
.whiteOutline {
|
|
18
|
+
-apple-pay-button-style: white;
|
|
44
19
|
border: solid 1px gray;
|
|
45
20
|
}
|
|
46
|
-
|
|
47
|
-
background-color: black;
|
|
48
|
-
}
|
|
49
|
-
.black .img-container img {
|
|
50
|
-
filter: invert(1);
|
|
51
|
-
}
|
|
21
|
+
|
|
@@ -10,15 +10,15 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
-
import React from 'react';
|
|
13
|
+
import * as React from 'react';
|
|
14
14
|
import { createRoot } from 'react-dom/client';
|
|
15
15
|
import { findOrCreateElementAndInject } from '../../utils';
|
|
16
16
|
import { useApplePay } from '../../hooks/useApplePay';
|
|
17
|
-
import { ButtonStyle, Scope } from '../../constants';
|
|
17
|
+
import { ButtonStyle, ButtonType, Locale, Scope } from '../../constants';
|
|
18
18
|
import './ApplePayButton.css';
|
|
19
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, _b = _a.scope, scope = _b === void 0 ? Scope.TapToken : _b, _c = _a.buttonStyle, buttonStyle = _c === void 0 ? ButtonStyle.WhiteOutline : _c,
|
|
21
|
-
var
|
|
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;
|
|
21
|
+
var _f = useApplePay({
|
|
22
22
|
publicKey: publicKey,
|
|
23
23
|
merchant: merchant,
|
|
24
24
|
transaction: transaction,
|
|
@@ -29,11 +29,20 @@ var ApplePay = React.memo(function (_a) {
|
|
|
29
29
|
onCancel: onCancel,
|
|
30
30
|
scope: scope,
|
|
31
31
|
metaData: metaData
|
|
32
|
-
}), loading =
|
|
33
|
-
|
|
32
|
+
}), loading = _f.loading, onApplePayButtonClicked = _f.onApplePayButtonClicked, disabled = _f.disabled;
|
|
33
|
+
var ref = React.useRef();
|
|
34
|
+
React.useEffect(function () {
|
|
35
|
+
var _a;
|
|
36
|
+
if (ref.current) {
|
|
37
|
+
(_a = ref.current) === null || _a === void 0 ? void 0 : _a.click();
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
return (_jsx("div", { className: "apple-pay-button-tap ".concat(buttonStyle), style: {
|
|
41
|
+
'-apple-pay-button-type': type
|
|
42
|
+
}, onClick: function () {
|
|
34
43
|
onApplePayButtonClicked();
|
|
35
44
|
onClick === null || onClick === void 0 ? void 0 : onClick();
|
|
36
|
-
},
|
|
45
|
+
}, lang: locale }));
|
|
37
46
|
});
|
|
38
47
|
export function ApplePayButton(props) {
|
|
39
48
|
return _jsx(ApplePay, __assign({}, props));
|