@tap-payments/apple-pay-button 0.0.38-development → 0.0.38-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/ApplePayButtonProps.d.ts +129 -0
- package/build/@types/ApplePayButtonProps.js +1 -0
- package/build/@types/charge.d.ts +57 -0
- package/build/@types/charge.js +1 -0
- package/build/@types/checkoutProfile.d.ts +195 -0
- package/build/@types/checkoutProfile.js +1 -0
- package/build/@types/enums.d.ts +65 -0
- package/build/@types/enums.js +76 -0
- package/build/@types/index.d.ts +6 -222
- package/build/@types/index.js +6 -1
- package/build/@types/tapLocalisation.d.ts +193 -0
- package/build/@types/tapLocalisation.js +1 -0
- package/build/@types/tapTheme.d.ts +842 -0
- package/build/@types/tapTheme.js +1 -0
- package/build/api.d.ts +29 -0
- package/build/{api/app.service.js → api.js} +79 -100
- package/build/constants/index.d.ts +2 -71
- package/build/constants/index.js +2 -71
- package/build/features/ApplePayButton/ApplePayButton.d.ts +3 -5
- package/build/features/ApplePayButton/ApplePayButton.js +8 -19
- package/build/features/ApplePayButton/index.d.ts +2 -2
- package/build/hooks/index.d.ts +0 -1
- package/build/hooks/index.js +0 -1
- package/build/hooks/useApplePay.d.ts +89 -6
- package/build/hooks/useApplePay.js +229 -87
- package/build/hooks/useMerchantApplePay.d.ts +20 -0
- package/build/hooks/useMerchantApplePay.js +176 -0
- package/build/index.d.ts +4 -4
- package/build/index.js +2 -3
- package/build/utils/config.d.ts +7 -4
- package/build/utils/config.js +27 -26
- package/build/utils/defaultValues.d.ts +2 -69
- package/build/utils/defaultValues.js +1 -23
- package/build/utils/index.d.ts +3 -0
- package/build/utils/index.js +3 -0
- package/build/utils/theme.d.ts +12 -0
- package/build/utils/theme.js +61 -0
- package/package.json +16 -11
- package/build/api/app.service.d.ts +0 -24
- package/build/api/base.d.ts +0 -9
- package/build/api/base.js +0 -45
- package/build/api/httpClient.d.ts +0 -8
- package/build/api/httpClient.js +0 -33
- package/build/features/ApplePayButton/ApplePayButton.css +0 -21
- package/build/hooks/useScript.d.ts +0 -1
- package/build/hooks/useScript.js +0 -39
package/build/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ApplePayButtonProps, ApplePayButton } from './features/ApplePayButton';
|
|
2
|
-
import { ThemeMode, Scope, SupportedNetworks,
|
|
3
|
-
export type { ApplePayButtonProps };
|
|
4
|
-
export { ApplePayButton, ThemeMode, Scope, SupportedNetworks,
|
|
1
|
+
import { ApplePayButtonProps, ApplePayButton, ApplePayRequestData } from './features/ApplePayButton';
|
|
2
|
+
import { ThemeMode, Scope, SupportedNetworks, Locale, ButtonType, Edges, MerchantCapabilities } from './@types/enums';
|
|
3
|
+
export type { ApplePayButtonProps, ApplePayRequestData };
|
|
4
|
+
export { ApplePayButton, ThemeMode, Scope, SupportedNetworks, Locale, ButtonType, Edges, MerchantCapabilities };
|
package/build/index.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { ApplePayButton, renderApplePayButton } from './features/ApplePayButton';
|
|
2
|
-
import { ThemeMode, Scope, SupportedNetworks,
|
|
3
|
-
export { ApplePayButton, ThemeMode, Scope, SupportedNetworks,
|
|
2
|
+
import { ThemeMode, Scope, SupportedNetworks, Locale, ButtonType, Edges, MerchantCapabilities } from './@types/enums';
|
|
3
|
+
export { ApplePayButton, ThemeMode, Scope, SupportedNetworks, Locale, ButtonType, Edges, MerchantCapabilities };
|
|
4
4
|
window['TapSDKs'] = {
|
|
5
5
|
renderApplePayButton: renderApplePayButton,
|
|
6
6
|
Scope: Scope,
|
|
7
7
|
SupportedNetworks: SupportedNetworks,
|
|
8
|
-
Environment: Environment,
|
|
9
8
|
Locale: Locale,
|
|
10
9
|
ButtonType: ButtonType,
|
|
11
10
|
ThemeMode: ThemeMode,
|
package/build/utils/config.d.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
import { Acceptance, ApplePayButtonProps, ApplePayRequestData, PaymentMethod } from '../@types';
|
|
1
|
+
import { Acceptance, ApplePayButtonProps, ApplePayRequestData, MetaData, PaymentMethod } from '../@types';
|
|
2
2
|
export declare const validateSupportedNetworks: (supportedNetworksOptions: Acceptance['supportedSchemes'], merchantSupportedNetworks?: Acceptance['supportedSchemes']) => Acceptance['supportedSchemes'];
|
|
3
|
+
export declare const getApplePayPaymentMethod: (paymentMethods: Array<PaymentMethod>) => PaymentMethod;
|
|
3
4
|
export declare const getApplePayRequest: ({ order, customer, supportedNetworks, merchantCapabilities, countryCode, name }: Pick<ApplePayButtonProps, "order" | "customer"> & {
|
|
4
5
|
supportedNetworks: Acceptance['supportedSchemes'];
|
|
5
6
|
merchantCapabilities: ApplePayRequestData['merchantCapabilities'];
|
|
6
7
|
countryCode: string;
|
|
7
8
|
name: string;
|
|
8
9
|
}) => ApplePayRequestData;
|
|
9
|
-
export declare const
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
export declare const prepareApplePayRequest: ({ payment_options, merchant, order, customer, acceptance }: Pick<MetaData, 'merchant' | 'payment_options'> & Pick<ApplePayButtonProps, 'order' | 'customer' | 'acceptance'>) => {
|
|
11
|
+
applePaySessionRequest: ApplePayRequestData;
|
|
12
|
+
paymentMethod: PaymentMethod;
|
|
13
|
+
};
|
|
14
|
+
export declare const shallRenderApplePay: () => boolean;
|
package/build/utils/config.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getMerchantCapabilities } from './defaultValues';
|
|
2
2
|
export var validateSupportedNetworks = function (supportedNetworksOptions, merchantSupportedNetworks) {
|
|
3
3
|
var toLowerCase = function (item) { return item.toLowerCase(); };
|
|
4
4
|
if (!supportedNetworksOptions)
|
|
@@ -15,6 +15,16 @@ export var validateSupportedNetworks = function (supportedNetworksOptions, merch
|
|
|
15
15
|
}
|
|
16
16
|
return supportedNetworks.map(toLowerCase);
|
|
17
17
|
};
|
|
18
|
+
export var getApplePayPaymentMethod = function (paymentMethods) {
|
|
19
|
+
var paymentMethod = paymentMethods.find(function (_a) {
|
|
20
|
+
var name = _a.name, payment_type = _a.payment_type;
|
|
21
|
+
return [name, payment_type].some(function (item) { return item.toLowerCase() === 'apple_pay'; });
|
|
22
|
+
});
|
|
23
|
+
if (!paymentMethod) {
|
|
24
|
+
throw new Error('apple_pay is not configured in your payment options');
|
|
25
|
+
}
|
|
26
|
+
return paymentMethod;
|
|
27
|
+
};
|
|
18
28
|
export var getApplePayRequest = function (_a) {
|
|
19
29
|
var _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
20
30
|
var order = _a.order, customer = _a.customer, supportedNetworks = _a.supportedNetworks, merchantCapabilities = _a.merchantCapabilities, countryCode = _a.countryCode, name = _a.name;
|
|
@@ -30,35 +40,26 @@ export var getApplePayRequest = function (_a) {
|
|
|
30
40
|
familyName: ((_j = customer.name) === null || _j === void 0 ? void 0 : _j.length) ? (_k = customer.name[0]) === null || _k === void 0 ? void 0 : _k.last : ''
|
|
31
41
|
},
|
|
32
42
|
total: {
|
|
33
|
-
amount: Number(order.amount.toFixed(2)),
|
|
43
|
+
amount: Number(Number(order.amount).toFixed(2)),
|
|
34
44
|
label: name
|
|
35
45
|
}
|
|
36
46
|
};
|
|
37
47
|
};
|
|
38
|
-
export var
|
|
39
|
-
var
|
|
40
|
-
|
|
41
|
-
|
|
48
|
+
export var prepareApplePayRequest = function (_a) {
|
|
49
|
+
var payment_options = _a.payment_options, merchant = _a.merchant, order = _a.order, customer = _a.customer, acceptance = _a.acceptance;
|
|
50
|
+
var paymentMethod = getApplePayPaymentMethod(payment_options.payment_methods || []);
|
|
51
|
+
var supportedNetworks = validateSupportedNetworks(paymentMethod.supported_card_brands, acceptance === null || acceptance === void 0 ? void 0 : acceptance.supportedSchemes);
|
|
52
|
+
var request = getApplePayRequest({
|
|
53
|
+
countryCode: merchant.country_code,
|
|
54
|
+
order: order,
|
|
55
|
+
customer: customer,
|
|
56
|
+
supportedNetworks: supportedNetworks,
|
|
57
|
+
merchantCapabilities: getMerchantCapabilities(acceptance === null || acceptance === void 0 ? void 0 : acceptance.supportedFundSource),
|
|
58
|
+
name: merchant.name
|
|
42
59
|
});
|
|
43
|
-
|
|
44
|
-
throw new Error('Apple Pay is not configured in your payment options');
|
|
45
|
-
}
|
|
46
|
-
return paymentMethod;
|
|
60
|
+
return { applePaySessionRequest: request, paymentMethod: paymentMethod };
|
|
47
61
|
};
|
|
48
|
-
export var
|
|
49
|
-
var
|
|
50
|
-
|
|
51
|
-
return function (string) {
|
|
52
|
-
if (typeof string !== 'string')
|
|
53
|
-
throw new Error('string should be from type string');
|
|
54
|
-
var encrypted = rsa.encrypt(string);
|
|
55
|
-
if (!encrypted)
|
|
56
|
-
throw new Error('encryption data reached max allowed length');
|
|
57
|
-
return encrypted;
|
|
58
|
-
};
|
|
62
|
+
export var shallRenderApplePay = function () {
|
|
63
|
+
var https = window.location.protocol === 'https:';
|
|
64
|
+
return https;
|
|
59
65
|
};
|
|
60
|
-
export function generateApplicationHeader(obj) {
|
|
61
|
-
return Object.keys(obj)
|
|
62
|
-
.map(function (key) { return "".concat(key, "=").concat(obj[key]); })
|
|
63
|
-
.join('|');
|
|
64
|
-
}
|
|
@@ -1,69 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const
|
|
3
|
-
interface: {
|
|
4
|
-
locale?: "en" | "ar" | "dynamic" | undefined;
|
|
5
|
-
theme?: "dynamic" | "dark" | "light" | undefined;
|
|
6
|
-
edges?: "straight" | "curved" | undefined;
|
|
7
|
-
type?: "book" | "buy" | "check-out" | "pay" | "plain" | "subscribe" | undefined;
|
|
8
|
-
};
|
|
9
|
-
operator: {
|
|
10
|
-
publicKey: string;
|
|
11
|
-
hashstring?: string | undefined;
|
|
12
|
-
};
|
|
13
|
-
merchant: {
|
|
14
|
-
id: string;
|
|
15
|
-
};
|
|
16
|
-
scope: "charge" | "authorize" | "taptoken" | "applepaytoken";
|
|
17
|
-
environment: "production" | "sandbox" | "beta" | "development" | "staging";
|
|
18
|
-
customer?: import("../@types").Customer | undefined;
|
|
19
|
-
acceptance?: import("../@types").Acceptance | undefined;
|
|
20
|
-
transaction?: {
|
|
21
|
-
authentication?: boolean | undefined;
|
|
22
|
-
authorize?: {
|
|
23
|
-
auto: {
|
|
24
|
-
type: string;
|
|
25
|
-
time: number;
|
|
26
|
-
};
|
|
27
|
-
} | undefined;
|
|
28
|
-
metadata?: Record<string, string> | undefined;
|
|
29
|
-
reference?: string | undefined;
|
|
30
|
-
paymentAgreement?: {
|
|
31
|
-
id: string;
|
|
32
|
-
contract?: {
|
|
33
|
-
id: string;
|
|
34
|
-
} | undefined;
|
|
35
|
-
} | undefined;
|
|
36
|
-
destinations?: Record<string, any> | undefined;
|
|
37
|
-
} | undefined;
|
|
38
|
-
invoice?: {
|
|
39
|
-
id: string;
|
|
40
|
-
} | undefined;
|
|
41
|
-
order: {
|
|
42
|
-
amount: number;
|
|
43
|
-
currency: string;
|
|
44
|
-
id?: string | undefined;
|
|
45
|
-
description?: string | undefined;
|
|
46
|
-
metadata?: Record<string, string> | undefined;
|
|
47
|
-
reference?: string | undefined;
|
|
48
|
-
};
|
|
49
|
-
post?: {
|
|
50
|
-
url: string;
|
|
51
|
-
} | undefined;
|
|
52
|
-
redirect?: {
|
|
53
|
-
url: string;
|
|
54
|
-
} | undefined;
|
|
55
|
-
onOrderCreated?: ((orderId: string) => void) | undefined;
|
|
56
|
-
onCancel?: (() => void) | undefined;
|
|
57
|
-
onError?: ((error: any) => void) | undefined;
|
|
58
|
-
onSuccess?: ((data: Record<string, any>) => void) | undefined;
|
|
59
|
-
onClick?: ((data?: ApplePayRequestData | undefined) => void) | undefined;
|
|
60
|
-
onReady?: (() => void) | undefined;
|
|
61
|
-
metaData?: import("../@types").MetaData | undefined;
|
|
62
|
-
debug?: boolean | undefined;
|
|
63
|
-
integration?: "merchant" | "tap" | undefined;
|
|
64
|
-
headers?: {
|
|
65
|
-
mdn: string;
|
|
66
|
-
application: string;
|
|
67
|
-
} | undefined;
|
|
68
|
-
};
|
|
69
|
-
export declare const getMerchantCapabilities: (supportedCards?: Array<string>) => ("supports3DS" | "supportsCredit" | "supportsDebit")[];
|
|
1
|
+
import { MerchantCapabilities } from '../@types/enums';
|
|
2
|
+
export declare const getMerchantCapabilities: (supportedCards?: Array<string>) => MerchantCapabilities[];
|
|
@@ -1,14 +1,3 @@
|
|
|
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
1
|
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
13
2
|
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
14
3
|
if (ar || !(i in from)) {
|
|
@@ -18,18 +7,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
18
7
|
}
|
|
19
8
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
20
9
|
};
|
|
21
|
-
import {
|
|
22
|
-
export var getDefaultValues = function (mainObject) {
|
|
23
|
-
var userThemeMode = window.matchMedia('(prefers-color-scheme: light)').matches ? ThemeMode.LIGHT : ThemeMode.DARK;
|
|
24
|
-
var userLang = navigator.language.toLowerCase().includes(Locale.AR) ? Locale.AR : Locale.EN;
|
|
25
|
-
var defaultInterface = {
|
|
26
|
-
locale: userLang,
|
|
27
|
-
theme: userThemeMode,
|
|
28
|
-
type: ButtonType.PLAIN,
|
|
29
|
-
edges: Edges.CURVED
|
|
30
|
-
};
|
|
31
|
-
return __assign(__assign({}, mainObject), { interface: __assign(__assign({}, defaultInterface), mainObject.interface) });
|
|
32
|
-
};
|
|
10
|
+
import { MerchantCapabilities } from '../@types/enums';
|
|
33
11
|
export var getMerchantCapabilities = function (supportedCards) {
|
|
34
12
|
var merchantCapabilities = [MerchantCapabilities.Supports3DS];
|
|
35
13
|
if (!supportedCards) {
|
package/build/utils/index.d.ts
CHANGED
package/build/utils/index.js
CHANGED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { TapThemeResponse } from '../@types';
|
|
2
|
+
import { ColorStyle, FullThemeMode, Locale, ThemeMode } from '../@types/enums';
|
|
3
|
+
import { ApplePayButtonProps } from '..';
|
|
4
|
+
export declare const mappingInterface: (interfaceParam?: ApplePayButtonProps['interface']) => ApplePayButtonProps['interface'];
|
|
5
|
+
export declare const getDefaultThemeMode: (themeMode?: ThemeMode) => ThemeMode;
|
|
6
|
+
export declare const getDefaultLocale: (locale?: Locale) => Locale;
|
|
7
|
+
export declare const getFullThemeMode: (themeMode?: ThemeMode, colorStyle?: ColorStyle) => FullThemeMode;
|
|
8
|
+
export declare const appendColors: (colors: Record<string, string>) => void;
|
|
9
|
+
export declare const getTapThemeValue: ({ tapTheme, value }: {
|
|
10
|
+
tapTheme: TapThemeResponse | null;
|
|
11
|
+
value?: string | undefined;
|
|
12
|
+
}) => string;
|
|
@@ -0,0 +1,61 @@
|
|
|
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 { ColorStyle, Edges, FullThemeMode, Locale, ThemeMode } from '../@types/enums';
|
|
13
|
+
export var mappingInterface = function (interfaceParam) {
|
|
14
|
+
return __assign(__assign({ edges: Edges.CURVED, colorStyle: ColorStyle.COLORED, loader: true }, interfaceParam), { locale: getDefaultLocale(interfaceParam === null || interfaceParam === void 0 ? void 0 : interfaceParam.locale), theme: getDefaultThemeMode(interfaceParam === null || interfaceParam === void 0 ? void 0 : interfaceParam.theme) });
|
|
15
|
+
};
|
|
16
|
+
export var getDefaultThemeMode = function (themeMode) {
|
|
17
|
+
return themeMode === ThemeMode.DYNAMIC || themeMode === undefined
|
|
18
|
+
? window.matchMedia('(prefers-color-scheme: dark)').matches
|
|
19
|
+
? ThemeMode.DARK
|
|
20
|
+
: ThemeMode.LIGHT
|
|
21
|
+
: themeMode;
|
|
22
|
+
};
|
|
23
|
+
export var getDefaultLocale = function (locale) {
|
|
24
|
+
var _a;
|
|
25
|
+
return locale === Locale.DYNAMIC || locale === undefined
|
|
26
|
+
? (_a = window.navigator.language.split('-')) === null || _a === void 0 ? void 0 : _a[0]
|
|
27
|
+
: locale;
|
|
28
|
+
};
|
|
29
|
+
export var getFullThemeMode = function (themeMode, colorStyle) {
|
|
30
|
+
var themeModeValue = getDefaultThemeMode(themeMode);
|
|
31
|
+
if (themeModeValue === ThemeMode.DARK) {
|
|
32
|
+
return colorStyle === ColorStyle.MONOCHROME ? FullThemeMode.DARK : FullThemeMode.DARK_COLORED;
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
return colorStyle === ColorStyle.MONOCHROME ? FullThemeMode.LIGHT_MONO : FullThemeMode.LIGHT;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
export var appendColors = function (colors) {
|
|
39
|
+
try {
|
|
40
|
+
var root_1 = document.documentElement;
|
|
41
|
+
Object.entries(colors).forEach(function (_a) {
|
|
42
|
+
var key = _a[0], value = _a[1];
|
|
43
|
+
root_1.style.setProperty("--".concat(key), value);
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
catch (e) {
|
|
47
|
+
throw e;
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
export var getTapThemeValue = function (_a) {
|
|
51
|
+
var tapTheme = _a.tapTheme, value = _a.value;
|
|
52
|
+
if (!tapTheme)
|
|
53
|
+
return '';
|
|
54
|
+
if (!value)
|
|
55
|
+
return '';
|
|
56
|
+
if (value[0] === '#')
|
|
57
|
+
return value;
|
|
58
|
+
var colorsObject = tapTheme === null || tapTheme === void 0 ? void 0 : tapTheme.GlobalValues.Colors;
|
|
59
|
+
var valueFromGlobalColors = colorsObject === null || colorsObject === void 0 ? void 0 : colorsObject[value];
|
|
60
|
+
return valueFromGlobalColors !== null && valueFromGlobalColors !== void 0 ? valueFromGlobalColors : '';
|
|
61
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tap-payments/apple-pay-button",
|
|
3
|
-
"version": "0.0.38-
|
|
3
|
+
"version": "0.0.38-test",
|
|
4
4
|
"description": "Apple Pay Button React Component",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"module": "build/index.js",
|
|
@@ -10,17 +10,17 @@
|
|
|
10
10
|
"README.md"
|
|
11
11
|
],
|
|
12
12
|
"scripts": {
|
|
13
|
+
"start": "cross-env NODE_ENV=development webpack serve",
|
|
13
14
|
"prepare": "npx husky install",
|
|
14
15
|
"prettier": "prettier --list-different \"src/**/*.{md,mdx,ts,js,tsx,jsx,json}\" *.json *.js",
|
|
15
16
|
"prettier:fix": "prettier --write \"src/**/*.{ts,tsx,js,jsx,json,md,css,json}\" *.json *.js",
|
|
16
17
|
"lint": "eslint src --color --ext .js,.jsx,.ts,.tsx,.json",
|
|
17
18
|
"lint:fix": "eslint src --ext .js,.jsx,.ts,.tsx --fix",
|
|
18
|
-
"start": "cross-env NODE_ENV=development webpack serve",
|
|
19
19
|
"build": "cross-env NODE_ENV=production webpack",
|
|
20
|
-
"copy:files": "copyfiles -u 1 src/**/*.css build/",
|
|
20
|
+
"copy:files": "copyfiles -u 1 src/**/*.gif build/ && copyfiles -u 1 src/**/*.css build/",
|
|
21
21
|
"tsc:alias": "tsc-alias -p tsconfig.json",
|
|
22
22
|
"ts:build": "rm -rf build && tsc && yarn tsc:alias && yarn copy:files",
|
|
23
|
-
"push": "npm publish --access public --tag
|
|
23
|
+
"push": "npm publish --access public --tag test"
|
|
24
24
|
},
|
|
25
25
|
"keywords": [],
|
|
26
26
|
"author": {
|
|
@@ -28,11 +28,23 @@
|
|
|
28
28
|
"email": "a.elsharkawy@tap.company"
|
|
29
29
|
},
|
|
30
30
|
"license": "ISC",
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@tap-payments/acceptance-sdk": "^0.0.46",
|
|
33
|
+
"@tap-payments/browser-info": "^1.0.2",
|
|
34
|
+
"@tap-payments/web-error-handing": "^1.0.1",
|
|
35
|
+
"axios": "^1.2.2",
|
|
36
|
+
"framer-motion": "^10.16.5",
|
|
37
|
+
"jsencrypt": "^3.3.2",
|
|
38
|
+
"lottie-react": "^2.4.0",
|
|
39
|
+
"react": "^18.2.0",
|
|
40
|
+
"react-dom": "^18.2.0"
|
|
41
|
+
},
|
|
31
42
|
"devDependencies": {
|
|
32
43
|
"@babel/core": "^7.18.6",
|
|
33
44
|
"@babel/preset-env": "^7.18.6",
|
|
34
45
|
"@babel/preset-react": "^7.18.6",
|
|
35
46
|
"@babel/preset-typescript": "^7.18.6",
|
|
47
|
+
"@types/applepayjs": "^14.0.3",
|
|
36
48
|
"@types/crypto-js": "^4.1.1",
|
|
37
49
|
"@types/react": "^18.0.15",
|
|
38
50
|
"@types/react-dom": "^18.0.6",
|
|
@@ -71,13 +83,6 @@
|
|
|
71
83
|
"webpack-dev-server": "^4.9.3",
|
|
72
84
|
"webpack-merge": "^5.8.0"
|
|
73
85
|
},
|
|
74
|
-
"dependencies": {
|
|
75
|
-
"@tap-payments/browser-info": "^1.0.2",
|
|
76
|
-
"axios": "^1.2.2",
|
|
77
|
-
"jsencrypt": "^3.3.2",
|
|
78
|
-
"react": ">=17.0.2",
|
|
79
|
-
"react-dom": ">=17.0.2"
|
|
80
|
-
},
|
|
81
86
|
"peerDependencies": {
|
|
82
87
|
"react": ">=17.0.2",
|
|
83
88
|
"react-dom": ">=17.0.2"
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { MerchantResponse, ApplePayButtonProps, CheckoutProfileRequest } from '../@types';
|
|
2
|
-
import BaseService from './base';
|
|
3
|
-
declare class APPService extends BaseService {
|
|
4
|
-
private baseUrl;
|
|
5
|
-
private env;
|
|
6
|
-
constructor();
|
|
7
|
-
setEnv(env: ApplePayButtonProps['environment']): void;
|
|
8
|
-
setBaseUrl(): void;
|
|
9
|
-
getHeaderPublicKey(): "-----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC8AX++RtxPZFtns4XzXFlDIxPBh0umN4qRXZaKDIlb6a3MknaB7psJWmf2l+e4Cfh9b5tey/+rZqpQ065eXTZfGCAuBLt+fYLQBhLfjRpk8S6hlIzc1Kdjg65uqzMwcTd0p7I4KLwHk1I0oXzuEu53fU1LSZhWp4Mnd6wjVgXAsQIDAQAB\n-----END PUBLIC KEY-----" | "" | "-----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC9hSRms7Ir1HmzdZxGXFYgmpi3\nez7VBFje0f8wwrxYS9oVoBtN4iAt0DOs3DbeuqtueI31wtpFVUMGg8W7R0SbtkZd\nGzszQNqt/wyqxpDC9q+97XdXwkWQFA72s76ud7eMXQlsWKsvgwhY+Ywzt0KlpNC3\nHj+N6UWFOYK98Xi+sQIDAQAB\n-----END PUBLIC KEY-----" | "-----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCi9W5jyTvA4Iwv3V5sfNQ7VdSz\n7WqwBbnWFbIUL/GjaaE93mvDv4zbgRSznHaHQPH6pxrMhMh0tV58njkvjHvQ/tvg\npwM8SemNPKEEAPl69tnMvCrJRPh2dWL3OHY8yCW4c38Hyx4fy56Zd5cdoVWfCReu\njCsvASLGz+cfRrj2swIDAQAB\n-----END PUBLIC KEY-----";
|
|
10
|
-
setHttpHeaders(headers: Record<string, string>): Promise<void>;
|
|
11
|
-
setBrowserHeaders({ locale, pk, domain }: {
|
|
12
|
-
locale: string;
|
|
13
|
-
pk: string;
|
|
14
|
-
domain: string;
|
|
15
|
-
}): Promise<void>;
|
|
16
|
-
checkoutProfile(request: CheckoutProfileRequest): Promise<{
|
|
17
|
-
merchant: any;
|
|
18
|
-
payment_options: any;
|
|
19
|
-
}>;
|
|
20
|
-
appleSession(merchant: Pick<MerchantResponse, 'name' | 'id'>, validationURL: string, merchantRegisteredDomain: string): Promise<any>;
|
|
21
|
-
tapTokenization(applePaymentData: Record<string, string>): Promise<any>;
|
|
22
|
-
}
|
|
23
|
-
declare const appService: APPService;
|
|
24
|
-
export default appService;
|
package/build/api/base.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { AxiosInstance, AxiosRequestConfig } from 'axios';
|
|
2
|
-
export default class BaseService {
|
|
3
|
-
httpClient: AxiosInstance;
|
|
4
|
-
constructor(httpClient: AxiosInstance);
|
|
5
|
-
get(url: string, config?: AxiosRequestConfig<any>): Promise<import("axios").AxiosResponse<any, any>>;
|
|
6
|
-
post(url: string, data?: any, config?: AxiosRequestConfig<any>): Promise<import("axios").AxiosResponse<any, any>>;
|
|
7
|
-
put(url: string, data?: any, config?: AxiosRequestConfig<any>): Promise<import("axios").AxiosResponse<any, any>>;
|
|
8
|
-
delete(url: string, config?: AxiosRequestConfig<any>): Promise<import("axios").AxiosResponse<any, any>>;
|
|
9
|
-
}
|
package/build/api/base.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
var BaseService = (function () {
|
|
2
|
-
function BaseService(httpClient) {
|
|
3
|
-
Object.defineProperty(this, "httpClient", {
|
|
4
|
-
enumerable: true,
|
|
5
|
-
configurable: true,
|
|
6
|
-
writable: true,
|
|
7
|
-
value: void 0
|
|
8
|
-
});
|
|
9
|
-
this.httpClient = httpClient;
|
|
10
|
-
}
|
|
11
|
-
Object.defineProperty(BaseService.prototype, "get", {
|
|
12
|
-
enumerable: false,
|
|
13
|
-
configurable: true,
|
|
14
|
-
writable: true,
|
|
15
|
-
value: function (url, config) {
|
|
16
|
-
return this.httpClient.get(url, config);
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
Object.defineProperty(BaseService.prototype, "post", {
|
|
20
|
-
enumerable: false,
|
|
21
|
-
configurable: true,
|
|
22
|
-
writable: true,
|
|
23
|
-
value: function (url, data, config) {
|
|
24
|
-
return this.httpClient.post(url, data, config);
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
Object.defineProperty(BaseService.prototype, "put", {
|
|
28
|
-
enumerable: false,
|
|
29
|
-
configurable: true,
|
|
30
|
-
writable: true,
|
|
31
|
-
value: function (url, data, config) {
|
|
32
|
-
return this.httpClient.put(url, data, config);
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
Object.defineProperty(BaseService.prototype, "delete", {
|
|
36
|
-
enumerable: false,
|
|
37
|
-
configurable: true,
|
|
38
|
-
writable: true,
|
|
39
|
-
value: function (url, config) {
|
|
40
|
-
return this.httpClient.delete(url, config);
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
return BaseService;
|
|
44
|
-
}());
|
|
45
|
-
export default BaseService;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export declare const MW_BASE_LIVE_URL = "https://mw-sdk.tap.company/v2/checkout";
|
|
2
|
-
export declare const MW_BASE_STAGING_URL = "https://mw-sdk.staging.tap.company/v2/checkout";
|
|
3
|
-
export declare const MW_BASE_DEV_URL = "https://mw-sdk.dev.tap.company/v2/checkout";
|
|
4
|
-
export declare const MW_BASE_BETA_URL = "https://mw-sdk.beta.tap.company/v2/checkout";
|
|
5
|
-
export declare const MW_BASE_SANDBOX_URL = "https://mw-sdk.sandbox.tap.company/v2/checkout";
|
|
6
|
-
declare const httpClient: import("axios").AxiosInstance;
|
|
7
|
-
export declare const setAxiosGlobalHeaders: (headers: Record<string, string>) => void;
|
|
8
|
-
export default httpClient;
|
package/build/api/httpClient.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
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.staging.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.beta.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,21 +0,0 @@
|
|
|
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 +0,0 @@
|
|
|
1
|
-
export declare function useScript(src: string, async?: boolean): "loading" | "ready" | "idle" | "error";
|
package/build/hooks/useScript.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { useEffect, useState } from 'react';
|
|
2
|
-
export function useScript(src, async) {
|
|
3
|
-
if (async === void 0) { async = true; }
|
|
4
|
-
var _a = useState(src ? 'loading' : 'idle'), status = _a[0], setStatus = _a[1];
|
|
5
|
-
useEffect(function () {
|
|
6
|
-
if (!src) {
|
|
7
|
-
setStatus('idle');
|
|
8
|
-
return;
|
|
9
|
-
}
|
|
10
|
-
var script = document.querySelector("script[src=\"".concat(src, "\"]"));
|
|
11
|
-
if (!script) {
|
|
12
|
-
script = document.createElement('script');
|
|
13
|
-
script.src = src;
|
|
14
|
-
script.async = async;
|
|
15
|
-
script.setAttribute('data-status', 'loading');
|
|
16
|
-
document.body.appendChild(script);
|
|
17
|
-
var setAttributeFromEvent = function (event) {
|
|
18
|
-
script.setAttribute('data-status', event.type === 'load' ? 'ready' : 'error');
|
|
19
|
-
};
|
|
20
|
-
script.addEventListener('load', setAttributeFromEvent);
|
|
21
|
-
script.addEventListener('error', setAttributeFromEvent);
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
setStatus(script.getAttribute('data-status'));
|
|
25
|
-
}
|
|
26
|
-
var setStateFromEvent = function (event) {
|
|
27
|
-
setStatus(event.type === 'load' ? 'ready' : 'error');
|
|
28
|
-
};
|
|
29
|
-
script.addEventListener('load', setStateFromEvent);
|
|
30
|
-
script.addEventListener('error', setStateFromEvent);
|
|
31
|
-
return function () {
|
|
32
|
-
if (script) {
|
|
33
|
-
script.removeEventListener('load', setStateFromEvent);
|
|
34
|
-
script.removeEventListener('error', setStateFromEvent);
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
}, [src]);
|
|
38
|
-
return status;
|
|
39
|
-
}
|