@tap-payments/apple-pay-button 0.0.69-development → 1.0.0-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.
Files changed (51) hide show
  1. package/README.md +30 -30
  2. package/build/@types/ApplePaySession.d.ts +67 -0
  3. package/build/@types/index.d.ts +118 -6
  4. package/build/@types/index.js +1 -6
  5. package/build/api/app.service.d.ts +23 -0
  6. package/build/{api.js → api/app.service.js} +91 -82
  7. package/build/api/base.d.ts +9 -0
  8. package/build/api/base.js +45 -0
  9. package/build/api/httpClient.d.ts +8 -0
  10. package/build/api/httpClient.js +33 -0
  11. package/build/constants/index.d.ts +58 -2
  12. package/build/constants/index.js +58 -2
  13. package/build/features/ApplePayButton/ApplePayButton.css +21 -0
  14. package/build/features/ApplePayButton/ApplePayButton.d.ts +5 -3
  15. package/build/features/ApplePayButton/ApplePayButton.js +25 -9
  16. package/build/features/ApplePayButton/index.d.ts +3 -3
  17. package/build/features/ApplePayButton/index.js +2 -2
  18. package/build/hooks/index.d.ts +1 -1
  19. package/build/hooks/index.js +1 -1
  20. package/build/hooks/useApplePay.d.ts +7 -86
  21. package/build/hooks/useApplePay.js +178 -262
  22. package/build/hooks/useGetEvents.d.ts +4 -0
  23. package/build/hooks/useGetEvents.js +15 -0
  24. package/build/hooks/useScript.d.ts +1 -0
  25. package/build/hooks/useScript.js +39 -0
  26. package/build/index.d.ts +4 -4
  27. package/build/index.js +7 -5
  28. package/build/utils/config.d.ts +9 -7
  29. package/build/utils/config.js +52 -41
  30. package/build/utils/defaultValues.d.ts +32 -2
  31. package/build/utils/defaultValues.js +31 -10
  32. package/build/utils/index.d.ts +0 -3
  33. package/build/utils/index.js +0 -3
  34. package/package.json +11 -16
  35. package/build/@types/ApplePayButtonProps.d.ts +0 -129
  36. package/build/@types/charge.d.ts +0 -57
  37. package/build/@types/charge.js +0 -1
  38. package/build/@types/checkoutProfile.d.ts +0 -194
  39. package/build/@types/checkoutProfile.js +0 -1
  40. package/build/@types/enums.d.ts +0 -65
  41. package/build/@types/enums.js +0 -76
  42. package/build/@types/tapLocalisation.d.ts +0 -193
  43. package/build/@types/tapLocalisation.js +0 -1
  44. package/build/@types/tapTheme.d.ts +0 -842
  45. package/build/@types/tapTheme.js +0 -1
  46. package/build/api.d.ts +0 -34
  47. package/build/hooks/useMerchantApplePay.d.ts +0 -20
  48. package/build/hooks/useMerchantApplePay.js +0 -176
  49. package/build/utils/theme.d.ts +0 -12
  50. package/build/utils/theme.js +0 -61
  51. /package/build/@types/{ApplePayButtonProps.js → ApplePaySession.js} +0 -0
@@ -1,3 +1,59 @@
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 ThemeMode: {
24
+ readonly DARK: "dark";
25
+ readonly LIGHT: "light";
26
+ };
27
+ export declare const Edges: {
28
+ readonly STRAIGHT: "straight";
29
+ readonly CURVED: "curved";
30
+ };
31
+ export declare const MerchantCapabilities: {
32
+ readonly Supports3DS: "supports3DS";
33
+ readonly SupportsCredit: "supportsCredit";
34
+ readonly SupportsDebit: "supportsDebit";
35
+ };
36
+ export declare const SupportedNetworks: {
37
+ readonly Amex: "amex";
38
+ readonly Mada: "mada";
39
+ readonly MasterCard: "masterCard";
40
+ readonly Visa: "visa";
41
+ readonly ChinaUnionPay: "chinaUnionPay";
42
+ readonly Discover: "discover";
43
+ readonly Electron: "electron";
44
+ readonly Jcb: "jcb";
45
+ readonly Maestro: "maestro";
46
+ };
1
47
  export declare const ApplePayVersion = 5;
2
- export declare const RSA_MW_PUBLIC_KEY = "-----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC8AX++RtxPZFtns4XzXFlDIxPBh0umN4qRXZaKDIlb6a3MknaB7psJWmf2l+e4Cfh9b5tey/+rZqpQ065eXTZfGCAuBLt+fYLQBhLfjRpk8S6hlIzc1Kdjg65uqzMwcTd0p7I4KLwHk1I0oXzuEu53fU1LSZhWp4Mnd6wjVgXAsQIDAQAB\n-----END PUBLIC KEY-----";
3
- export declare const MW_BASE_URL = "https://mw-sdk.dev.tap.company/v2/checkout";
48
+ export declare const Environment: {
49
+ readonly Production: "production";
50
+ readonly Sandbox: "sandbox";
51
+ readonly Beta: "beta";
52
+ readonly Development: "development";
53
+ readonly Staging: "staging";
54
+ };
55
+ export declare const RSA_DEV_MW_PUBLIC_KEY = "-----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC8AX++RtxPZFtns4XzXFlDIxPBh0umN4qRXZaKDIlb6a3MknaB7psJWmf2l+e4Cfh9b5tey/+rZqpQ065eXTZfGCAuBLt+fYLQBhLfjRpk8S6hlIzc1Kdjg65uqzMwcTd0p7I4KLwHk1I0oXzuEu53fU1LSZhWp4Mnd6wjVgXAsQIDAQAB\n-----END PUBLIC KEY-----";
56
+ export declare const RSA_SANDBOX_MW_PUBLIC_KEY = "";
57
+ export declare const RSA_STAGING_MW_PUBLIC_KEY = "-----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCi9W5jyTvA4Iwv3V5sfNQ7VdSz\n7WqwBbnWFbIUL/GjaaE93mvDv4zbgRSznHaHQPH6pxrMhMh0tV58njkvjHvQ/tvg\npwM8SemNPKEEAPl69tnMvCrJRPh2dWL3OHY8yCW4c38Hyx4fy56Zd5cdoVWfCReu\njCsvASLGz+cfRrj2swIDAQAB\n-----END PUBLIC KEY-----";
58
+ export declare const RSA_BETA_MW_PUBLIC_KEY = "-----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC9hSRms7Ir1HmzdZxGXFYgmpi3\nez7VBFje0f8wwrxYS9oVoBtN4iAt0DOs3DbeuqtueI31wtpFVUMGg8W7R0SbtkZd\nGzszQNqt/wyqxpDC9q+97XdXwkWQFA72s76ud7eMXQlsWKsvgwhY+Ywzt0KlpNC3\nHj+N6UWFOYK98Xi+sQIDAQAB\n-----END PUBLIC KEY-----";
59
+ export declare const RSA_PRODUCTION_MW_PUBLIC_KEY = "-----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC9hSRms7Ir1HmzdZxGXFYgmpi3\nez7VBFje0f8wwrxYS9oVoBtN4iAt0DOs3DbeuqtueI31wtpFVUMGg8W7R0SbtkZd\nGzszQNqt/wyqxpDC9q+97XdXwkWQFA72s76ud7eMXQlsWKsvgwhY+Ywzt0KlpNC3\nHj+N6UWFOYK98Xi+sQIDAQAB\n-----END PUBLIC KEY-----";
@@ -1,3 +1,59 @@
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 ThemeMode = {
24
+ DARK: 'dark',
25
+ LIGHT: 'light'
26
+ };
27
+ export var Edges = {
28
+ STRAIGHT: 'straight',
29
+ CURVED: 'curved'
30
+ };
31
+ export var MerchantCapabilities = {
32
+ Supports3DS: 'supports3DS',
33
+ SupportsCredit: 'supportsCredit',
34
+ SupportsDebit: 'supportsDebit'
35
+ };
36
+ export var SupportedNetworks = {
37
+ Amex: 'amex',
38
+ Mada: 'mada',
39
+ MasterCard: 'masterCard',
40
+ Visa: 'visa',
41
+ ChinaUnionPay: 'chinaUnionPay',
42
+ Discover: 'discover',
43
+ Electron: 'electron',
44
+ Jcb: 'jcb',
45
+ Maestro: 'maestro'
46
+ };
1
47
  export var ApplePayVersion = 5;
2
- export var RSA_MW_PUBLIC_KEY = "-----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC8AX++RtxPZFtns4XzXFlDIxPBh0umN4qRXZaKDIlb6a3MknaB7psJWmf2l+e4Cfh9b5tey/+rZqpQ065eXTZfGCAuBLt+fYLQBhLfjRpk8S6hlIzc1Kdjg65uqzMwcTd0p7I4KLwHk1I0oXzuEu53fU1LSZhWp4Mnd6wjVgXAsQIDAQAB\n-----END PUBLIC KEY-----";
3
- export var MW_BASE_URL = 'https://mw-sdk.dev.tap.company/v2/checkout';
48
+ export var Environment = {
49
+ Production: 'production',
50
+ Sandbox: 'sandbox',
51
+ Beta: 'beta',
52
+ Development: 'development',
53
+ Staging: 'staging'
54
+ };
55
+ export var RSA_DEV_MW_PUBLIC_KEY = "-----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC8AX++RtxPZFtns4XzXFlDIxPBh0umN4qRXZaKDIlb6a3MknaB7psJWmf2l+e4Cfh9b5tey/+rZqpQ065eXTZfGCAuBLt+fYLQBhLfjRpk8S6hlIzc1Kdjg65uqzMwcTd0p7I4KLwHk1I0oXzuEu53fU1LSZhWp4Mnd6wjVgXAsQIDAQAB\n-----END PUBLIC KEY-----";
56
+ export var RSA_SANDBOX_MW_PUBLIC_KEY = "";
57
+ export var RSA_STAGING_MW_PUBLIC_KEY = "-----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCi9W5jyTvA4Iwv3V5sfNQ7VdSz\n7WqwBbnWFbIUL/GjaaE93mvDv4zbgRSznHaHQPH6pxrMhMh0tV58njkvjHvQ/tvg\npwM8SemNPKEEAPl69tnMvCrJRPh2dWL3OHY8yCW4c38Hyx4fy56Zd5cdoVWfCReu\njCsvASLGz+cfRrj2swIDAQAB\n-----END PUBLIC KEY-----";
58
+ export var RSA_BETA_MW_PUBLIC_KEY = "-----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC9hSRms7Ir1HmzdZxGXFYgmpi3\nez7VBFje0f8wwrxYS9oVoBtN4iAt0DOs3DbeuqtueI31wtpFVUMGg8W7R0SbtkZd\nGzszQNqt/wyqxpDC9q+97XdXwkWQFA72s76ud7eMXQlsWKsvgwhY+Ywzt0KlpNC3\nHj+N6UWFOYK98Xi+sQIDAQAB\n-----END PUBLIC KEY-----";
59
+ export var RSA_PRODUCTION_MW_PUBLIC_KEY = "-----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC9hSRms7Ir1HmzdZxGXFYgmpi3\nez7VBFje0f8wwrxYS9oVoBtN4iAt0DOs3DbeuqtueI31wtpFVUMGg8W7R0SbtkZd\nGzszQNqt/wyqxpDC9q+97XdXwkWQFA72s76ud7eMXQlsWKsvgwhY+Ywzt0KlpNC3\nHj+N6UWFOYK98Xi+sQIDAQAB\n-----END PUBLIC KEY-----";
@@ -0,0 +1,21 @@
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,5 +1,7 @@
1
1
  /// <reference types="react" />
2
- import { ApplePayButtonProps, ApplePayRequestData } from '../../@types';
3
- export type { ApplePayButtonProps, ApplePayRequestData };
2
+ import { ApplePayButtonProps } from '../../@types';
3
+ import './ApplePayButton.css';
4
+ export type { ApplePayButtonProps };
4
5
  export declare function ApplePayButton(props: ApplePayButtonProps): JSX.Element;
5
- export declare const renderApplePayButton: (props: ApplePayButtonProps, elementId: string) => any;
6
+ export declare function abortApplePaySession(): void;
7
+ export declare const render: (props: ApplePayButtonProps, elementId: string) => any;
@@ -14,26 +14,42 @@ 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 { Locale, PayButton } from '@tap-payments/acceptance-sdk';
17
+ import './ApplePayButton.css';
18
+ import { getDefaultValues } from '../../utils/defaultValues';
19
+ import { ButtonStyle, Edges, ThemeMode } from '../../constants';
20
+ import { GetEvents, useGetEvents } from '../../hooks/useGetEvents';
18
21
  var ApplePay = React.memo(function (props) {
19
- var _a, _b, _c;
20
- var _d = useApplePay({ buttonProps: props }), onClick = _d.onClick, initialLoading = _d.initialLoading, mappedProps = _d.mappedProps, theme = _d.theme, isRounded = _d.isRounded, success = _d.success, error = _d.error, applePayPaymentMethodOptions = _d.applePayPaymentMethodOptions, profileData = _d.profileData;
22
+ var mappedProps = getDefaultValues(props);
23
+ var _a = useApplePay(mappedProps), loading = _a.loading, onApplePayButtonClicked = _a.onApplePayButtonClicked, disabled = _a.disabled, abortApplePaySession = _a.abortApplePaySession;
24
+ var onEventReceieved = React.useCallback(function (event) {
25
+ if (event === GetEvents.ABORT) {
26
+ abortApplePaySession();
27
+ }
28
+ }, [abortApplePaySession]);
29
+ useGetEvents(onEventReceieved);
21
30
  React.useEffect(function () {
22
31
  if (props.debug) {
23
32
  console.log('ApplePayButtonProps', props);
24
33
  }
25
34
  }, []);
26
- return (_jsx("div", __assign({ style: {
27
- width: '100%',
28
- display: 'flex',
29
- justifyContent: 'center'
30
- } }, { children: _jsx(PayButton, { shimmerLoader: !profileData || initialLoading || !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 }) })));
35
+ return (_jsx("button", { className: 'button-applepay-tap', style: {
36
+ ApplePayButtonType: mappedProps.interface.type,
37
+ ApplePayButtonStyle: mappedProps.interface.theme === ThemeMode.DARK ? ButtonStyle.Black : ButtonStyle.White,
38
+ borderRadius: mappedProps.interface.edges === Edges.STRAIGHT ? '0' : '10px'
39
+ }, onClick: function () {
40
+ var _a;
41
+ onApplePayButtonClicked();
42
+ (_a = props.onClick) === null || _a === void 0 ? void 0 : _a.call(props);
43
+ }, lang: mappedProps.interface.locale, disabled: loading || disabled }));
31
44
  });
32
45
  export function ApplePayButton(props) {
33
46
  return _jsx(ApplePay, __assign({}, props));
34
47
  }
48
+ export function abortApplePaySession() {
49
+ window.postMessage({ event: GetEvents.ABORT }, '*');
50
+ }
35
51
  var tapConnectInstance = null;
36
- export var renderApplePayButton = function (props, elementId) {
52
+ export var render = function (props, elementId) {
37
53
  if (tapConnectInstance) {
38
54
  return tapConnectInstance;
39
55
  }
@@ -1,3 +1,3 @@
1
- import { ApplePayButtonProps, ApplePayButton, renderApplePayButton, ApplePayRequestData } from './ApplePayButton';
2
- export { ApplePayButton, renderApplePayButton };
3
- export type { ApplePayButtonProps, ApplePayRequestData };
1
+ import { ApplePayButtonProps, ApplePayButton, render, abortApplePaySession } from './ApplePayButton';
2
+ export { ApplePayButton, render, abortApplePaySession };
3
+ export type { ApplePayButtonProps };
@@ -1,2 +1,2 @@
1
- import { ApplePayButton, renderApplePayButton } from './ApplePayButton';
2
- export { ApplePayButton, renderApplePayButton };
1
+ import { ApplePayButton, render, abortApplePaySession } from './ApplePayButton';
2
+ export { ApplePayButton, render, abortApplePaySession };
@@ -1 +1 @@
1
- export * from './useApplePay';
1
+ export * from './useScript';
@@ -1 +1 @@
1
- export * from './useApplePay';
1
+ export * from './useScript';
@@ -1,89 +1,10 @@
1
- import { ApplePayButtonProps, ApplePayDataToLunchSDKFromMerchantSide, ApplePayRequestData, MetaData, Scope } from '../@types';
2
- interface UsaApplePayProps {
3
- buttonProps: ApplePayButtonProps;
4
- }
5
- export declare const useApplePay: ({ buttonProps }: UsaApplePayProps) => {
6
- onClick: () => void;
1
+ import { ApplePayButtonProps } from '../@types';
2
+ declare type UseApplePayProps = Omit<ApplePayButtonProps, 'buttonStyle'>;
3
+ interface UseApplePayReturnProps {
7
4
  loading: boolean;
8
- isIframeIntegration: boolean;
9
- onApplePayButtonClicked: () => Promise<void>;
10
5
  disabled: boolean;
11
- applePayRequestData: ApplePayRequestData | undefined;
12
- applePayRequestConfiguration: Omit<ApplePayDataToLunchSDKFromMerchantSide, "applePayRequestData"> | undefined;
13
- mappedProps: {
14
- interface: {
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
- } | undefined;
21
- operator: {
22
- publicKey: string;
23
- hashstring?: string | undefined;
24
- };
25
- merchant: {
26
- id: string;
27
- identifier?: string | undefined;
28
- };
29
- scope: Scope;
30
- customer?: import("../@types").Customer | undefined;
31
- acceptance?: import("../@types").Acceptance | undefined;
32
- transaction?: {
33
- authentication?: boolean | undefined;
34
- authorize?: {
35
- auto: {
36
- type: string;
37
- time: number;
38
- };
39
- } | undefined;
40
- metadata?: Record<string, string> | undefined;
41
- reference?: string | undefined;
42
- paymentAgreement?: {
43
- id: string;
44
- contract?: {
45
- id: string;
46
- } | undefined;
47
- } | undefined;
48
- destinations?: Record<string, any> | undefined;
49
- } | undefined;
50
- invoice?: {
51
- id: string;
52
- } | undefined;
53
- order: {
54
- amount: number;
55
- currency: string;
56
- id?: string | undefined;
57
- description?: string | undefined;
58
- metadata?: Record<string, string> | undefined;
59
- reference?: string | undefined;
60
- };
61
- post?: {
62
- url: string;
63
- } | undefined;
64
- redirect?: {
65
- url: string;
66
- } | undefined;
67
- onOrderCreated?: ((orderId: string) => void) | undefined;
68
- onCancel?: (() => void) | undefined;
69
- onError?: ((error: any) => void) | undefined;
70
- onSuccess?: ((data: Record<string, any>) => void) | undefined;
71
- onClick?: ((data?: ApplePayDataToLunchSDKFromMerchantSide | undefined) => void) | undefined;
72
- onReady?: (() => void) | undefined;
73
- metaData?: MetaData | undefined;
74
- debug?: boolean | undefined;
75
- integration?: "iframe" | "sdk" | undefined;
76
- headers?: {
77
- mdn: string;
78
- application: string;
79
- } | undefined;
80
- };
81
- theme: import("../@types").ThemeMode;
82
- initialLoading: boolean;
83
- isRounded: boolean;
84
- success: boolean;
85
- error: boolean;
86
- applePayPaymentMethodOptions: import("../@types").PaymentMethod | null;
87
- profileData: Pick<MetaData, "merchant" | "payment_options"> | undefined;
88
- };
6
+ onApplePayButtonClicked: () => Promise<void>;
7
+ abortApplePaySession: () => void;
8
+ }
9
+ export declare const useApplePay: ({ publicKey, merchant, transaction, interface: interfaceObj, customer, onCancel, onError, onSuccess, scope, acceptance, metaData, debug, environment, onReady, onMerchantValidation, onShippingContactSelected, onPaymentMethodSelected, onCouponChanged }: UseApplePayProps) => UseApplePayReturnProps;
89
10
  export {};