@tap-payments/apple-pay-button 0.0.3 → 0.0.4-staging

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/LICENSE +21 -21
  2. package/README.md +240 -194
  3. package/build/@types/ApplePayButtonProps.d.ts +129 -0
  4. package/build/@types/ApplePayButtonProps.js +1 -0
  5. package/build/@types/charge.d.ts +57 -0
  6. package/build/@types/charge.js +1 -0
  7. package/build/@types/checkoutProfile.d.ts +216 -0
  8. package/build/@types/checkoutProfile.js +1 -0
  9. package/build/@types/enums.d.ts +65 -0
  10. package/build/@types/enums.js +76 -0
  11. package/build/@types/index.d.ts +6 -82
  12. package/build/@types/index.js +6 -1
  13. package/build/@types/tapLocalisation.d.ts +193 -0
  14. package/build/@types/tapLocalisation.js +1 -0
  15. package/build/@types/tapTheme.d.ts +842 -0
  16. package/build/@types/tapTheme.js +1 -0
  17. package/build/api.d.ts +29 -0
  18. package/build/{api/app.service.js → api.js} +244 -253
  19. package/build/constants/index.d.ts +3 -51
  20. package/build/constants/index.js +3 -51
  21. package/build/features/ApplePayButton/ApplePayButton.d.ts +4 -6
  22. package/build/features/ApplePayButton/ApplePayButton.js +49 -80
  23. package/build/features/ApplePayButton/index.d.ts +3 -3
  24. package/build/features/ApplePayButton/index.js +2 -2
  25. package/build/hooks/index.d.ts +1 -1
  26. package/build/hooks/index.js +1 -1
  27. package/build/hooks/useApplePay.d.ts +93 -9
  28. package/build/hooks/useApplePay.js +449 -243
  29. package/build/hooks/useMerchantApplePay.d.ts +20 -0
  30. package/build/hooks/useMerchantApplePay.js +188 -0
  31. package/build/index.d.ts +4 -4
  32. package/build/index.js +13 -10
  33. package/build/utils/config.d.ts +14 -11
  34. package/build/utils/config.js +65 -72
  35. package/build/utils/defaultValues.d.ts +2 -0
  36. package/build/utils/defaultValues.js +27 -0
  37. package/build/utils/html.d.ts +1 -1
  38. package/build/utils/html.js +9 -9
  39. package/build/utils/index.d.ts +4 -1
  40. package/build/utils/index.js +4 -1
  41. package/build/utils/theme.d.ts +12 -0
  42. package/build/utils/theme.js +61 -0
  43. package/package.json +109 -104
  44. package/build/api/app.service.d.ts +0 -23
  45. package/build/api/base.d.ts +0 -9
  46. package/build/api/base.js +0 -45
  47. package/build/api/httpClient.d.ts +0 -8
  48. package/build/api/httpClient.js +0 -33
  49. package/build/features/ApplePayButton/ApplePayButton.css +0 -21
  50. package/build/hooks/useScript.d.ts +0 -1
  51. package/build/hooks/useScript.js +0 -39
@@ -1,51 +1,3 @@
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
+ export var ApplePayVersion = 5;
2
+ export var RSA_MW_PUBLIC_KEY = "-----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCi9W5jyTvA4Iwv3V5sfNQ7VdSz\n7WqwBbnWFbIUL/GjaaE93mvDv4zbgRSznHaHQPH6pxrMhMh0tV58njkvjHvQ/tvg\npwM8SemNPKEEAPl69tnMvCrJRPh2dWL3OHY8yCW4c38Hyx4fy56Zd5cdoVWfCReu\njCsvASLGz+cfRrj2swIDAQAB\n-----END PUBLIC KEY-----";
3
+ export var MW_BASE_URL = 'https://mw-sdk.staging.tap.company/v2/checkout';
@@ -1,6 +1,4 @@
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
+ import { ApplePayButtonProps, ApplePayRequestData } from '../../@types';
2
+ export type { ApplePayButtonProps, ApplePayRequestData };
3
+ export declare function ApplePayButton(props: ApplePayButtonProps): import("react/jsx-runtime").JSX.Element;
4
+ export declare const renderApplePayButton: (props: ApplePayButtonProps, elementId: string) => any;
@@ -1,80 +1,49 @@
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
+ 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 { Locale, PayButton } from '@tap-payments/acceptance-sdk';
18
+ 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;
21
+ React.useEffect(function () {
22
+ if (props.debug) {
23
+ console.log('ApplePayButtonProps', props);
24
+ }
25
+ }, []);
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 }) })));
31
+ });
32
+ export function ApplePayButton(props) {
33
+ return _jsx(ApplePay, __assign({}, props));
34
+ }
35
+ var tapConnectInstance = null;
36
+ export var renderApplePayButton = function (props, elementId) {
37
+ if (tapConnectInstance) {
38
+ return tapConnectInstance;
39
+ }
40
+ var el = findOrCreateElementAndInject(elementId);
41
+ var root = createRoot(el);
42
+ root.render(_jsx(ApplePayButton, __assign({}, props)));
43
+ var unmount = function () {
44
+ root.unmount();
45
+ tapConnectInstance = null;
46
+ };
47
+ tapConnectInstance = { unmount: unmount };
48
+ return tapConnectInstance;
49
+ };
@@ -1,3 +1,3 @@
1
- import { ApplePayButtonProps, ApplePayButton, renderApplePayButton } from './ApplePayButton';
2
- export { ApplePayButton, renderApplePayButton };
3
- export type { ApplePayButtonProps };
1
+ import { ApplePayButtonProps, ApplePayButton, renderApplePayButton, ApplePayRequestData } from './ApplePayButton';
2
+ export { ApplePayButton, renderApplePayButton };
3
+ export type { ApplePayButtonProps, ApplePayRequestData };
@@ -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 './useApplePay';
@@ -1 +1 @@
1
- export * from './useScript';
1
+ export * from './useApplePay';
@@ -1,9 +1,93 @@
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 {};
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;
7
+ loading: boolean;
8
+ isIframeIntegration: boolean;
9
+ onApplePayButtonClicked: () => Promise<void>;
10
+ 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
+ userExperience?: "popup" | "page" | undefined;
21
+ powered?: boolean | undefined;
22
+ direction?: import("@tap-payments/acceptance-sdk").Direction | undefined;
23
+ cardDirection?: import("@tap-payments/acceptance-sdk").Direction | undefined;
24
+ } | undefined;
25
+ operator: {
26
+ publicKey: string;
27
+ hashstring?: string | undefined;
28
+ };
29
+ merchant: {
30
+ id: string;
31
+ identifier?: string | undefined;
32
+ };
33
+ scope: Scope;
34
+ customer?: import("../@types").Customer | undefined;
35
+ acceptance?: import("../@types").Acceptance | undefined;
36
+ transaction?: {
37
+ authentication?: boolean | undefined;
38
+ authorize?: {
39
+ auto: {
40
+ type: string;
41
+ time: number;
42
+ };
43
+ } | undefined;
44
+ metadata?: Record<string, string> | undefined;
45
+ reference?: string | undefined;
46
+ paymentAgreement?: {
47
+ id: string;
48
+ contract?: {
49
+ id: string;
50
+ } | undefined;
51
+ } | undefined;
52
+ destinations?: Record<string, any> | undefined;
53
+ } | undefined;
54
+ invoice?: {
55
+ id: string;
56
+ } | undefined;
57
+ order: {
58
+ amount: number;
59
+ currency: string;
60
+ id?: string | undefined;
61
+ description?: string | undefined;
62
+ metadata?: Record<string, string> | undefined;
63
+ reference?: string | undefined;
64
+ };
65
+ post?: {
66
+ url: string;
67
+ } | undefined;
68
+ redirect?: {
69
+ url: string;
70
+ } | undefined;
71
+ onOrderCreated?: ((orderId: string) => void) | undefined;
72
+ onCancel?: (() => void) | undefined;
73
+ onError?: ((error: any) => void) | undefined;
74
+ onSuccess?: ((data: Record<string, any>) => Promise<void>) | undefined;
75
+ onClick?: ((data?: ApplePayDataToLunchSDKFromMerchantSide | undefined) => void) | undefined;
76
+ onReady?: (() => void) | undefined;
77
+ metaData?: MetaData | undefined;
78
+ debug?: boolean | undefined;
79
+ integration?: "iframe" | "sdk" | "webview" | undefined;
80
+ headers?: {
81
+ mdn: string;
82
+ application: string;
83
+ } | undefined;
84
+ };
85
+ theme: import("../@types").ThemeMode;
86
+ initialLoading: boolean;
87
+ isRounded: boolean;
88
+ success: boolean;
89
+ error: boolean;
90
+ applePayPaymentMethodOptions: import("../@types").PaymentMethod | null;
91
+ profileData: Pick<MetaData, "merchant" | "payment_options"> | undefined;
92
+ };
93
+ export {};