@tap-payments/apple-pay-button 1.0.0 → 1.0.2

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,16 +1,33 @@
1
- import axios from 'axios';
2
- var MW_BASE_URL = 'https://checkout.payments.tap.company/api';
3
- var httpClient = axios.create({
4
- baseURL: MW_BASE_URL,
5
- headers: {
6
- 'Content-Type': 'application/json',
7
- Accept: 'application/json'
8
- }
9
- });
10
- httpClient.interceptors.request.use(function (config) {
11
- return config;
12
- });
13
- httpClient.interceptors.response.use(function (response) {
14
- return response;
15
- });
16
- export default httpClient;
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 axios from 'axios';
13
+ export var MW_BASE_LIVE_URL = 'https://mw-sdk.tap.company/v2/checkout';
14
+ export var MW_BASE_STAGING_URL = 'https://mw-sdk.staing.tap.company/v2/checkout';
15
+ export var MW_BASE_DEV_URL = 'https://mw-sdk.dev.tap.company/v2/checkout';
16
+ export var MW_BASE_BETA_URL = 'https://mw-sdk.dev.tap.company/v2/checkout';
17
+ export var MW_BASE_SANDBOX_URL = 'https://mw-sdk.sandbox.tap.company/v2/checkout';
18
+ var httpClient = axios.create({
19
+ headers: {
20
+ 'Content-Type': 'application/json',
21
+ Accept: 'application/json'
22
+ }
23
+ });
24
+ httpClient.interceptors.request.use(function (config) {
25
+ return config;
26
+ });
27
+ httpClient.interceptors.response.use(function (response) {
28
+ return response;
29
+ });
30
+ export var setAxiosGlobalHeaders = function (headers) {
31
+ httpClient.defaults.headers.common = __assign(__assign({}, httpClient.defaults.headers.common), headers);
32
+ };
33
+ export default httpClient;
@@ -1,26 +1,51 @@
1
- export declare const Scope: {
2
- readonly AppleToken: "AppleToken";
3
- readonly TapToken: "TapToken";
4
- };
5
- export declare const ButtonStyle: {
6
- readonly Black: "black";
7
- readonly White: "white";
8
- readonly WhiteOutline: "whiteOutline";
9
- };
10
- export declare const MerchantCapabilities: {
11
- readonly Supports3DS: "supports3DS";
12
- readonly SupportsCredit: "supportsCredit";
13
- readonly SupportsDebit: "supportsDebit";
14
- };
15
- export declare const SupportedNetworks: {
16
- readonly Amex: "amex";
17
- readonly Mada: "mada";
18
- readonly MasterCard: "masterCard";
19
- readonly Visa: "visa";
20
- readonly ChinaUnionPay: "chinaUnionPay";
21
- readonly Discover: "discover";
22
- readonly Electron: "electron";
23
- readonly Jcb: "jcb";
24
- readonly Maestro: "maestro";
25
- };
26
- export declare const ApplePayVersion = 5;
1
+ export declare const Scope: {
2
+ readonly AppleToken: "AppleToken";
3
+ readonly TapToken: "TapToken";
4
+ };
5
+ export declare const ButtonStyle: {
6
+ readonly Black: "black";
7
+ readonly White: "white";
8
+ readonly WhiteOutline: "white-outline";
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
+ };
23
+ export declare const MerchantCapabilities: {
24
+ readonly Supports3DS: "supports3DS";
25
+ readonly SupportsCredit: "supportsCredit";
26
+ readonly SupportsDebit: "supportsDebit";
27
+ };
28
+ export declare const SupportedNetworks: {
29
+ readonly Amex: "amex";
30
+ readonly Mada: "mada";
31
+ readonly MasterCard: "masterCard";
32
+ readonly Visa: "visa";
33
+ readonly ChinaUnionPay: "chinaUnionPay";
34
+ readonly Discover: "discover";
35
+ readonly Electron: "electron";
36
+ readonly Jcb: "jcb";
37
+ readonly Maestro: "maestro";
38
+ };
39
+ export declare const ApplePayVersion = 5;
40
+ export declare const Environment: {
41
+ readonly Production: "production";
42
+ readonly Sandbox: "sandbox";
43
+ readonly Beta: "beta";
44
+ readonly Development: "development";
45
+ readonly Staging: "staging";
46
+ };
47
+ export declare const RSA_DEV_MW_PUBLIC_KEY = "-----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC8AX++RtxPZFtns4XzXFlDIxPBh0umN4qRXZaKDIlb6a3MknaB7psJWmf2l+e4Cfh9b5tey/+rZqpQ065eXTZfGCAuBLt+fYLQBhLfjRpk8S6hlIzc1Kdjg65uqzMwcTd0p7I4KLwHk1I0oXzuEu53fU1LSZhWp4Mnd6wjVgXAsQIDAQAB\n-----END PUBLIC KEY-----";
48
+ export declare const RSA_SANDBOX_MW_PUBLIC_KEY = "";
49
+ export declare const RSA_PRODUCTION_MW_PUBLIC_KEY = "";
50
+ export declare const RSA_BETA_MW_PUBLIC_KEY = "-----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC9hSRms7Ir1HmzdZxGXFYgmpi3\nez7VBFje0f8wwrxYS9oVoBtN4iAt0DOs3DbeuqtueI31wtpFVUMGg8W7R0SbtkZd\nGzszQNqt/wyqxpDC9q+97XdXwkWQFA72s76ud7eMXQlsWKsvgwhY+Ywzt0KlpNC3\nHj+N6UWFOYK98Xi+sQIDAQAB\n-----END PUBLIC KEY-----";
51
+ export declare const RSA_STAGING_MW_PUBLIC_KEY = "-----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCi9W5jyTvA4Iwv3V5sfNQ7VdSz\n7WqwBbnWFbIUL/GjaaE93mvDv4zbgRSznHaHQPH6pxrMhMh0tV58njkvjHvQ/tvg\npwM8SemNPKEEAPl69tnMvCrJRPh2dWL3OHY8yCW4c38Hyx4fy56Zd5cdoVWfCReu\njCsvASLGz+cfRrj2swIDAQAB\n-----END PUBLIC KEY-----";
@@ -1,26 +1,51 @@
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
- ChinaUnionPay: 'chinaUnionPay',
21
- Discover: 'discover',
22
- Electron: 'electron',
23
- Jcb: 'jcb',
24
- Maestro: 'maestro'
25
- };
26
- 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;
40
+ export var Environment = {
41
+ Production: 'production',
42
+ Sandbox: 'sandbox',
43
+ Beta: 'beta',
44
+ Development: 'development',
45
+ Staging: 'staging'
46
+ };
47
+ export var RSA_DEV_MW_PUBLIC_KEY = "-----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC8AX++RtxPZFtns4XzXFlDIxPBh0umN4qRXZaKDIlb6a3MknaB7psJWmf2l+e4Cfh9b5tey/+rZqpQ065eXTZfGCAuBLt+fYLQBhLfjRpk8S6hlIzc1Kdjg65uqzMwcTd0p7I4KLwHk1I0oXzuEu53fU1LSZhWp4Mnd6wjVgXAsQIDAQAB\n-----END PUBLIC KEY-----";
48
+ export var RSA_SANDBOX_MW_PUBLIC_KEY = "";
49
+ export var RSA_PRODUCTION_MW_PUBLIC_KEY = "";
50
+ export var RSA_BETA_MW_PUBLIC_KEY = "-----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC9hSRms7Ir1HmzdZxGXFYgmpi3\nez7VBFje0f8wwrxYS9oVoBtN4iAt0DOs3DbeuqtueI31wtpFVUMGg8W7R0SbtkZd\nGzszQNqt/wyqxpDC9q+97XdXwkWQFA72s76ud7eMXQlsWKsvgwhY+Ywzt0KlpNC3\nHj+N6UWFOYK98Xi+sQIDAQAB\n-----END PUBLIC KEY-----";
51
+ export var RSA_STAGING_MW_PUBLIC_KEY = "-----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCi9W5jyTvA4Iwv3V5sfNQ7VdSz\n7WqwBbnWFbIUL/GjaaE93mvDv4zbgRSznHaHQPH6pxrMhMh0tV58njkvjHvQ/tvg\npwM8SemNPKEEAPl69tnMvCrJRPh2dWL3OHY8yCW4c38Hyx4fy56Zd5cdoVWfCReu\njCsvASLGz+cfRrj2swIDAQAB\n-----END PUBLIC KEY-----";
@@ -1,51 +1,21 @@
1
- .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;
24
- width: 100%;
25
- }
26
-
27
- .button-applepay-tap:disabled {
28
- cursor: default;
29
- }
30
-
31
- .img-container {
32
- height: 24px;
33
- max-width: 80px;
34
- }
35
-
36
- .img-container img {
37
- height: 100%;
38
- width: 100%;
39
- transform: scale(1.5);
40
- filter: invert(0);
41
- }
42
-
43
- .whiteOutline {
44
- border: solid 1px gray;
45
- }
46
- .dark {
47
- background-color: black;
48
- }
49
- .dark .img-container img {
50
- filter: invert(1);
51
- }
1
+ .button-applepay-tap {
2
+ -webkit-appearance: -apple-pay-button;
3
+ display: block;
4
+ width: 100%;
5
+ height: 48px;
6
+ min-height: 30px;
7
+ cursor: pointer;
8
+ }
9
+ .button-applepay-tap:disabled {
10
+ cursor: default;
11
+ }
12
+ .black {
13
+ -apple-pay-button-style: black;
14
+ }
15
+ .white {
16
+ -apple-pay-button-style: white;
17
+ }
18
+ .whiteOutline {
19
+ -apple-pay-button-style: white;
20
+ border: solid 1px gray;
21
+ }
@@ -1,6 +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 const renderApplePayButton: (props: ApplePayButtonProps, elementId: string) => any;
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,51 +1,80 @@
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 { findOrCreateElementAndInject } 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
- var tapConnectInstance = null;
38
- export var renderApplePayButton = function (props, elementId) {
39
- if (tapConnectInstance) {
40
- return tapConnectInstance;
41
- }
42
- var el = findOrCreateElementAndInject(elementId);
43
- var root = createRoot(el);
44
- root.render(_jsx(ApplePayButton, __assign({}, props)));
45
- var unmount = function () {
46
- root.unmount();
47
- tapConnectInstance = null;
48
- };
49
- tapConnectInstance = { unmount: unmount };
50
- return tapConnectInstance;
51
- };
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, environment = _a.environment, onReady = _a.onReady;
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
+ environment: environment,
35
+ locale: locale,
36
+ onReady: onReady
37
+ }), loading = _f.loading, onApplePayButtonClicked = _f.onApplePayButtonClicked, disabled = _f.disabled;
38
+ React.useEffect(function () {
39
+ if (debug) {
40
+ console.log('ApplePayButtonProps', {
41
+ publicKey: publicKey,
42
+ merchant: merchant,
43
+ transaction: transaction,
44
+ billingContact: billingContact,
45
+ supportedNetworks: supportedNetworks,
46
+ metaData: metaData,
47
+ scope: scope,
48
+ buttonStyle: buttonStyle,
49
+ type: type,
50
+ locale: locale,
51
+ debug: debug
52
+ });
53
+ }
54
+ }, []);
55
+ return (_jsx("button", { className: 'button-applepay-tap', style: {
56
+ '-apple-pay-button-type': type,
57
+ '-apple-pay-button-style': buttonStyle
58
+ }, onClick: function () {
59
+ onApplePayButtonClicked();
60
+ onClick === null || onClick === void 0 ? void 0 : onClick();
61
+ }, lang: locale, disabled: loading || disabled }));
62
+ });
63
+ export function ApplePayButton(props) {
64
+ return _jsx(ApplePay, __assign({}, props));
65
+ }
66
+ var tapConnectInstance = null;
67
+ export var renderApplePayButton = function (props, elementId) {
68
+ if (tapConnectInstance) {
69
+ return tapConnectInstance;
70
+ }
71
+ var el = findOrCreateElementAndInject(elementId);
72
+ var root = createRoot(el);
73
+ root.render(_jsx(ApplePayButton, __assign({}, props)));
74
+ var unmount = function () {
75
+ root.unmount();
76
+ tapConnectInstance = null;
77
+ };
78
+ tapConnectInstance = { unmount: unmount };
79
+ return tapConnectInstance;
80
+ };
@@ -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, environment, locale, onReady }: UseApplePayProps) => UseApplePayReturnProps;
9
+ export {};