@tap-payments/apple-pay-button 0.0.78-development → 0.0.80-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.
@@ -130,7 +130,7 @@ interface Assests {
130
130
  theme: Theme;
131
131
  web: Theme;
132
132
  }
133
- declare type Theme = Record<ThemeMode, string> & {
133
+ type Theme = Record<ThemeMode, string> & {
134
134
  card: {
135
135
  light: string;
136
136
  dark: string;
@@ -1,4 +1,4 @@
1
- export declare type TapLocalizationResponse = Record<string, TapLocalization>;
1
+ export type TapLocalizationResponse = Record<string, TapLocalization>;
2
2
  export interface TapLocalization {
3
3
  ActionButton: ActionButton;
4
4
  Common: Common;
package/build/api.d.ts CHANGED
@@ -20,7 +20,7 @@ declare class APPService {
20
20
  merchant: any;
21
21
  payment_options: any;
22
22
  }>;
23
- appleSession(merchant: Pick<MerchantResponse, 'name' | 'id'>, validationURL: string, merchantRegisteredDomain: string, merchantIdentifier: string, domainValidator: string): Promise<any>;
23
+ appleSession(merchant: Pick<MerchantResponse, 'name' | 'id'>, validationURL: string, merchantRegisteredDomain: string, merchantIdentifier: string): Promise<any>;
24
24
  tapTokenization(applePaymentData: Record<string, string>): Promise<any>;
25
25
  createCharge(request: ChargeRequestBody): Promise<any>;
26
26
  createAuthorize(request: AuthorizeRequestBody): Promise<any>;
package/build/api.js CHANGED
@@ -24,7 +24,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
24
24
  function verb(n) { return function (v) { return step([n, v]); }; }
25
25
  function step(op) {
26
26
  if (f) throw new TypeError("Generator is already executing.");
27
- while (_) try {
27
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
28
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
29
  if (y = 0, t) op = [op[0] & 2, t.value];
30
30
  switch (op[0]) {
@@ -149,7 +149,7 @@ var APPService = (function () {
149
149
  enumerable: false,
150
150
  configurable: true,
151
151
  writable: true,
152
- value: function (merchant, validationURL, merchantRegisteredDomain, merchantIdentifier, domainValidator) {
152
+ value: function (merchant, validationURL, merchantRegisteredDomain, merchantIdentifier) {
153
153
  return __awaiter(this, void 0, void 0, function () {
154
154
  var body, data;
155
155
  return __generator(this, function (_a) {
@@ -160,8 +160,7 @@ var APPService = (function () {
160
160
  origin: merchantRegisteredDomain,
161
161
  merchantIdentifier: merchantIdentifier,
162
162
  merchantId: merchant.id,
163
- merchantName: merchant.name,
164
- domainValidator: domainValidator
163
+ merchantName: merchant.name
165
164
  };
166
165
  return [4, axiosInstance.post('/validatemerchant', body)];
167
166
  case 1:
@@ -1,5 +1,4 @@
1
- /// <reference types="react" />
2
1
  import { ApplePayButtonProps, ApplePayRequestData } from '../../@types';
3
2
  export type { ApplePayButtonProps, ApplePayRequestData };
4
- export declare function ApplePayButton(props: ApplePayButtonProps): JSX.Element;
3
+ export declare function ApplePayButton(props: ApplePayButtonProps): import("react/jsx-runtime").JSX.Element;
5
4
  export declare const renderApplePayButton: (props: ApplePayButtonProps, elementId: string) => any;
@@ -24,7 +24,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
24
24
  function verb(n) { return function (v) { return step([n, v]); }; }
25
25
  function step(op) {
26
26
  if (f) throw new TypeError("Generator is already executing.");
27
- while (_) try {
27
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
28
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
29
  if (y = 0, t) op = [op[0] & 2, t.value];
30
30
  switch (op[0]) {
@@ -65,17 +65,17 @@ import { getApplePayPaymentMethod, getDefaultThemeMode } from '../utils';
65
65
  import appService, { getAxiosGlobalHeaders, setAxiosGlobalHeaders } from '../api';
66
66
  import { ChargeCode, mappingInterface } from '@tap-payments/acceptance-sdk';
67
67
  export var useApplePay = function (_a) {
68
- var _b, _c;
68
+ var _b;
69
69
  var buttonProps = _a.buttonProps;
70
- var _d = useState(), applePayRequestData = _d[0], setApplePayRequestData = _d[1];
71
- var _e = useState(), applePayRequestConfiguration = _e[0], setApplePayRequestConfiguration = _e[1];
72
- var _f = useState(), profileData = _f[0], setProfile = _f[1];
73
- var _g = useState(false), disabled = _g[0], setDisabled = _g[1];
74
- var _h = useState(false), initialLoading = _h[0], setInitialLoading = _h[1];
75
- var _j = useState(false), error = _j[0], setError = _j[1];
76
- var _k = useState(false), success = _k[0], setSuccess = _k[1];
77
- var _l = useState(false), loading = _l[0], setLoading = _l[1];
78
- var _m = useState(false), isRounded = _m[0], setIsRounded = _m[1];
70
+ var _c = useState(), applePayRequestData = _c[0], setApplePayRequestData = _c[1];
71
+ var _d = useState(), applePayRequestConfiguration = _d[0], setApplePayRequestConfiguration = _d[1];
72
+ var _e = useState(), profileData = _e[0], setProfile = _e[1];
73
+ var _f = useState(false), disabled = _f[0], setDisabled = _f[1];
74
+ var _g = useState(false), initialLoading = _g[0], setInitialLoading = _g[1];
75
+ var _h = useState(false), error = _h[0], setError = _h[1];
76
+ var _j = useState(false), success = _j[0], setSuccess = _j[1];
77
+ var _k = useState(false), loading = _k[0], setLoading = _k[1];
78
+ var _l = useState(false), isRounded = _l[0], setIsRounded = _l[1];
79
79
  var mappedProps = __assign(__assign({}, buttonProps), { interface: mappingInterface(buttonProps.interface) });
80
80
  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;
81
81
  var isIframeIntegration = buttonProps.integration === 'iframe';
@@ -192,16 +192,6 @@ export var useApplePay = function (_a) {
192
192
  }
193
193
  });
194
194
  }); };
195
- var isTapIdentifier = function (id) { return (id.toLowerCase().includes('knet') ? 'knet' : 'tap'); };
196
- var domainValidator = useMemo(function () {
197
- var _a, _b, _c;
198
- if (merchant.identifier)
199
- return isTapIdentifier(merchant.identifier);
200
- if (!((_a = profileData === null || profileData === void 0 ? void 0 : profileData.payment_options) === null || _a === void 0 ? void 0 : _a.payment_methods))
201
- return '';
202
- var identifier = (_c = (_b = getApplePayPaymentMethod(profileData.payment_options.payment_methods)) === null || _b === void 0 ? void 0 : _b.identifier) !== null && _c !== void 0 ? _c : '';
203
- return isTapIdentifier(identifier);
204
- }, [(_c = profileData === null || profileData === void 0 ? void 0 : profileData.payment_options) === null || _c === void 0 ? void 0 : _c.payment_methods, merchant === null || merchant === void 0 ? void 0 : merchant.identifier]);
205
195
  var onApplePayButtonClicked = function () { return __awaiter(void 0, void 0, void 0, function () {
206
196
  var ApplePaySession, session_1;
207
197
  var _a;
@@ -243,7 +233,7 @@ export var useApplePay = function (_a) {
243
233
  if (debug) {
244
234
  console.info("creating merchant session for merchantData: ".concat(JSON.stringify(profileData.merchant), " and validationURL: ").concat(event.validationURL, " and merchant.domain: ").concat(window.location.hostname));
245
235
  }
246
- return [4, appService.appleSession(__assign(__assign({}, profileData.merchant), { id: merchant.id || profileData.merchant.id }), event.validationURL, window.location.hostname, merchant.identifier || merchant.id || profileData.merchant.id, domainValidator)];
236
+ return [4, appService.appleSession(__assign(__assign({}, profileData.merchant), { id: merchant.id || profileData.merchant.id }), event.validationURL, window.location.hostname, merchant.identifier || merchant.id || profileData.merchant.id)];
247
237
  case 2:
248
238
  merchantSession = _a.sent();
249
239
  if (debug)
@@ -264,16 +254,16 @@ export var useApplePay = function (_a) {
264
254
  });
265
255
  }); };
266
256
  session_1.onpaymentauthorized = function (event) { return __awaiter(void 0, void 0, void 0, function () {
267
- var _a, data, tokenId, supportCurrency, transactionRequest, transactionResponse, _b, successState, error_2;
268
- var _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
269
- return __generator(this, function (_t) {
270
- switch (_t.label) {
257
+ var _a, _b, paymentData, paymentMethod, transactionIdentifier, data, tokenId, supportCurrency, transactionRequest, transactionResponse, _c, successState, error_2;
258
+ var _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
259
+ return __generator(this, function (_v) {
260
+ switch (_v.label) {
271
261
  case 0:
272
262
  if (debug)
273
263
  console.info('onpaymentauthorized event', event);
274
- _t.label = 1;
264
+ _v.label = 1;
275
265
  case 1:
276
- _t.trys.push([1, 13, 14, 15]);
266
+ _v.trys.push([1, 13, 14, 15]);
277
267
  _a = scope;
278
268
  switch (_a) {
279
269
  case Scope.APPLE_PAY_TOKEN: return [3, 2];
@@ -283,27 +273,27 @@ export var useApplePay = function (_a) {
283
273
  }
284
274
  return [3, 11];
285
275
  case 2:
286
- onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(event.payment.token.paymentData);
276
+ onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(event.payment.token);
287
277
  session_1.completePayment({ status: ApplePaySession.STATUS_SUCCESS });
288
278
  return [3, 12];
289
279
  case 3:
290
280
  setLoading(true);
291
- session_1.completePayment({ status: ApplePaySession.STATUS_SUCCESS });
292
- return [4, appService.tapTokenization(event.payment.token.paymentData)];
281
+ _b = (_d = event.payment.token) !== null && _d !== void 0 ? _d : {}, paymentData = _b.paymentData, paymentMethod = _b.paymentMethod, transactionIdentifier = _b.transactionIdentifier;
282
+ return [4, appService.tapTokenization(__assign(__assign({}, paymentData), { paymentMethod: paymentMethod, transactionIdentifier: transactionIdentifier }))];
293
283
  case 4:
294
- data = _t.sent();
284
+ data = _v.sent();
295
285
  setSuccess === null || setSuccess === void 0 ? void 0 : setSuccess(true);
296
286
  onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(data);
297
287
  return [3, 12];
298
288
  case 5:
299
289
  setLoading(true);
300
290
  session_1.completePayment({ status: ApplePaySession.STATUS_SUCCESS });
301
- return [4, appService.tapTokenization(event.payment.token.paymentData)];
291
+ return [4, appService.tapTokenization(__assign(__assign(__assign({}, event.payment.token.paymentData), event.payment.token), { paymentData: undefined }))];
302
292
  case 6:
303
- tokenId = (_t.sent()).id;
304
- supportCurrency = ((_d = (_c = profileData === null || profileData === void 0 ? void 0 : profileData.payment_options) === null || _c === void 0 ? void 0 : _c.supported_currencies) !== null && _d !== void 0 ? _d : [])[0];
293
+ tokenId = (_v.sent()).id;
294
+ supportCurrency = ((_f = (_e = profileData === null || profileData === void 0 ? void 0 : profileData.payment_options) === null || _e === void 0 ? void 0 : _e.supported_currencies) !== null && _f !== void 0 ? _f : [])[0];
305
295
  transactionRequest = {
306
- auto: (_e = transaction === null || transaction === void 0 ? void 0 : transaction.authorize) === null || _e === void 0 ? void 0 : _e.auto,
296
+ auto: (_g = transaction === null || transaction === void 0 ? void 0 : transaction.authorize) === null || _g === void 0 ? void 0 : _g.auto,
307
297
  amount: order.amount,
308
298
  currency: order.currency,
309
299
  selected_amount: supportCurrency === null || supportCurrency === void 0 ? void 0 : supportCurrency.amount,
@@ -311,19 +301,19 @@ export var useApplePay = function (_a) {
311
301
  customer: (customer === null || customer === void 0 ? void 0 : customer.id)
312
302
  ? { id: customer === null || customer === void 0 ? void 0 : customer.id }
313
303
  : {
314
- email: (_f = customer === null || customer === void 0 ? void 0 : customer.contact) === null || _f === void 0 ? void 0 : _f.email,
315
- first_name: ((_g = customer === null || customer === void 0 ? void 0 : customer.name) === null || _g === void 0 ? void 0 : _g.length) ? customer.name[0].first : '',
316
- last_name: ((_h = customer === null || customer === void 0 ? void 0 : customer.name) === null || _h === void 0 ? void 0 : _h.length) ? customer.name[0].last : '',
304
+ email: (_h = customer === null || customer === void 0 ? void 0 : customer.contact) === null || _h === void 0 ? void 0 : _h.email,
305
+ first_name: ((_j = customer === null || customer === void 0 ? void 0 : customer.name) === null || _j === void 0 ? void 0 : _j.length) ? customer.name[0].first : '',
306
+ last_name: ((_k = customer === null || customer === void 0 ? void 0 : customer.name) === null || _k === void 0 ? void 0 : _k.length) ? customer.name[0].last : '',
317
307
  phone: {
318
- country_code: (_l = (_k = (_j = customer === null || customer === void 0 ? void 0 : customer.contact) === null || _j === void 0 ? void 0 : _j.phone) === null || _k === void 0 ? void 0 : _k.countryCode) !== null && _l !== void 0 ? _l : '',
319
- number: (_p = (_o = (_m = customer === null || customer === void 0 ? void 0 : customer.contact) === null || _m === void 0 ? void 0 : _m.phone) === null || _o === void 0 ? void 0 : _o.number) !== null && _p !== void 0 ? _p : ''
308
+ country_code: (_o = (_m = (_l = customer === null || customer === void 0 ? void 0 : customer.contact) === null || _l === void 0 ? void 0 : _l.phone) === null || _m === void 0 ? void 0 : _m.countryCode) !== null && _o !== void 0 ? _o : '',
309
+ number: (_r = (_q = (_p = customer === null || customer === void 0 ? void 0 : customer.contact) === null || _p === void 0 ? void 0 : _p.phone) === null || _q === void 0 ? void 0 : _q.number) !== null && _r !== void 0 ? _r : ''
320
310
  }
321
311
  },
322
312
  fee: 0,
323
313
  merchant: {
324
- id: (_r = (_q = profileData === null || profileData === void 0 ? void 0 : profileData.merchant) === null || _q === void 0 ? void 0 : _q.id) !== null && _r !== void 0 ? _r : ''
314
+ id: (_t = (_s = profileData === null || profileData === void 0 ? void 0 : profileData.merchant) === null || _s === void 0 ? void 0 : _s.id) !== null && _t !== void 0 ? _t : ''
325
315
  },
326
- order: (_s = profileData === null || profileData === void 0 ? void 0 : profileData.payment_options) === null || _s === void 0 ? void 0 : _s.order,
316
+ order: (_u = profileData === null || profileData === void 0 ? void 0 : profileData.payment_options) === null || _u === void 0 ? void 0 : _u.order,
327
317
  product: 'Apple-Pay-Button',
328
318
  save_card: false,
329
319
  source: { id: tokenId !== null && tokenId !== void 0 ? tokenId : '' },
@@ -342,14 +332,14 @@ export var useApplePay = function (_a) {
342
332
  if (!(scope === Scope.AUTHORIZE)) return [3, 8];
343
333
  return [4, appService.createAuthorize(transactionRequest)];
344
334
  case 7:
345
- _b = _t.sent();
335
+ _c = _v.sent();
346
336
  return [3, 10];
347
337
  case 8: return [4, appService.createCharge(transactionRequest)];
348
338
  case 9:
349
- _b = _t.sent();
350
- _t.label = 10;
339
+ _c = _v.sent();
340
+ _v.label = 10;
351
341
  case 10:
352
- transactionResponse = _b;
342
+ transactionResponse = _c;
353
343
  successState = scope === Scope.AUTHORIZE ? ChargeCode.AUTHORIZED : ChargeCode.SUCCESS;
354
344
  if ((transactionResponse === null || transactionResponse === void 0 ? void 0 : transactionResponse.response.code) === successState) {
355
345
  setSuccess === null || setSuccess === void 0 ? void 0 : setSuccess(true);
@@ -363,10 +353,10 @@ export var useApplePay = function (_a) {
363
353
  console.error('We only support AppleToken and TapToken for now');
364
354
  console.info('Completing payment with status: STATUS_FAILURE');
365
355
  session_1.completePayment({ status: ApplePaySession.STATUS_FAILURE });
366
- _t.label = 12;
356
+ _v.label = 12;
367
357
  case 12: return [3, 15];
368
358
  case 13:
369
- error_2 = _t.sent();
359
+ error_2 = _v.sent();
370
360
  if (debug)
371
361
  console.error('error in onpaymentauthorized', error_2);
372
362
  setError(true);
@@ -6,7 +6,7 @@ interface ApplePayRequestData {
6
6
  setLoading?: (loading: boolean) => void;
7
7
  setSuccess?: (success: boolean) => void;
8
8
  setError?: (error: boolean) => void;
9
- scope: typeof Scope[keyof typeof Scope];
9
+ scope: (typeof Scope)[keyof typeof Scope];
10
10
  profileData?: Pick<MetaData, 'merchant' | 'payment_options'>;
11
11
  merchant: Pick<MetaData['merchant'], 'id'>;
12
12
  order: ApplePayButtonProps['order'];
@@ -13,7 +13,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
13
13
  function verb(n) { return function (v) { return step([n, v]); }; }
14
14
  function step(op) {
15
15
  if (f) throw new TypeError("Generator is already executing.");
16
- while (_) try {
16
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
17
17
  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;
18
18
  if (y = 0, t) op = [op[0] & 2, t.value];
19
19
  switch (op[0]) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tap-payments/apple-pay-button",
3
- "version": "0.0.78-development",
3
+ "version": "0.0.80-development",
4
4
  "description": "Apple Pay Button React Component",
5
5
  "main": "build/index.js",
6
6
  "module": "build/index.js",