@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.
@@ -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: 'whiteOutline'
9
- };
10
- export var MerchantCapabilities = {
11
- Supports3DS: 'supports3DS',
12
- SupportsCredit: 'supportsCredit',
13
- SupportsDebit: 'supportsDebit'
14
- };
15
- export var SupportedNetworks = {
16
- Amex: 'amex',
17
- Mada: 'mada',
18
- MasterCard: 'masterCard',
19
- Visa: 'visa'
20
- };
21
- export var ApplePayVersion = 5;
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: none;
3
- border: none;
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
- .img-container {
32
- height: 24px;
33
- max-width: 80px;
13
+ .black {
14
+ -apple-pay-button-style: black;
34
15
  }
35
-
36
- .img-container img {
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
- .dark {
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 function renderApplePayButton(config: ApplePayButtonProps, elementId: string): {
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 { createElementAndInject } from '../../utils';
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 _d = useApplePay({
22
- publicKey: publicKey,
23
- merchant: merchant,
24
- transaction: transaction,
25
- billingContact: billingContact,
26
- supportedNetworks: supportedNetworks,
27
- onCancel: onCancel,
28
- onError: onError,
29
- onSuccess: onSuccess,
30
- scope: scope
31
- }), loading = _d.loading, onApplePayButtonClicked = _d.onApplePayButtonClicked, disabled = _d.disabled;
32
- return (_jsx("button", __assign({ className: "button-applepay-tap ".concat(buttonStyle), onClick: onApplePayButtonClicked, disabled: loading || disabled }, { children: _jsx("div", __assign({ className: 'img-container' }, { children: _jsx("img", { loading: 'eager', src: 'https://back-end.b-cdn.net/payment_methods/apple_pay.svg' }) })) })));
33
- });
34
- export function ApplePayButton(props) {
35
- return _jsx(ApplePay, __assign({}, props));
36
- }
37
- export function renderApplePayButton(config, elementId) {
38
- var el = createElementAndInject(elementId);
39
- var root = createRoot(el);
40
- root.render(_jsx(ApplePay, __assign({}, config)));
41
- var unmount = function () { return root.unmount(); };
42
- return { unmount: unmount };
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 };
@@ -1 +1 @@
1
- export * from './useScript';
1
+ export * from './useScript';
@@ -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 {};