@tap-payments/apple-pay-button 0.0.93-development → 0.0.95-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.
Files changed (41) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +240 -240
  3. package/build/@types/ApplePayButtonProps.d.ts +56 -56
  4. package/build/@types/ApplePayButtonProps.js +1 -1
  5. package/build/@types/checkoutProfile.d.ts +216 -216
  6. package/build/@types/checkoutProfile.js +1 -1
  7. package/build/@types/enums.d.ts +44 -44
  8. package/build/@types/enums.js +51 -51
  9. package/build/@types/index.d.ts +5 -6
  10. package/build/@types/index.js +5 -6
  11. package/build/@types/tapLocalisation.d.ts +193 -193
  12. package/build/@types/tapLocalisation.js +1 -1
  13. package/build/@types/tapTheme.d.ts +842 -842
  14. package/build/@types/tapTheme.js +1 -1
  15. package/build/api.d.ts +7 -31
  16. package/build/api.js +84 -236
  17. package/build/constants/index.d.ts +4 -4
  18. package/build/constants/index.js +4 -4
  19. package/build/features/ApplePayButton/ApplePayButton.d.ts +4 -4
  20. package/build/features/ApplePayButton/ApplePayButton.js +48 -48
  21. package/build/features/ApplePayButton/index.d.ts +3 -3
  22. package/build/features/ApplePayButton/index.js +2 -2
  23. package/build/hooks/index.d.ts +1 -1
  24. package/build/hooks/index.js +1 -1
  25. package/build/hooks/useApplePay.d.ts +84 -81
  26. package/build/hooks/useApplePay.js +402 -425
  27. package/build/hooks/useMerchantApplePay.d.ts +22 -22
  28. package/build/hooks/useMerchantApplePay.js +167 -190
  29. package/build/index.d.ts +5 -5
  30. package/build/index.js +14 -14
  31. package/build/utils/config.d.ts +14 -14
  32. package/build/utils/config.js +59 -59
  33. package/build/utils/defaultValues.d.ts +2 -2
  34. package/build/utils/defaultValues.js +27 -27
  35. package/build/utils/index.d.ts +3 -3
  36. package/build/utils/index.js +3 -3
  37. package/build/utils/theme.d.ts +13 -13
  38. package/build/utils/theme.js +62 -62
  39. package/package.json +109 -109
  40. package/build/@types/charge.d.ts +0 -56
  41. package/build/@types/charge.js +0 -1
@@ -1 +1 @@
1
- export {};
1
+ export {};
package/build/api.d.ts CHANGED
@@ -1,31 +1,7 @@
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 { MerchantValidationRequestData } from './@types';
2
+ import { CheckoutService as CheckoutServiceBase } from '@tap-payments/acceptance-sdk';
3
+ declare class CheckoutService extends CheckoutServiceBase {
4
+ appleSession(body: MerchantValidationRequestData): Promise<any>;
5
+ }
6
+ export declare const checkoutService: CheckoutService;
7
+ export {};
package/build/api.js CHANGED
@@ -1,236 +1,84 @@
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 __extends = (this && this.__extends) || (function () {
2
+ var extendStatics = function (d, b) {
3
+ extendStatics = Object.setPrototypeOf ||
4
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6
+ return extendStatics(d, b);
7
+ };
8
+ return function (d, b) {
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 __());
14
+ };
15
+ })();
16
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
17
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
18
+ return new (P || (P = Promise))(function (resolve, reject) {
19
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
20
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
21
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
22
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
23
+ });
24
+ };
25
+ var __generator = (this && this.__generator) || function (thisArg, body) {
26
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
27
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
28
+ function verb(n) { return function (v) { return step([n, v]); }; }
29
+ function step(op) {
30
+ if (f) throw new TypeError("Generator is already executing.");
31
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
32
+ 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;
33
+ if (y = 0, t) op = [op[0] & 2, t.value];
34
+ switch (op[0]) {
35
+ case 0: case 1: t = op; break;
36
+ case 4: _.label++; return { value: op[1], done: false };
37
+ case 5: _.label++; y = op[1]; op = [0]; continue;
38
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
39
+ default:
40
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
41
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
42
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
43
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
44
+ if (t[2]) _.ops.pop();
45
+ _.trys.pop(); continue;
46
+ }
47
+ op = body.call(thisArg, _);
48
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
49
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
50
+ }
51
+ };
52
+ import { RSA_MW_PUBLIC_KEY } from './constants';
53
+ import { CheckoutService as CheckoutServiceBase } from '@tap-payments/acceptance-sdk';
54
+ var CheckoutService = (function (_super) {
55
+ __extends(CheckoutService, _super);
56
+ function CheckoutService() {
57
+ return _super !== null && _super.apply(this, arguments) || this;
58
+ }
59
+ Object.defineProperty(CheckoutService.prototype, "appleSession", {
60
+ enumerable: false,
61
+ configurable: true,
62
+ writable: true,
63
+ value: function (body) {
64
+ return __awaiter(this, void 0, void 0, function () {
65
+ var data;
66
+ return __generator(this, function (_a) {
67
+ switch (_a.label) {
68
+ case 0: return [4, this.axiosInstance.post('/validatemerchant', body)];
69
+ case 1:
70
+ data = (_a.sent()).data;
71
+ if (data.errors)
72
+ throw data;
73
+ return [2, data];
74
+ }
75
+ });
76
+ });
77
+ }
78
+ });
79
+ return CheckoutService;
80
+ }(CheckoutServiceBase));
81
+ export var checkoutService = new CheckoutService({
82
+ rsaMWPublicKey: RSA_MW_PUBLIC_KEY,
83
+ sdkName: '@tap-payments/apple-pay-button'
84
+ });
@@ -1,4 +1,4 @@
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";
4
- export declare const APPLE_PAY_SCRIPT = "https://applepay.cdn-apple.com/jsapi/1.latest/apple-pay-sdk.js";
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";
4
+ export declare const APPLE_PAY_SCRIPT = "https://applepay.cdn-apple.com/jsapi/1.latest/apple-pay-sdk.js";
@@ -1,4 +1,4 @@
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';
4
- export var APPLE_PAY_SCRIPT = 'https://applepay.cdn-apple.com/jsapi/1.latest/apple-pay-sdk.js';
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';
4
+ export var APPLE_PAY_SCRIPT = 'https://applepay.cdn-apple.com/jsapi/1.latest/apple-pay-sdk.js';
@@ -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;
@@ -1,48 +1,48 @@
1
- var __assign = (this && this.__assign) || function () {
2
- __assign = Object.assign || function(t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
- t[p] = s[p];
7
- }
8
- return t;
9
- };
10
- return __assign.apply(this, arguments);
11
- };
12
- import { jsx as _jsx } from "react/jsx-runtime";
13
- import * as React from 'react';
14
- import { createRoot } from 'react-dom/client';
15
- import { useApplePay } from '../../hooks/useApplePay';
16
- import { findOrCreateElementAndInject, Locale, PayButton } from '@tap-payments/acceptance-sdk';
17
- var ApplePay = React.memo(function (props) {
18
- var _a, _b, _c;
19
- var _d = useApplePay({ buttonProps: props }), onClick = _d.onClick, mappedProps = _d.mappedProps, theme = _d.theme, isRounded = _d.isRounded, success = _d.success, error = _d.error, applePayPaymentMethodOptions = _d.applePayPaymentMethodOptions, profileData = _d.profileData;
20
- React.useEffect(function () {
21
- if (props.debug) {
22
- console.log('ApplePayButtonProps', props);
23
- }
24
- }, []);
25
- return (_jsx("div", __assign({ style: {
26
- width: '100%',
27
- display: 'flex',
28
- justifyContent: 'center'
29
- } }, { children: _jsx(PayButton, { shimmerLoader: !profileData || !applePayPaymentMethodOptions, locale: ((_a = mappedProps.interface) === null || _a === void 0 ? void 0 : _a.locale) || Locale.EN, theme: theme, edges: (_b = mappedProps.interface) === null || _b === void 0 ? void 0 : _b.edges, colorStyle: (_c = mappedProps.interface) === null || _c === void 0 ? void 0 : _c.colorStyle, isFailed: error, isRounded: isRounded, isSuccess: success, onClick: onClick, buttonStyle: applePayPaymentMethodOptions === null || applePayPaymentMethodOptions === void 0 ? void 0 : applePayPaymentMethodOptions.button_style }) })));
30
- });
31
- export function ApplePayButton(props) {
32
- return _jsx(ApplePay, __assign({}, props));
33
- }
34
- var tapConnectInstance = null;
35
- export var renderApplePayButton = function (props, elementId) {
36
- if (tapConnectInstance) {
37
- return tapConnectInstance;
38
- }
39
- var el = findOrCreateElementAndInject(elementId);
40
- var root = createRoot(el);
41
- root.render(_jsx(ApplePayButton, __assign({}, props)));
42
- var unmount = function () {
43
- root.unmount();
44
- tapConnectInstance = null;
45
- };
46
- tapConnectInstance = { unmount: unmount };
47
- return tapConnectInstance;
48
- };
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ import * as React from 'react';
14
+ import { createRoot } from 'react-dom/client';
15
+ import { useApplePay } from '../../hooks/useApplePay';
16
+ import { findOrCreateElementAndInject, Locale, PayButton } from '@tap-payments/acceptance-sdk';
17
+ var ApplePay = React.memo(function (props) {
18
+ var _a, _b, _c;
19
+ var _d = useApplePay({ buttonProps: props }), onClick = _d.onClick, mappedProps = _d.mappedProps, theme = _d.theme, isRounded = _d.isRounded, success = _d.success, error = _d.error, applePayPaymentMethodOptions = _d.applePayPaymentMethodOptions, profileData = _d.profileData;
20
+ React.useEffect(function () {
21
+ if (props.debug) {
22
+ console.log('ApplePayButtonProps', props);
23
+ }
24
+ }, []);
25
+ return (_jsx("div", __assign({ style: {
26
+ width: '100%',
27
+ display: 'flex',
28
+ justifyContent: 'center'
29
+ } }, { children: _jsx(PayButton, { shimmerLoader: !profileData || !applePayPaymentMethodOptions, locale: ((_a = mappedProps.interface) === null || _a === void 0 ? void 0 : _a.locale) || Locale.EN, theme: theme, edges: (_b = mappedProps.interface) === null || _b === void 0 ? void 0 : _b.edges, colorStyle: (_c = mappedProps.interface) === null || _c === void 0 ? void 0 : _c.colorStyle, isFailed: error, isRounded: isRounded, isSuccess: success, onClick: onClick, buttonStyle: applePayPaymentMethodOptions === null || applePayPaymentMethodOptions === void 0 ? void 0 : applePayPaymentMethodOptions.button_style }) })));
30
+ });
31
+ export function ApplePayButton(props) {
32
+ return _jsx(ApplePay, __assign({}, props));
33
+ }
34
+ var tapConnectInstance = null;
35
+ export var renderApplePayButton = function (props, elementId) {
36
+ if (tapConnectInstance) {
37
+ return tapConnectInstance;
38
+ }
39
+ var el = findOrCreateElementAndInject(elementId);
40
+ var root = createRoot(el);
41
+ root.render(_jsx(ApplePayButton, __assign({}, props)));
42
+ var unmount = function () {
43
+ root.unmount();
44
+ tapConnectInstance = null;
45
+ };
46
+ tapConnectInstance = { unmount: unmount };
47
+ return tapConnectInstance;
48
+ };
@@ -1,3 +1,3 @@
1
- import { ApplePayButtonProps, ApplePayButton, renderApplePayButton, ApplePayRequestData } from './ApplePayButton';
2
- export { ApplePayButton, renderApplePayButton };
3
- export type { ApplePayButtonProps, ApplePayRequestData };
1
+ import { ApplePayButtonProps, ApplePayButton, renderApplePayButton, ApplePayRequestData } from './ApplePayButton';
2
+ export { ApplePayButton, renderApplePayButton };
3
+ export type { ApplePayButtonProps, ApplePayRequestData };
@@ -1,2 +1,2 @@
1
- import { ApplePayButton, renderApplePayButton } from './ApplePayButton';
2
- export { ApplePayButton, renderApplePayButton };
1
+ import { ApplePayButton, renderApplePayButton } from './ApplePayButton';
2
+ export { ApplePayButton, renderApplePayButton };
@@ -1 +1 @@
1
- export * from './useApplePay';
1
+ export * from './useApplePay';
@@ -1 +1 @@
1
- export * from './useApplePay';
1
+ export * from './useApplePay';