@tap-payments/apple-pay-button 0.0.90-development → 0.0.92-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/LICENSE +21 -21
- package/README.md +240 -240
- package/build/@types/ApplePayButtonProps.d.ts +56 -56
- package/build/@types/ApplePayButtonProps.js +1 -1
- package/build/@types/charge.d.ts +56 -56
- package/build/@types/charge.js +1 -1
- package/build/@types/checkoutProfile.d.ts +216 -216
- package/build/@types/checkoutProfile.js +1 -1
- package/build/@types/enums.d.ts +44 -45
- package/build/@types/enums.js +51 -52
- package/build/@types/index.d.ts +6 -6
- package/build/@types/index.js +6 -6
- package/build/@types/tapLocalisation.d.ts +193 -193
- package/build/@types/tapLocalisation.js +1 -1
- package/build/@types/tapTheme.d.ts +842 -842
- package/build/@types/tapTheme.js +1 -1
- package/build/api.d.ts +31 -31
- package/build/api.js +236 -236
- package/build/constants/index.d.ts +3 -3
- package/build/constants/index.js +3 -3
- package/build/features/ApplePayButton/ApplePayButton.d.ts +4 -4
- package/build/features/ApplePayButton/ApplePayButton.js +48 -48
- package/build/features/ApplePayButton/index.d.ts +3 -3
- package/build/features/ApplePayButton/index.js +2 -2
- package/build/hooks/index.d.ts +1 -1
- package/build/hooks/index.js +1 -1
- package/build/hooks/useApplePay.d.ts +81 -81
- package/build/hooks/useApplePay.js +424 -425
- package/build/hooks/useMerchantApplePay.d.ts +22 -22
- package/build/hooks/useMerchantApplePay.js +190 -190
- package/build/index.d.ts +5 -5
- package/build/index.js +14 -14
- package/build/utils/config.d.ts +14 -14
- package/build/utils/config.js +59 -57
- package/build/utils/defaultValues.d.ts +2 -2
- package/build/utils/defaultValues.js +27 -27
- package/build/utils/index.d.ts +3 -3
- package/build/utils/index.js +3 -3
- package/build/utils/theme.d.ts +13 -13
- package/build/utils/theme.js +62 -62
- package/package.json +109 -109
package/build/@types/tapTheme.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
package/build/api.d.ts
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import { CheckoutProfileRequest, ChargeRequestBody, AuthorizeRequestBody, MerchantValidationRequestData } from './@types';
|
|
2
|
-
export declare const setAxiosGlobalHeaders: (headers: {
|
|
3
|
-
[x: string]: string | undefined;
|
|
4
|
-
}) => void;
|
|
5
|
-
export declare const getAxiosGlobalHeaders: () => {
|
|
6
|
-
[x: string]: import("axios").AxiosHeaderValue | undefined;
|
|
7
|
-
Accept?: import("axios").AxiosHeaderValue | undefined;
|
|
8
|
-
"Content-Length"?: import("axios").AxiosHeaderValue | undefined;
|
|
9
|
-
"User-Agent"?: import("axios").AxiosHeaderValue | undefined;
|
|
10
|
-
"Content-Encoding"?: import("axios").AxiosHeaderValue | undefined;
|
|
11
|
-
Authorization?: import("axios").AxiosHeaderValue | undefined;
|
|
12
|
-
'Content-Type'?: import("axios").AxiosHeaderValue | undefined;
|
|
13
|
-
};
|
|
14
|
-
declare class APPService {
|
|
15
|
-
setHttpHeaders(headers: Record<string, string>): Promise<void>;
|
|
16
|
-
setBrowserHeaders({ locale, pk, domain }: {
|
|
17
|
-
locale: string;
|
|
18
|
-
pk: string;
|
|
19
|
-
domain: string;
|
|
20
|
-
}): Promise<void>;
|
|
21
|
-
checkoutProfile(request: CheckoutProfileRequest): Promise<{
|
|
22
|
-
merchant: any;
|
|
23
|
-
payment_options: any;
|
|
24
|
-
}>;
|
|
25
|
-
appleSession(body: MerchantValidationRequestData): Promise<any>;
|
|
26
|
-
tapTokenization(applePaymentData: Record<string, string>): Promise<any>;
|
|
27
|
-
createCharge(request: ChargeRequestBody): Promise<any>;
|
|
28
|
-
createAuthorize(request: AuthorizeRequestBody): Promise<any>;
|
|
29
|
-
}
|
|
30
|
-
declare const appService: APPService;
|
|
31
|
-
export default appService;
|
|
1
|
+
import { CheckoutProfileRequest, ChargeRequestBody, AuthorizeRequestBody, MerchantValidationRequestData } from './@types';
|
|
2
|
+
export declare const setAxiosGlobalHeaders: (headers: {
|
|
3
|
+
[x: string]: string | undefined;
|
|
4
|
+
}) => void;
|
|
5
|
+
export declare const getAxiosGlobalHeaders: () => {
|
|
6
|
+
[x: string]: import("axios").AxiosHeaderValue | undefined;
|
|
7
|
+
Accept?: import("axios").AxiosHeaderValue | undefined;
|
|
8
|
+
"Content-Length"?: import("axios").AxiosHeaderValue | undefined;
|
|
9
|
+
"User-Agent"?: import("axios").AxiosHeaderValue | undefined;
|
|
10
|
+
"Content-Encoding"?: import("axios").AxiosHeaderValue | undefined;
|
|
11
|
+
Authorization?: import("axios").AxiosHeaderValue | undefined;
|
|
12
|
+
'Content-Type'?: import("axios").AxiosHeaderValue | undefined;
|
|
13
|
+
};
|
|
14
|
+
declare class APPService {
|
|
15
|
+
setHttpHeaders(headers: Record<string, string>): Promise<void>;
|
|
16
|
+
setBrowserHeaders({ locale, pk, domain }: {
|
|
17
|
+
locale: string;
|
|
18
|
+
pk: string;
|
|
19
|
+
domain: string;
|
|
20
|
+
}): Promise<void>;
|
|
21
|
+
checkoutProfile(request: CheckoutProfileRequest): Promise<{
|
|
22
|
+
merchant: any;
|
|
23
|
+
payment_options: any;
|
|
24
|
+
}>;
|
|
25
|
+
appleSession(body: MerchantValidationRequestData): Promise<any>;
|
|
26
|
+
tapTokenization(applePaymentData: Record<string, string>): Promise<any>;
|
|
27
|
+
createCharge(request: ChargeRequestBody): Promise<any>;
|
|
28
|
+
createAuthorize(request: AuthorizeRequestBody): Promise<any>;
|
|
29
|
+
}
|
|
30
|
+
declare const appService: APPService;
|
|
31
|
+
export default appService;
|
package/build/api.js
CHANGED
|
@@ -1,236 +1,236 @@
|
|
|
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
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
23
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
-
function step(op) {
|
|
26
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
28
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
29
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
-
switch (op[0]) {
|
|
31
|
-
case 0: case 1: t = op; break;
|
|
32
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
-
default:
|
|
36
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
-
if (t[2]) _.ops.pop();
|
|
41
|
-
_.trys.pop(); continue;
|
|
42
|
-
}
|
|
43
|
-
op = body.call(thisArg, _);
|
|
44
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
49
|
-
var t = {};
|
|
50
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
51
|
-
t[p] = s[p];
|
|
52
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
53
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
54
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
55
|
-
t[p[i]] = s[p[i]];
|
|
56
|
-
}
|
|
57
|
-
return t;
|
|
58
|
-
};
|
|
59
|
-
import BrowserInfo from '@tap-payments/browser-info';
|
|
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'
|
|
67
|
-
}
|
|
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;
|
|
73
|
-
});
|
|
74
|
-
};
|
|
75
|
-
export var getAxiosGlobalHeaders = function () {
|
|
76
|
-
return __assign({}, axiosInstance.defaults.headers.common);
|
|
77
|
-
};
|
|
78
|
-
var APPService = (function () {
|
|
79
|
-
function APPService() {
|
|
80
|
-
}
|
|
81
|
-
Object.defineProperty(APPService.prototype, "setHttpHeaders", {
|
|
82
|
-
enumerable: false,
|
|
83
|
-
configurable: true,
|
|
84
|
-
writable: true,
|
|
85
|
-
value: function (headers) {
|
|
86
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
87
|
-
return __generator(this, function (_a) {
|
|
88
|
-
setAxiosGlobalHeaders(headers);
|
|
89
|
-
return [2];
|
|
90
|
-
});
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
Object.defineProperty(APPService.prototype, "setBrowserHeaders", {
|
|
95
|
-
enumerable: false,
|
|
96
|
-
configurable: true,
|
|
97
|
-
writable: true,
|
|
98
|
-
value: function (_a) {
|
|
99
|
-
var locale = _a.locale, pk = _a.pk, domain = _a.domain;
|
|
100
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
101
|
-
var encryptString, encryptedHeaders, mdn, authorization, rest, application;
|
|
102
|
-
return __generator(this, function (_b) {
|
|
103
|
-
switch (_b.label) {
|
|
104
|
-
case 0:
|
|
105
|
-
encryptString = rsaSetup(RSA_MW_PUBLIC_KEY);
|
|
106
|
-
return [4, new BrowserInfo.BrowserInfo({
|
|
107
|
-
app: { name: '@tap-payments/apple-pay-button', language: locale },
|
|
108
|
-
credentials: { mdn: domain, pk: pk },
|
|
109
|
-
encrypt: function (_key, value) { return encryptString(value.substring(0, 115)); }
|
|
110
|
-
}).get()];
|
|
111
|
-
case 1:
|
|
112
|
-
encryptedHeaders = _b.sent();
|
|
113
|
-
mdn = encryptedHeaders.mdn, authorization = encryptedHeaders.authorization, rest = __rest(encryptedHeaders, ["mdn", "authorization"]);
|
|
114
|
-
application = generateApplicationHeader(rest);
|
|
115
|
-
setAxiosGlobalHeaders({
|
|
116
|
-
authorization: pk,
|
|
117
|
-
mdn: mdn,
|
|
118
|
-
application: application
|
|
119
|
-
});
|
|
120
|
-
return [2];
|
|
121
|
-
}
|
|
122
|
-
});
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
Object.defineProperty(APPService.prototype, "checkoutProfile", {
|
|
127
|
-
enumerable: false,
|
|
128
|
-
configurable: true,
|
|
129
|
-
writable: true,
|
|
130
|
-
value: function (request) {
|
|
131
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
132
|
-
var data, merchant, payment_options, session;
|
|
133
|
-
return __generator(this, function (_a) {
|
|
134
|
-
switch (_a.label) {
|
|
135
|
-
case 0: return [4, axiosInstance.post('/checkoutprofile', request)];
|
|
136
|
-
case 1:
|
|
137
|
-
data = (_a.sent()).data;
|
|
138
|
-
if (data.errors)
|
|
139
|
-
throw data;
|
|
140
|
-
merchant = data.merchant, payment_options = data.payment_options, session = data.session;
|
|
141
|
-
setAxiosGlobalHeaders({ session: session });
|
|
142
|
-
return [2, { merchant: merchant, payment_options: payment_options }];
|
|
143
|
-
}
|
|
144
|
-
});
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
});
|
|
148
|
-
Object.defineProperty(APPService.prototype, "appleSession", {
|
|
149
|
-
enumerable: false,
|
|
150
|
-
configurable: true,
|
|
151
|
-
writable: true,
|
|
152
|
-
value: function (body) {
|
|
153
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
154
|
-
var data;
|
|
155
|
-
return __generator(this, function (_a) {
|
|
156
|
-
switch (_a.label) {
|
|
157
|
-
case 0: return [4, axiosInstance.post('/validatemerchant', body)];
|
|
158
|
-
case 1:
|
|
159
|
-
data = (_a.sent()).data;
|
|
160
|
-
if (data.errors)
|
|
161
|
-
throw data;
|
|
162
|
-
return [2, data];
|
|
163
|
-
}
|
|
164
|
-
});
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
});
|
|
168
|
-
Object.defineProperty(APPService.prototype, "tapTokenization", {
|
|
169
|
-
enumerable: false,
|
|
170
|
-
configurable: true,
|
|
171
|
-
writable: true,
|
|
172
|
-
value: function (applePaymentData) {
|
|
173
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
174
|
-
var body, data;
|
|
175
|
-
return __generator(this, function (_a) {
|
|
176
|
-
switch (_a.label) {
|
|
177
|
-
case 0:
|
|
178
|
-
body = {
|
|
179
|
-
type: 'applepay',
|
|
180
|
-
token_data: applePaymentData
|
|
181
|
-
};
|
|
182
|
-
return [4, axiosInstance.post('/token', body)];
|
|
183
|
-
case 1:
|
|
184
|
-
data = (_a.sent()).data;
|
|
185
|
-
if (data.errors)
|
|
186
|
-
throw data;
|
|
187
|
-
return [2, data];
|
|
188
|
-
}
|
|
189
|
-
});
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
|
-
});
|
|
193
|
-
Object.defineProperty(APPService.prototype, "createCharge", {
|
|
194
|
-
enumerable: false,
|
|
195
|
-
configurable: true,
|
|
196
|
-
writable: true,
|
|
197
|
-
value: function (request) {
|
|
198
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
199
|
-
var data;
|
|
200
|
-
return __generator(this, function (_a) {
|
|
201
|
-
switch (_a.label) {
|
|
202
|
-
case 0: return [4, axiosInstance.post('/charge', request)];
|
|
203
|
-
case 1:
|
|
204
|
-
data = (_a.sent()).data;
|
|
205
|
-
if (data.errors)
|
|
206
|
-
throw data;
|
|
207
|
-
return [2, data];
|
|
208
|
-
}
|
|
209
|
-
});
|
|
210
|
-
});
|
|
211
|
-
}
|
|
212
|
-
});
|
|
213
|
-
Object.defineProperty(APPService.prototype, "createAuthorize", {
|
|
214
|
-
enumerable: false,
|
|
215
|
-
configurable: true,
|
|
216
|
-
writable: true,
|
|
217
|
-
value: function (request) {
|
|
218
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
219
|
-
var data;
|
|
220
|
-
return __generator(this, function (_a) {
|
|
221
|
-
switch (_a.label) {
|
|
222
|
-
case 0: return [4, axiosInstance.post('/authorize', request)];
|
|
223
|
-
case 1:
|
|
224
|
-
data = (_a.sent()).data;
|
|
225
|
-
if (data.errors)
|
|
226
|
-
throw data;
|
|
227
|
-
return [2, data];
|
|
228
|
-
}
|
|
229
|
-
});
|
|
230
|
-
});
|
|
231
|
-
}
|
|
232
|
-
});
|
|
233
|
-
return APPService;
|
|
234
|
-
}());
|
|
235
|
-
var appService = new APPService();
|
|
236
|
-
export default appService;
|
|
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
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
23
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
+
function step(op) {
|
|
26
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
28
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
29
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
+
switch (op[0]) {
|
|
31
|
+
case 0: case 1: t = op; break;
|
|
32
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
+
default:
|
|
36
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
+
if (t[2]) _.ops.pop();
|
|
41
|
+
_.trys.pop(); continue;
|
|
42
|
+
}
|
|
43
|
+
op = body.call(thisArg, _);
|
|
44
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
49
|
+
var t = {};
|
|
50
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
51
|
+
t[p] = s[p];
|
|
52
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
53
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
54
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
55
|
+
t[p[i]] = s[p[i]];
|
|
56
|
+
}
|
|
57
|
+
return t;
|
|
58
|
+
};
|
|
59
|
+
import BrowserInfo from '@tap-payments/browser-info';
|
|
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'
|
|
67
|
+
}
|
|
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;
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
export var getAxiosGlobalHeaders = function () {
|
|
76
|
+
return __assign({}, axiosInstance.defaults.headers.common);
|
|
77
|
+
};
|
|
78
|
+
var APPService = (function () {
|
|
79
|
+
function APPService() {
|
|
80
|
+
}
|
|
81
|
+
Object.defineProperty(APPService.prototype, "setHttpHeaders", {
|
|
82
|
+
enumerable: false,
|
|
83
|
+
configurable: true,
|
|
84
|
+
writable: true,
|
|
85
|
+
value: function (headers) {
|
|
86
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
87
|
+
return __generator(this, function (_a) {
|
|
88
|
+
setAxiosGlobalHeaders(headers);
|
|
89
|
+
return [2];
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
Object.defineProperty(APPService.prototype, "setBrowserHeaders", {
|
|
95
|
+
enumerable: false,
|
|
96
|
+
configurable: true,
|
|
97
|
+
writable: true,
|
|
98
|
+
value: function (_a) {
|
|
99
|
+
var locale = _a.locale, pk = _a.pk, domain = _a.domain;
|
|
100
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
101
|
+
var encryptString, encryptedHeaders, mdn, authorization, rest, application;
|
|
102
|
+
return __generator(this, function (_b) {
|
|
103
|
+
switch (_b.label) {
|
|
104
|
+
case 0:
|
|
105
|
+
encryptString = rsaSetup(RSA_MW_PUBLIC_KEY);
|
|
106
|
+
return [4, new BrowserInfo.BrowserInfo({
|
|
107
|
+
app: { name: '@tap-payments/apple-pay-button', language: locale },
|
|
108
|
+
credentials: { mdn: domain, pk: pk },
|
|
109
|
+
encrypt: function (_key, value) { return encryptString(value.substring(0, 115)); }
|
|
110
|
+
}).get()];
|
|
111
|
+
case 1:
|
|
112
|
+
encryptedHeaders = _b.sent();
|
|
113
|
+
mdn = encryptedHeaders.mdn, authorization = encryptedHeaders.authorization, rest = __rest(encryptedHeaders, ["mdn", "authorization"]);
|
|
114
|
+
application = generateApplicationHeader(rest);
|
|
115
|
+
setAxiosGlobalHeaders({
|
|
116
|
+
authorization: pk,
|
|
117
|
+
mdn: mdn,
|
|
118
|
+
application: application
|
|
119
|
+
});
|
|
120
|
+
return [2];
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
Object.defineProperty(APPService.prototype, "checkoutProfile", {
|
|
127
|
+
enumerable: false,
|
|
128
|
+
configurable: true,
|
|
129
|
+
writable: true,
|
|
130
|
+
value: function (request) {
|
|
131
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
132
|
+
var data, merchant, payment_options, session;
|
|
133
|
+
return __generator(this, function (_a) {
|
|
134
|
+
switch (_a.label) {
|
|
135
|
+
case 0: return [4, axiosInstance.post('/checkoutprofile', request)];
|
|
136
|
+
case 1:
|
|
137
|
+
data = (_a.sent()).data;
|
|
138
|
+
if (data.errors)
|
|
139
|
+
throw data;
|
|
140
|
+
merchant = data.merchant, payment_options = data.payment_options, session = data.session;
|
|
141
|
+
setAxiosGlobalHeaders({ session: session });
|
|
142
|
+
return [2, { merchant: merchant, payment_options: payment_options }];
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
Object.defineProperty(APPService.prototype, "appleSession", {
|
|
149
|
+
enumerable: false,
|
|
150
|
+
configurable: true,
|
|
151
|
+
writable: true,
|
|
152
|
+
value: function (body) {
|
|
153
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
154
|
+
var data;
|
|
155
|
+
return __generator(this, function (_a) {
|
|
156
|
+
switch (_a.label) {
|
|
157
|
+
case 0: return [4, axiosInstance.post('/validatemerchant', body)];
|
|
158
|
+
case 1:
|
|
159
|
+
data = (_a.sent()).data;
|
|
160
|
+
if (data.errors)
|
|
161
|
+
throw data;
|
|
162
|
+
return [2, data];
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
Object.defineProperty(APPService.prototype, "tapTokenization", {
|
|
169
|
+
enumerable: false,
|
|
170
|
+
configurable: true,
|
|
171
|
+
writable: true,
|
|
172
|
+
value: function (applePaymentData) {
|
|
173
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
174
|
+
var body, data;
|
|
175
|
+
return __generator(this, function (_a) {
|
|
176
|
+
switch (_a.label) {
|
|
177
|
+
case 0:
|
|
178
|
+
body = {
|
|
179
|
+
type: 'applepay',
|
|
180
|
+
token_data: applePaymentData
|
|
181
|
+
};
|
|
182
|
+
return [4, axiosInstance.post('/token', body)];
|
|
183
|
+
case 1:
|
|
184
|
+
data = (_a.sent()).data;
|
|
185
|
+
if (data.errors)
|
|
186
|
+
throw data;
|
|
187
|
+
return [2, data];
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
Object.defineProperty(APPService.prototype, "createCharge", {
|
|
194
|
+
enumerable: false,
|
|
195
|
+
configurable: true,
|
|
196
|
+
writable: true,
|
|
197
|
+
value: function (request) {
|
|
198
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
199
|
+
var data;
|
|
200
|
+
return __generator(this, function (_a) {
|
|
201
|
+
switch (_a.label) {
|
|
202
|
+
case 0: return [4, axiosInstance.post('/charge', request)];
|
|
203
|
+
case 1:
|
|
204
|
+
data = (_a.sent()).data;
|
|
205
|
+
if (data.errors)
|
|
206
|
+
throw data;
|
|
207
|
+
return [2, data];
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
Object.defineProperty(APPService.prototype, "createAuthorize", {
|
|
214
|
+
enumerable: false,
|
|
215
|
+
configurable: true,
|
|
216
|
+
writable: true,
|
|
217
|
+
value: function (request) {
|
|
218
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
219
|
+
var data;
|
|
220
|
+
return __generator(this, function (_a) {
|
|
221
|
+
switch (_a.label) {
|
|
222
|
+
case 0: return [4, axiosInstance.post('/authorize', request)];
|
|
223
|
+
case 1:
|
|
224
|
+
data = (_a.sent()).data;
|
|
225
|
+
if (data.errors)
|
|
226
|
+
throw data;
|
|
227
|
+
return [2, data];
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
return APPService;
|
|
234
|
+
}());
|
|
235
|
+
var appService = new APPService();
|
|
236
|
+
export default appService;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
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";
|
|
1
|
+
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";
|
package/build/constants/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
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';
|
|
1
|
+
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';
|
|
@@ -1,4 +1,4 @@
|
|
|
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
|
+
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;
|