@tap-payments/apple-pay-button 0.0.65-development → 0.0.66-development
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 +1 -2
- package/build/@types/enums.d.ts +2 -8
- package/build/@types/enums.js +1 -8
- package/build/api.d.ts +34 -0
- package/build/{api/app.service.js → api.js} +36 -107
- package/build/constants/index.d.ts +2 -7
- package/build/constants/index.js +2 -7
- package/build/features/ApplePayButton/ApplePayButton.d.ts +0 -1
- package/build/features/ApplePayButton/ApplePayButton.js +9 -8
- package/build/hooks/index.d.ts +0 -1
- package/build/hooks/index.js +0 -1
- package/build/hooks/useApplePay.d.ts +9 -13
- package/build/hooks/useApplePay.js +23 -57
- package/build/hooks/useMerchantApplePay.js +2 -2
- package/build/index.d.ts +2 -2
- package/build/index.js +2 -3
- package/build/utils/config.d.ts +0 -2
- package/build/utils/config.js +0 -18
- package/build/utils/defaultValues.d.ts +1 -71
- package/build/utils/defaultValues.js +1 -23
- package/package.json +3 -4
- package/build/api/app.service.d.ts +0 -27
- package/build/api/base.d.ts +0 -9
- package/build/api/base.js +0 -45
- package/build/api/httpClient.d.ts +0 -22
- package/build/api/httpClient.js +0 -36
- package/build/assets/gif/error-black.gif +0 -0
- package/build/assets/gif/error-white.gif +0 -0
- package/build/assets/gif/success-black.gif +0 -0
- package/build/assets/gif/success-white.gif +0 -0
- package/build/assets/lottie/Dark_Mode_Loader.json +0 -255
- package/build/assets/lottie/Light_Mode_Loader.json +0 -255
- package/build/components/ActionButton/ActionButton.d.ts +0 -24
- package/build/components/ActionButton/ActionButton.js +0 -62
- package/build/components/ActionButton/index.d.ts +0 -2
- package/build/components/ActionButton/index.js +0 -2
- package/build/components/InitialLoader/InitialLoader.d.ts +0 -9
- package/build/components/InitialLoader/InitialLoader.js +0 -26
- package/build/components/InitialLoader/index.d.ts +0 -2
- package/build/components/InitialLoader/index.js +0 -2
- package/build/components/Loader/Loader.d.ts +0 -24
- package/build/components/Loader/Loader.js +0 -48
- package/build/components/Loader/index.d.ts +0 -2
- package/build/components/Loader/index.js +0 -2
- package/build/components/PayButton/PayButton.d.ts +0 -16
- package/build/components/PayButton/PayButton.js +0 -40
- package/build/components/PayButton/index.d.ts +0 -2
- package/build/components/PayButton/index.js +0 -2
- package/build/components/PayButton/style.d.ts +0 -5
- package/build/components/PayButton/style.js +0 -19
- package/build/features/ApplePayButton/ApplePayButton.css +0 -21
- package/build/features/ApplePayButton/style.d.ts +0 -5
- package/build/features/ApplePayButton/style.js +0 -20
- package/build/hooks/useScript.d.ts +0 -3
- package/build/hooks/useScript.js +0 -40
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CheckoutProfileResponse } from './checkoutProfile';
|
|
2
|
-
import { Locale,
|
|
2
|
+
import { Locale, ThemeMode, Edges, Scope, MerchantCapabilities, SupportedNetworks, ButtonType, ColorStyle } from './enums';
|
|
3
3
|
export interface ApplePayRequestData {
|
|
4
4
|
countryCode: string;
|
|
5
5
|
currencyCode: string;
|
|
@@ -62,7 +62,6 @@ export interface ApplePayButtonProps {
|
|
|
62
62
|
id: string;
|
|
63
63
|
};
|
|
64
64
|
scope: Scope;
|
|
65
|
-
environment: Environment;
|
|
66
65
|
interface?: Interface;
|
|
67
66
|
customer?: Customer;
|
|
68
67
|
acceptance?: Acceptance;
|
package/build/@types/enums.d.ts
CHANGED
|
@@ -10,19 +10,13 @@ export declare enum ThemeMode {
|
|
|
10
10
|
}
|
|
11
11
|
export declare enum Edges {
|
|
12
12
|
STRAIGHT = "straight",
|
|
13
|
-
CURVED = "curved"
|
|
13
|
+
CURVED = "curved",
|
|
14
|
+
CIRCULAR = "circular"
|
|
14
15
|
}
|
|
15
16
|
export declare enum ColorStyle {
|
|
16
17
|
COLORED = "colored",
|
|
17
18
|
MONOCHROME = "monochrome"
|
|
18
19
|
}
|
|
19
|
-
export declare enum Environment {
|
|
20
|
-
Beta = "beta",
|
|
21
|
-
Staging = "staging",
|
|
22
|
-
Sandbox = "sandbox",
|
|
23
|
-
Production = "production",
|
|
24
|
-
Development = "development"
|
|
25
|
-
}
|
|
26
20
|
export declare enum Scope {
|
|
27
21
|
CHARGE = "charge",
|
|
28
22
|
AUTHORIZE = "authorize",
|
package/build/@types/enums.js
CHANGED
|
@@ -14,20 +14,13 @@ export var Edges;
|
|
|
14
14
|
(function (Edges) {
|
|
15
15
|
Edges["STRAIGHT"] = "straight";
|
|
16
16
|
Edges["CURVED"] = "curved";
|
|
17
|
+
Edges["CIRCULAR"] = "circular";
|
|
17
18
|
})(Edges || (Edges = {}));
|
|
18
19
|
export var ColorStyle;
|
|
19
20
|
(function (ColorStyle) {
|
|
20
21
|
ColorStyle["COLORED"] = "colored";
|
|
21
22
|
ColorStyle["MONOCHROME"] = "monochrome";
|
|
22
23
|
})(ColorStyle || (ColorStyle = {}));
|
|
23
|
-
export var Environment;
|
|
24
|
-
(function (Environment) {
|
|
25
|
-
Environment["Beta"] = "beta";
|
|
26
|
-
Environment["Staging"] = "staging";
|
|
27
|
-
Environment["Sandbox"] = "sandbox";
|
|
28
|
-
Environment["Production"] = "production";
|
|
29
|
-
Environment["Development"] = "development";
|
|
30
|
-
})(Environment || (Environment = {}));
|
|
31
24
|
export var Scope;
|
|
32
25
|
(function (Scope) {
|
|
33
26
|
Scope["CHARGE"] = "charge";
|
package/build/api.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { MerchantResponse, CheckoutProfileRequest, ChargeRequestBody, AuthorizeRequestBody } from './@types';
|
|
2
|
+
export declare const setAxiosGlobalHeaders: (headers: Record<string, string>) => void;
|
|
3
|
+
export declare const getAxiosGlobalHeaders: () => {
|
|
4
|
+
[x: string]: (string | number | boolean | string[] | import("axios").AxiosHeaders | null) | undefined;
|
|
5
|
+
head?: import("axios").AxiosHeaders | undefined;
|
|
6
|
+
link?: import("axios").AxiosHeaders | undefined;
|
|
7
|
+
post?: import("axios").AxiosHeaders | undefined;
|
|
8
|
+
get?: import("axios").AxiosHeaders | undefined;
|
|
9
|
+
delete?: import("axios").AxiosHeaders | undefined;
|
|
10
|
+
options?: import("axios").AxiosHeaders | undefined;
|
|
11
|
+
put?: import("axios").AxiosHeaders | undefined;
|
|
12
|
+
patch?: import("axios").AxiosHeaders | undefined;
|
|
13
|
+
purge?: import("axios").AxiosHeaders | undefined;
|
|
14
|
+
unlink?: import("axios").AxiosHeaders | undefined;
|
|
15
|
+
common?: import("axios").AxiosHeaders | undefined;
|
|
16
|
+
};
|
|
17
|
+
declare class APPService {
|
|
18
|
+
setHttpHeaders(headers: Record<string, string>): Promise<void>;
|
|
19
|
+
setBrowserHeaders({ locale, pk, domain }: {
|
|
20
|
+
locale: string;
|
|
21
|
+
pk: string;
|
|
22
|
+
domain: string;
|
|
23
|
+
}): Promise<void>;
|
|
24
|
+
checkoutProfile(request: CheckoutProfileRequest): Promise<{
|
|
25
|
+
merchant: any;
|
|
26
|
+
payment_options: any;
|
|
27
|
+
}>;
|
|
28
|
+
appleSession(merchant: Pick<MerchantResponse, 'name' | 'id'>, validationURL: string, merchantRegisteredDomain: string): Promise<any>;
|
|
29
|
+
tapTokenization(applePaymentData: Record<string, string>): Promise<any>;
|
|
30
|
+
createCharge(request: ChargeRequestBody): Promise<any>;
|
|
31
|
+
createAuthorize(request: AuthorizeRequestBody): Promise<any>;
|
|
32
|
+
}
|
|
33
|
+
declare const appService: APPService;
|
|
34
|
+
export default appService;
|
|
@@ -1,18 +1,14 @@
|
|
|
1
|
-
var
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
if (typeof b !== "function" && b !== null)
|
|
10
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
11
|
-
extendStatics(d, b);
|
|
12
|
-
function __() { this.constructor = d; }
|
|
13
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
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;
|
|
14
9
|
};
|
|
15
|
-
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
16
12
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
17
13
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
18
14
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -60,95 +56,28 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
60
56
|
}
|
|
61
57
|
return t;
|
|
62
58
|
};
|
|
63
|
-
import { Environment } from '../@types';
|
|
64
|
-
import BaseService from './base';
|
|
65
|
-
import httpClient, { setAxiosGlobalHeaders, MW_BASE_BETA_URL, MW_BASE_DEV_URL, MW_BASE_LIVE_URL, MW_BASE_STAGING_URL, MW_BASE_SANDBOX_URL } from './httpClient';
|
|
66
59
|
import BrowserInfo from '@tap-payments/browser-info';
|
|
67
|
-
import {
|
|
68
|
-
import
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
enumerable: true,
|
|
75
|
-
configurable: true,
|
|
76
|
-
writable: true,
|
|
77
|
-
value: void 0
|
|
78
|
-
});
|
|
79
|
-
Object.defineProperty(_this, "env", {
|
|
80
|
-
enumerable: true,
|
|
81
|
-
configurable: true,
|
|
82
|
-
writable: true,
|
|
83
|
-
value: void 0
|
|
84
|
-
});
|
|
85
|
-
_this.baseUrl = MW_BASE_LIVE_URL;
|
|
86
|
-
_this.env = Environment.Production;
|
|
87
|
-
return _this;
|
|
60
|
+
import { MW_BASE_URL, RSA_MW_PUBLIC_KEY } from './constants';
|
|
61
|
+
import axios from 'axios';
|
|
62
|
+
import { generateApplicationHeader, rsaSetup } from '@tap-payments/acceptance-sdk';
|
|
63
|
+
var axiosInstance = axios.create({
|
|
64
|
+
baseURL: MW_BASE_URL,
|
|
65
|
+
headers: {
|
|
66
|
+
'Content-Type': 'application/json'
|
|
88
67
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
this.env = env;
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
Object.defineProperty(APPService.prototype, "setBaseUrl", {
|
|
98
|
-
enumerable: false,
|
|
99
|
-
configurable: true,
|
|
100
|
-
writable: true,
|
|
101
|
-
value: function () {
|
|
102
|
-
if (!this.env)
|
|
103
|
-
throw new Error('Environment is not set');
|
|
104
|
-
switch (this.env) {
|
|
105
|
-
case 'staging':
|
|
106
|
-
this.baseUrl = MW_BASE_STAGING_URL;
|
|
107
|
-
break;
|
|
108
|
-
case 'beta':
|
|
109
|
-
this.baseUrl = MW_BASE_BETA_URL;
|
|
110
|
-
break;
|
|
111
|
-
case 'development':
|
|
112
|
-
this.baseUrl = MW_BASE_DEV_URL;
|
|
113
|
-
break;
|
|
114
|
-
case 'sandbox':
|
|
115
|
-
this.baseUrl = MW_BASE_SANDBOX_URL;
|
|
116
|
-
break;
|
|
117
|
-
default:
|
|
118
|
-
this.baseUrl = MW_BASE_LIVE_URL;
|
|
119
|
-
break;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
});
|
|
123
|
-
Object.defineProperty(APPService.prototype, "getHeaderPublicKey", {
|
|
124
|
-
enumerable: false,
|
|
125
|
-
configurable: true,
|
|
126
|
-
writable: true,
|
|
127
|
-
value: function () {
|
|
128
|
-
if (!this.env)
|
|
129
|
-
throw new Error('Environment is not set');
|
|
130
|
-
switch (this.env) {
|
|
131
|
-
case 'staging':
|
|
132
|
-
return RSA_STAGING_MW_PUBLIC_KEY;
|
|
133
|
-
case 'beta':
|
|
134
|
-
return RSA_BETA_MW_PUBLIC_KEY;
|
|
135
|
-
case 'development':
|
|
136
|
-
return RSA_DEV_MW_PUBLIC_KEY;
|
|
137
|
-
case 'sandbox':
|
|
138
|
-
return RSA_SANDBOX_MW_PUBLIC_KEY;
|
|
139
|
-
default:
|
|
140
|
-
return RSA_PRODUCTION_MW_PUBLIC_KEY;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
});
|
|
144
|
-
Object.defineProperty(APPService.prototype, "getBaseUrl", {
|
|
145
|
-
enumerable: false,
|
|
146
|
-
configurable: true,
|
|
147
|
-
writable: true,
|
|
148
|
-
value: function () {
|
|
149
|
-
return this.baseUrl;
|
|
150
|
-
}
|
|
68
|
+
});
|
|
69
|
+
export var setAxiosGlobalHeaders = function (headers) {
|
|
70
|
+
Object.entries(headers).forEach(function (_a) {
|
|
71
|
+
var key = _a[0], value = _a[1];
|
|
72
|
+
axiosInstance.defaults.headers.common[key] = value;
|
|
151
73
|
});
|
|
74
|
+
};
|
|
75
|
+
export var getAxiosGlobalHeaders = function () {
|
|
76
|
+
return __assign({}, axiosInstance.defaults.headers.common);
|
|
77
|
+
};
|
|
78
|
+
var APPService = (function () {
|
|
79
|
+
function APPService() {
|
|
80
|
+
}
|
|
152
81
|
Object.defineProperty(APPService.prototype, "setHttpHeaders", {
|
|
153
82
|
enumerable: false,
|
|
154
83
|
configurable: true,
|
|
@@ -173,7 +102,7 @@ var APPService = (function (_super) {
|
|
|
173
102
|
return __generator(this, function (_b) {
|
|
174
103
|
switch (_b.label) {
|
|
175
104
|
case 0:
|
|
176
|
-
encryptString = rsaSetup(
|
|
105
|
+
encryptString = rsaSetup(RSA_MW_PUBLIC_KEY);
|
|
177
106
|
return [4, new BrowserInfo.BrowserInfo({
|
|
178
107
|
app: { name: '@tap-payments/apple-pay-button', language: locale },
|
|
179
108
|
credentials: { mdn: domain, pk: pk },
|
|
@@ -203,7 +132,7 @@ var APPService = (function (_super) {
|
|
|
203
132
|
var data, merchant, payment_options, session;
|
|
204
133
|
return __generator(this, function (_a) {
|
|
205
134
|
switch (_a.label) {
|
|
206
|
-
case 0: return [4,
|
|
135
|
+
case 0: return [4, axiosInstance.post('/checkoutprofile', request)];
|
|
207
136
|
case 1:
|
|
208
137
|
data = (_a.sent()).data;
|
|
209
138
|
if (data.errors)
|
|
@@ -233,7 +162,7 @@ var APPService = (function (_super) {
|
|
|
233
162
|
merchantId: merchant.id,
|
|
234
163
|
merchantName: merchant.name
|
|
235
164
|
};
|
|
236
|
-
return [4,
|
|
165
|
+
return [4, axiosInstance.post('/validatemerchant', body)];
|
|
237
166
|
case 1:
|
|
238
167
|
data = (_a.sent()).data;
|
|
239
168
|
if (data.errors)
|
|
@@ -258,7 +187,7 @@ var APPService = (function (_super) {
|
|
|
258
187
|
type: 'applepay',
|
|
259
188
|
token_data: applePaymentData
|
|
260
189
|
};
|
|
261
|
-
return [4,
|
|
190
|
+
return [4, axiosInstance.post('/token', body)];
|
|
262
191
|
case 1:
|
|
263
192
|
data = (_a.sent()).data;
|
|
264
193
|
if (data.errors)
|
|
@@ -278,7 +207,7 @@ var APPService = (function (_super) {
|
|
|
278
207
|
var data;
|
|
279
208
|
return __generator(this, function (_a) {
|
|
280
209
|
switch (_a.label) {
|
|
281
|
-
case 0: return [4,
|
|
210
|
+
case 0: return [4, axiosInstance.post('/charge', request)];
|
|
282
211
|
case 1:
|
|
283
212
|
data = (_a.sent()).data;
|
|
284
213
|
if (data.errors)
|
|
@@ -298,7 +227,7 @@ var APPService = (function (_super) {
|
|
|
298
227
|
var data;
|
|
299
228
|
return __generator(this, function (_a) {
|
|
300
229
|
switch (_a.label) {
|
|
301
|
-
case 0: return [4,
|
|
230
|
+
case 0: return [4, axiosInstance.post('/authorize', request)];
|
|
302
231
|
case 1:
|
|
303
232
|
data = (_a.sent()).data;
|
|
304
233
|
if (data.errors)
|
|
@@ -310,6 +239,6 @@ var APPService = (function (_super) {
|
|
|
310
239
|
}
|
|
311
240
|
});
|
|
312
241
|
return APPService;
|
|
313
|
-
}(
|
|
242
|
+
}());
|
|
314
243
|
var appService = new APPService();
|
|
315
244
|
export default appService;
|
|
@@ -1,8 +1,3 @@
|
|
|
1
1
|
export declare const ApplePayVersion = 5;
|
|
2
|
-
export declare const
|
|
3
|
-
export declare const
|
|
4
|
-
export declare const RSA_PRODUCTION_MW_PUBLIC_KEY = "";
|
|
5
|
-
export declare const RSA_BETA_MW_PUBLIC_KEY = "-----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC9hSRms7Ir1HmzdZxGXFYgmpi3\nez7VBFje0f8wwrxYS9oVoBtN4iAt0DOs3DbeuqtueI31wtpFVUMGg8W7R0SbtkZd\nGzszQNqt/wyqxpDC9q+97XdXwkWQFA72s76ud7eMXQlsWKsvgwhY+Ywzt0KlpNC3\nHj+N6UWFOYK98Xi+sQIDAQAB\n-----END PUBLIC KEY-----";
|
|
6
|
-
export declare const RSA_STAGING_MW_PUBLIC_KEY = "-----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCi9W5jyTvA4Iwv3V5sfNQ7VdSz\n7WqwBbnWFbIUL/GjaaE93mvDv4zbgRSznHaHQPH6pxrMhMh0tV58njkvjHvQ/tvg\npwM8SemNPKEEAPl69tnMvCrJRPh2dWL3OHY8yCW4c38Hyx4fy56Zd5cdoVWfCReu\njCsvASLGz+cfRrj2swIDAQAB\n-----END PUBLIC KEY-----";
|
|
7
|
-
export declare const MW_BASE_DEV_URL = "https://mw-sdk.dev.tap.company/v2/checkout";
|
|
8
|
-
export declare const MW_BASE_BETA_URL = "https://mw-sdk.beta.tap.company/v2/checkout";
|
|
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";
|
package/build/constants/index.js
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
1
|
export var ApplePayVersion = 5;
|
|
2
|
-
export var
|
|
3
|
-
export var
|
|
4
|
-
export var RSA_PRODUCTION_MW_PUBLIC_KEY = "";
|
|
5
|
-
export var RSA_BETA_MW_PUBLIC_KEY = "-----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC9hSRms7Ir1HmzdZxGXFYgmpi3\nez7VBFje0f8wwrxYS9oVoBtN4iAt0DOs3DbeuqtueI31wtpFVUMGg8W7R0SbtkZd\nGzszQNqt/wyqxpDC9q+97XdXwkWQFA72s76ud7eMXQlsWKsvgwhY+Ywzt0KlpNC3\nHj+N6UWFOYK98Xi+sQIDAQAB\n-----END PUBLIC KEY-----";
|
|
6
|
-
export var RSA_STAGING_MW_PUBLIC_KEY = "-----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCi9W5jyTvA4Iwv3V5sfNQ7VdSz\n7WqwBbnWFbIUL/GjaaE93mvDv4zbgRSznHaHQPH6pxrMhMh0tV58njkvjHvQ/tvg\npwM8SemNPKEEAPl69tnMvCrJRPh2dWL3OHY8yCW4c38Hyx4fy56Zd5cdoVWfCReu\njCsvASLGz+cfRrj2swIDAQAB\n-----END PUBLIC KEY-----";
|
|
7
|
-
export var MW_BASE_DEV_URL = 'https://mw-sdk.dev.tap.company/v2/checkout';
|
|
8
|
-
export var MW_BASE_BETA_URL = 'https://mw-sdk.beta.tap.company/v2/checkout';
|
|
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';
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { ApplePayButtonProps, ApplePayRequestData } from '../../@types';
|
|
3
|
-
import './ApplePayButton.css';
|
|
4
3
|
export type { ApplePayButtonProps, ApplePayRequestData };
|
|
5
4
|
export declare function ApplePayButton(props: ApplePayButtonProps): JSX.Element;
|
|
6
5
|
export declare const renderApplePayButton: (props: ApplePayButtonProps, elementId: string) => any;
|
|
@@ -9,24 +9,25 @@ var __assign = (this && this.__assign) || function () {
|
|
|
9
9
|
};
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
|
-
import { jsx as _jsx
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
13
|
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
|
|
18
|
-
import './ApplePayButton.css';
|
|
19
|
-
import { StyledContainer } from './style';
|
|
20
|
-
import PayButton from '../../components/PayButton';
|
|
17
|
+
import { Locale, PayButton } from '@tap-payments/acceptance-sdk';
|
|
21
18
|
var ApplePay = React.memo(function (props) {
|
|
22
|
-
var _a, _b
|
|
23
|
-
var
|
|
19
|
+
var _a, _b;
|
|
20
|
+
var _c = useApplePay({ buttonProps: props }), onClick = _c.onClick, initialLoading = _c.initialLoading, mappedProps = _c.mappedProps, theme = _c.theme, isRounded = _c.isRounded, success = _c.success, error = _c.error, applePayPaymentMethodOptions = _c.applePayPaymentMethodOptions, profileData = _c.profileData;
|
|
24
21
|
React.useEffect(function () {
|
|
25
22
|
if (props.debug) {
|
|
26
23
|
console.log('ApplePayButtonProps', props);
|
|
27
24
|
}
|
|
28
25
|
}, []);
|
|
29
|
-
return (_jsx(
|
|
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, isFailed: error, isRounded: isRounded, isSuccess: success, onClick: onClick, buttonStyle: applePayPaymentMethodOptions === null || applePayPaymentMethodOptions === void 0 ? void 0 : applePayPaymentMethodOptions.button_style }) })));
|
|
30
31
|
});
|
|
31
32
|
export function ApplePayButton(props) {
|
|
32
33
|
return _jsx(ApplePay, __assign({}, props));
|
package/build/hooks/index.d.ts
CHANGED
package/build/hooks/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { Scope } from '../@types
|
|
2
|
-
import { ApplePayButtonProps, ApplePayDataToLunchSDKFromMerchantSide, ApplePayRequestData, MetaData } from '../@types';
|
|
1
|
+
import { ApplePayButtonProps, ApplePayDataToLunchSDKFromMerchantSide, ApplePayRequestData, MetaData, Scope } from '../@types';
|
|
3
2
|
interface UsaApplePayProps {
|
|
4
3
|
buttonProps: ApplePayButtonProps;
|
|
5
4
|
}
|
|
@@ -13,13 +12,12 @@ export declare const useApplePay: ({ buttonProps }: UsaApplePayProps) => {
|
|
|
13
12
|
applePayRequestConfiguration: Omit<ApplePayDataToLunchSDKFromMerchantSide, "applePayRequestData"> | undefined;
|
|
14
13
|
mappedProps: {
|
|
15
14
|
interface: {
|
|
16
|
-
locale?: import("
|
|
17
|
-
theme?: import("
|
|
18
|
-
edges?: import("
|
|
19
|
-
|
|
20
|
-
colorStyle?: import("../@types").ColorStyle | undefined;
|
|
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;
|
|
21
19
|
loader?: boolean | undefined;
|
|
22
|
-
};
|
|
20
|
+
} | undefined;
|
|
23
21
|
operator: {
|
|
24
22
|
publicKey: string;
|
|
25
23
|
hashstring?: string | undefined;
|
|
@@ -28,7 +26,6 @@ export declare const useApplePay: ({ buttonProps }: UsaApplePayProps) => {
|
|
|
28
26
|
id: string;
|
|
29
27
|
};
|
|
30
28
|
scope: Scope;
|
|
31
|
-
environment: import("../@types").Environment;
|
|
32
29
|
customer?: import("../@types").Customer | undefined;
|
|
33
30
|
acceptance?: import("../@types").Acceptance | undefined;
|
|
34
31
|
transaction?: {
|
|
@@ -74,7 +71,7 @@ export declare const useApplePay: ({ buttonProps }: UsaApplePayProps) => {
|
|
|
74
71
|
onReady?: (() => void) | undefined;
|
|
75
72
|
metaData?: MetaData | undefined;
|
|
76
73
|
debug?: boolean | undefined;
|
|
77
|
-
integration?: "
|
|
74
|
+
integration?: "iframe" | "sdk" | undefined;
|
|
78
75
|
headers?: {
|
|
79
76
|
mdn: string;
|
|
80
77
|
application: string;
|
|
@@ -85,8 +82,7 @@ export declare const useApplePay: ({ buttonProps }: UsaApplePayProps) => {
|
|
|
85
82
|
isRounded: boolean;
|
|
86
83
|
success: boolean;
|
|
87
84
|
error: boolean;
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
titleAsset: string | undefined;
|
|
85
|
+
applePayPaymentMethodOptions: import("../@types").PaymentMethod | null;
|
|
86
|
+
profileData: Pick<MetaData, "merchant" | "payment_options"> | undefined;
|
|
91
87
|
};
|
|
92
88
|
export {};
|
|
@@ -46,27 +46,27 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
48
|
import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
49
|
-
import
|
|
50
|
-
import { getAxiosGlobalHeaders, setAxiosGlobalHeaders } from '../api/httpClient';
|
|
51
|
-
import { ApplePayVersion } from '../constants';
|
|
52
|
-
import { CHARGE_CODE, Scope } from '../@types/enums';
|
|
49
|
+
import { ApplePayVersion, MW_BASE_URL } from '../constants';
|
|
53
50
|
import { prepareApplePayRequest, shallRenderApplePay } from '../utils/config';
|
|
51
|
+
import { Scope } from '../@types';
|
|
54
52
|
import { useMerchantApplePay } from './useMerchantApplePay';
|
|
55
|
-
import { getApplePayPaymentMethod,
|
|
53
|
+
import { getApplePayPaymentMethod, getDefaultThemeMode } from '../utils';
|
|
54
|
+
import appService, { getAxiosGlobalHeaders, setAxiosGlobalHeaders } from '../api';
|
|
55
|
+
import { ChargeCode, mapingInterface } from '@tap-payments/acceptance-sdk';
|
|
56
56
|
export var useApplePay = function (_a) {
|
|
57
|
-
var _b
|
|
57
|
+
var _b;
|
|
58
58
|
var buttonProps = _a.buttonProps;
|
|
59
|
-
var
|
|
60
|
-
var
|
|
61
|
-
var
|
|
62
|
-
var
|
|
63
|
-
var
|
|
64
|
-
var
|
|
65
|
-
var
|
|
66
|
-
var
|
|
67
|
-
var
|
|
68
|
-
var mappedProps =
|
|
69
|
-
var
|
|
59
|
+
var _c = useState(), applePayRequestData = _c[0], setApplePayRequestData = _c[1];
|
|
60
|
+
var _d = useState(), applePayRequestConfiguration = _d[0], setApplePayRequestConfiguration = _d[1];
|
|
61
|
+
var _e = useState(), profileData = _e[0], setProfile = _e[1];
|
|
62
|
+
var _f = useState(false), disabled = _f[0], setDisabled = _f[1];
|
|
63
|
+
var _g = useState(false), initialLoading = _g[0], setInitialLoading = _g[1];
|
|
64
|
+
var _h = useState(false), error = _h[0], setError = _h[1];
|
|
65
|
+
var _j = useState(false), success = _j[0], setSuccess = _j[1];
|
|
66
|
+
var _k = useState(false), loading = _k[0], setLoading = _k[1];
|
|
67
|
+
var _l = useState(false), isRounded = _l[0], setIsRounded = _l[1];
|
|
68
|
+
var mappedProps = __assign(__assign({}, buttonProps), { interface: mapingInterface(buttonProps.interface) });
|
|
69
|
+
var interfaceObj = mappedProps.interface, merchant = mappedProps.merchant, customer = mappedProps.customer, acceptance = mappedProps.acceptance, scope = mappedProps.scope, debug = mappedProps.debug, onError = mappedProps.onError, onSuccess = mappedProps.onSuccess, onCancel = mappedProps.onCancel, onReady = mappedProps.onReady, metaData = mappedProps.metaData, headers = mappedProps.headers, operator = mappedProps.operator, order = mappedProps.order, onOrderCreated = mappedProps.onOrderCreated, transaction = mappedProps.transaction, post = mappedProps.post, redirect = mappedProps.redirect;
|
|
70
70
|
var isIframeIntegration = buttonProps.integration === 'iframe';
|
|
71
71
|
useMerchantApplePay({
|
|
72
72
|
isIframeIntegration: isIframeIntegration,
|
|
@@ -85,43 +85,12 @@ export var useApplePay = function (_a) {
|
|
|
85
85
|
setSuccess: setSuccess,
|
|
86
86
|
setLoading: setLoading
|
|
87
87
|
});
|
|
88
|
-
var
|
|
89
|
-
var theme = getDefaultThemeMode((_c = mappedProps.interface) === null || _c === void 0 ? void 0 : _c.theme);
|
|
88
|
+
var theme = getDefaultThemeMode((_b = mappedProps.interface) === null || _b === void 0 ? void 0 : _b.theme);
|
|
90
89
|
var applePayPaymentMethodOptions = useMemo(function () {
|
|
91
90
|
if (!profileData)
|
|
92
91
|
return null;
|
|
93
92
|
return getApplePayPaymentMethod(profileData.payment_options.payment_methods || []);
|
|
94
93
|
}, [profileData]);
|
|
95
|
-
var gradientColor = useMemo(function () {
|
|
96
|
-
var _a, _b, _c;
|
|
97
|
-
if (!applePayPaymentMethodOptions)
|
|
98
|
-
return undefined;
|
|
99
|
-
var backgroundColor = (_a = applePayPaymentMethodOptions.button_style.background) === null || _a === void 0 ? void 0 : _a[getFullThemeMode((_b = buttonProps.interface) === null || _b === void 0 ? void 0 : _b.theme, (_c = buttonProps.interface) === null || _c === void 0 ? void 0 : _c.colorStyle)].background_colors;
|
|
100
|
-
if (backgroundColor.length > 1)
|
|
101
|
-
return "linear-gradient(-90deg,".concat(backgroundColor.join(','), ")");
|
|
102
|
-
return backgroundColor[0];
|
|
103
|
-
}, [applePayPaymentMethodOptions, buttonProps]);
|
|
104
|
-
var backgroundColor = useMemo(function () {
|
|
105
|
-
var _a, _b;
|
|
106
|
-
if (!applePayPaymentMethodOptions)
|
|
107
|
-
return undefined;
|
|
108
|
-
return applePayPaymentMethodOptions.button_style.background[getFullThemeMode((_a = buttonProps.interface) === null || _a === void 0 ? void 0 : _a.theme, (_b = buttonProps.interface) === null || _b === void 0 ? void 0 : _b.colorStyle)].base_color;
|
|
109
|
-
}, [applePayPaymentMethodOptions, buttonProps]);
|
|
110
|
-
var titleAsset = useMemo(function () {
|
|
111
|
-
var _a, _b, _c;
|
|
112
|
-
if (!applePayPaymentMethodOptions)
|
|
113
|
-
return undefined;
|
|
114
|
-
var imgSrc = (_a = profileData === null || profileData === void 0 ? void 0 : profileData.payment_options.payment_methods.find(function (method) { return method.name === applePayPaymentMethodOptions.name; })) === null || _a === void 0 ? void 0 : _a.button_style.title_asset;
|
|
115
|
-
var theme = getFullThemeMode((_b = buttonProps.interface) === null || _b === void 0 ? void 0 : _b.theme, (_c = buttonProps.interface) === null || _c === void 0 ? void 0 : _c.colorStyle);
|
|
116
|
-
var titleAsset = (imgSrc === null || imgSrc === void 0 ? void 0 : imgSrc.replace('{theme}', theme).replace('{lang}', lang)) + '.svg';
|
|
117
|
-
return titleAsset;
|
|
118
|
-
}, [
|
|
119
|
-
applePayPaymentMethodOptions,
|
|
120
|
-
lang,
|
|
121
|
-
profileData === null || profileData === void 0 ? void 0 : profileData.payment_options.payment_methods,
|
|
122
|
-
(_d = buttonProps.interface) === null || _d === void 0 ? void 0 : _d.colorStyle,
|
|
123
|
-
(_e = buttonProps.interface) === null || _e === void 0 ? void 0 : _e.theme
|
|
124
|
-
]);
|
|
125
94
|
var initialize = function (metaData) { return __awaiter(void 0, void 0, void 0, function () {
|
|
126
95
|
var merchantProfile, payment_options, headers_1, data, err_1;
|
|
127
96
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
@@ -129,8 +98,6 @@ export var useApplePay = function (_a) {
|
|
|
129
98
|
switch (_o.label) {
|
|
130
99
|
case 0:
|
|
131
100
|
setInitialLoading(true);
|
|
132
|
-
appService.setEnv(environment);
|
|
133
|
-
appService.setBaseUrl();
|
|
134
101
|
_o.label = 1;
|
|
135
102
|
case 1:
|
|
136
103
|
_o.trys.push([1, 7, , 8]);
|
|
@@ -159,7 +126,7 @@ export var useApplePay = function (_a) {
|
|
|
159
126
|
case 5: return [4, appService.checkoutProfile({
|
|
160
127
|
supported_payment_methods: ['APPLE_PAY'],
|
|
161
128
|
supported_currencies: [order.currency],
|
|
162
|
-
transaction_mode: scope
|
|
129
|
+
transaction_mode: scope === Scope.AUTHORIZE ? 'AUTHORIZE_CAPTURE' : 'PURCHASE',
|
|
163
130
|
currency: order.currency,
|
|
164
131
|
merchant_id: merchant === null || merchant === void 0 ? void 0 : merchant.id,
|
|
165
132
|
total_amount: Number(order.amount),
|
|
@@ -194,7 +161,7 @@ export var useApplePay = function (_a) {
|
|
|
194
161
|
setApplePayRequestData(prepareApplePayRequest(__assign(__assign({}, data), { order: order, acceptance: acceptance, customer: customer })));
|
|
195
162
|
onOrderCreated === null || onOrderCreated === void 0 ? void 0 : onOrderCreated((_l = (_k = data.payment_options) === null || _k === void 0 ? void 0 : _k.order) === null || _l === void 0 ? void 0 : _l.id);
|
|
196
163
|
setApplePayRequestConfiguration({
|
|
197
|
-
BASE_URL:
|
|
164
|
+
BASE_URL: MW_BASE_URL,
|
|
198
165
|
headers: getAxiosGlobalHeaders(),
|
|
199
166
|
merchant: __assign(__assign({}, data.merchant), { id: merchant.id || ((_m = data.merchant) === null || _m === void 0 ? void 0 : _m.id) })
|
|
200
167
|
});
|
|
@@ -358,7 +325,7 @@ export var useApplePay = function (_a) {
|
|
|
358
325
|
_t.label = 10;
|
|
359
326
|
case 10:
|
|
360
327
|
transactionResponse = _b;
|
|
361
|
-
successState = scope === Scope.AUTHORIZE ?
|
|
328
|
+
successState = scope === Scope.AUTHORIZE ? ChargeCode.AUTHORIZED : ChargeCode.SUCCESS;
|
|
362
329
|
if ((transactionResponse === null || transactionResponse === void 0 ? void 0 : transactionResponse.response.code) === successState) {
|
|
363
330
|
setSuccess === null || setSuccess === void 0 ? void 0 : setSuccess(true);
|
|
364
331
|
}
|
|
@@ -453,8 +420,7 @@ export var useApplePay = function (_a) {
|
|
|
453
420
|
isRounded: isRounded,
|
|
454
421
|
success: success,
|
|
455
422
|
error: error,
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
titleAsset: titleAsset
|
|
423
|
+
applePayPaymentMethodOptions: applePayPaymentMethodOptions,
|
|
424
|
+
profileData: profileData
|
|
459
425
|
};
|
|
460
426
|
};
|
|
@@ -35,7 +35,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
37
|
import * as React from 'react';
|
|
38
|
-
import appService from '../api
|
|
38
|
+
import appService from '../api';
|
|
39
39
|
import { Scope, CHARGE_CODE } from '../@types';
|
|
40
40
|
var EVENT_NAME = 'TAP_BUTTON::APPLE_PAY_ON_PAYMENT_AUTHORIZED';
|
|
41
41
|
export var useMerchantApplePay = function (_a) {
|
|
@@ -138,7 +138,7 @@ export var useMerchantApplePay = function (_a) {
|
|
|
138
138
|
return [3, 12];
|
|
139
139
|
case 11:
|
|
140
140
|
console.error("We only support: ".concat(Object.values(Scope).join(', '), " for now"));
|
|
141
|
-
onError === null || onError === void 0 ? void 0 : onError({ message: "We only support: ".concat(Object.values(Scope).join(', '), " for now"), code: '
|
|
141
|
+
onError === null || onError === void 0 ? void 0 : onError({ message: "We only support: ".concat(Object.values(Scope).join(', '), " for now"), code: '000' });
|
|
142
142
|
return [3, 12];
|
|
143
143
|
case 12: return [3, 15];
|
|
144
144
|
case 13:
|
package/build/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { ApplePayButtonProps, ApplePayButton, ApplePayRequestData } from './features/ApplePayButton';
|
|
2
|
-
import { ThemeMode, Scope, SupportedNetworks,
|
|
2
|
+
import { ThemeMode, Scope, SupportedNetworks, Locale, ButtonType, Edges, MerchantCapabilities } from './@types/enums';
|
|
3
3
|
export type { ApplePayButtonProps, ApplePayRequestData };
|
|
4
|
-
export { ApplePayButton, ThemeMode, Scope, SupportedNetworks,
|
|
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
|
@@ -7,7 +7,5 @@ export declare const getApplePayRequest: ({ order, customer, supportedNetworks,
|
|
|
7
7
|
countryCode: string;
|
|
8
8
|
name: string;
|
|
9
9
|
}) => ApplePayRequestData;
|
|
10
|
-
export declare const rsaSetup: (key: string) => (string: string) => string;
|
|
11
|
-
export declare function generateApplicationHeader(obj: Record<string, string | any>): string;
|
|
12
10
|
export declare const prepareApplePayRequest: ({ payment_options, merchant, order, customer, acceptance }: Pick<MetaData, 'merchant' | 'payment_options'> & Pick<ApplePayButtonProps, 'order' | 'customer' | 'acceptance'>) => ApplePayRequestData;
|
|
13
11
|
export declare const shallRenderApplePay: () => boolean;
|