@tap-payments/apple-pay-button 0.0.84-development → 0.0.86-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.
@@ -109,12 +109,18 @@ export interface ApplePayButtonProps {
109
109
  onReady?: () => void;
110
110
  metaData?: MetaData;
111
111
  debug?: boolean;
112
- integration?: 'sdk' | 'iframe';
112
+ integration?: 'sdk' | 'iframe' | 'webview';
113
113
  headers?: {
114
114
  mdn: string;
115
115
  application: string;
116
116
  };
117
117
  }
118
+ export interface MerchantValidationRequestData {
119
+ validationUrl: string;
120
+ origin: string;
121
+ merchantId: string;
122
+ merchantName: string;
123
+ }
118
124
  export interface MerchantResponse {
119
125
  id: string;
120
126
  name: string;
package/build/api.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { MerchantResponse, CheckoutProfileRequest, ChargeRequestBody, AuthorizeRequestBody } from './@types';
1
+ import { CheckoutProfileRequest, ChargeRequestBody, AuthorizeRequestBody, MerchantValidationRequestData } from './@types';
2
2
  export declare const setAxiosGlobalHeaders: (headers: Record<string, string>) => void;
3
3
  export declare const getAxiosGlobalHeaders: () => {
4
4
  [x: string]: import("axios").AxiosHeaderValue | undefined;
@@ -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): Promise<any>;
23
+ appleSession(body: MerchantValidationRequestData): 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
@@ -149,20 +149,12 @@ var APPService = (function () {
149
149
  enumerable: false,
150
150
  configurable: true,
151
151
  writable: true,
152
- value: function (merchant, validationURL, merchantRegisteredDomain, merchantIdentifier) {
152
+ value: function (body) {
153
153
  return __awaiter(this, void 0, void 0, function () {
154
- var body, data;
154
+ var data;
155
155
  return __generator(this, function (_a) {
156
156
  switch (_a.label) {
157
- case 0:
158
- body = {
159
- validationUrl: validationURL,
160
- origin: merchantRegisteredDomain,
161
- merchantIdentifier: merchantIdentifier,
162
- merchantId: merchant.id,
163
- merchantName: merchant.name
164
- };
165
- return [4, axiosInstance.post('/validatemerchant', body)];
157
+ case 0: return [4, axiosInstance.post('/validatemerchant', body)];
166
158
  case 1:
167
159
  data = (_a.sent()).data;
168
160
  if (data.errors)
@@ -76,7 +76,7 @@ export declare const useApplePay: ({ buttonProps }: UsaApplePayProps) => {
76
76
  onReady?: (() => void) | undefined;
77
77
  metaData?: MetaData | undefined;
78
78
  debug?: boolean | undefined;
79
- integration?: "iframe" | "sdk" | undefined;
79
+ integration?: "iframe" | "sdk" | "webview" | undefined;
80
80
  headers?: {
81
81
  mdn: string;
82
82
  application: string;
@@ -77,8 +77,9 @@ export var useApplePay = function (_a) {
77
77
  var _k = useState(false), loading = _k[0], setLoading = _k[1];
78
78
  var _l = useState(false), isRounded = _l[0], setIsRounded = _l[1];
79
79
  var mappedProps = __assign(__assign({}, buttonProps), { interface: mappingInterface(buttonProps.interface) });
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
- var isIframeIntegration = buttonProps.integration === 'iframe';
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, integration = mappedProps.integration;
81
+ var isIframeIntegration = integration === 'iframe';
82
+ var isWebViewIntegration = integration === 'webview';
82
83
  useMerchantApplePay({
83
84
  isIframeIntegration: isIframeIntegration,
84
85
  onError: onError,
@@ -102,6 +103,17 @@ export var useApplePay = function (_a) {
102
103
  return null;
103
104
  return getApplePayPaymentMethod(profileData.payment_options.payment_methods || []);
104
105
  }, [profileData]);
106
+ var merchantValidationRequestData = useMemo(function () {
107
+ if (!profileData)
108
+ return null;
109
+ return {
110
+ merchantId: merchant.id || (profileData === null || profileData === void 0 ? void 0 : profileData.merchant.id),
111
+ merchantName: profileData.merchant.name,
112
+ validationUrl: '',
113
+ origin: (isWebViewIntegration ? applePayPaymentMethodOptions === null || applePayPaymentMethodOptions === void 0 ? void 0 : applePayPaymentMethodOptions.identifier : merchant.identifier || merchant.id) ||
114
+ profileData.merchant.id
115
+ };
116
+ }, [merchant, profileData === null || profileData === void 0 ? void 0 : profileData.merchant, isWebViewIntegration, applePayPaymentMethodOptions === null || applePayPaymentMethodOptions === void 0 ? void 0 : applePayPaymentMethodOptions.identifier]);
105
117
  var initialize = function (metaData) { return __awaiter(void 0, void 0, void 0, function () {
106
118
  var headers_1, rest, applePayPreparedData_1, data, applePayPreparedData, err_1;
107
119
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
@@ -233,7 +245,10 @@ export var useApplePay = function (_a) {
233
245
  if (debug) {
234
246
  console.info("creating merchant session for merchantData: ".concat(JSON.stringify(profileData.merchant), " and validationURL: ").concat(event.validationURL, " and merchant.domain: ").concat(window.location.hostname));
235
247
  }
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)];
248
+ if (!merchantValidationRequestData) {
249
+ throw new Error('Merchant Validation Request Data is not prepared!');
250
+ }
251
+ return [4, appService.appleSession(__assign(__assign({}, merchantValidationRequestData), { validationUrl: event.validationURL }))];
237
252
  case 2:
238
253
  merchantSession = _a.sent();
239
254
  if (debug)
@@ -405,12 +420,19 @@ export var useApplePay = function (_a) {
405
420
  var handleClick = useCallback(function () {
406
421
  var _a, _b;
407
422
  if (isIframeIntegration) {
408
- (_a = buttonProps.onClick) === null || _a === void 0 ? void 0 : _a.call(buttonProps, __assign(__assign({}, applePayRequestConfiguration), { applePayRequestData: applePayRequestData }));
423
+ (_a = buttonProps.onClick) === null || _a === void 0 ? void 0 : _a.call(buttonProps, __assign(__assign({}, applePayRequestConfiguration), { merchantValidationRequestData: merchantValidationRequestData, applePayRequestData: applePayRequestData }));
409
424
  return;
410
425
  }
411
426
  onApplePayButtonClicked();
412
427
  (_b = buttonProps.onClick) === null || _b === void 0 ? void 0 : _b.call(buttonProps);
413
- }, [applePayRequestConfiguration, applePayRequestData, buttonProps, isIframeIntegration, onApplePayButtonClicked]);
428
+ }, [
429
+ applePayRequestConfiguration,
430
+ applePayRequestData,
431
+ buttonProps,
432
+ isIframeIntegration,
433
+ onApplePayButtonClicked,
434
+ merchantValidationRequestData
435
+ ]);
414
436
  useEffect(function () {
415
437
  initialize(metaData);
416
438
  }, []);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tap-payments/apple-pay-button",
3
- "version": "0.0.84-development",
3
+ "version": "0.0.86-development",
4
4
  "description": "Apple Pay Button React Component",
5
5
  "main": "build/index.js",
6
6
  "module": "build/index.js",