@tap-payments/apple-pay-button 0.0.85-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.
@@ -115,6 +115,12 @@ export interface ApplePayButtonProps {
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)
@@ -103,6 +103,17 @@ export var useApplePay = function (_a) {
103
103
  return null;
104
104
  return getApplePayPaymentMethod(profileData.payment_options.payment_methods || []);
105
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]);
106
117
  var initialize = function (metaData) { return __awaiter(void 0, void 0, void 0, function () {
107
118
  var headers_1, rest, applePayPreparedData_1, data, applePayPreparedData, err_1;
108
119
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
@@ -234,8 +245,10 @@ export var useApplePay = function (_a) {
234
245
  if (debug) {
235
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));
236
247
  }
237
- return [4, appService.appleSession(__assign(__assign({}, profileData.merchant), { id: merchant.id || profileData.merchant.id }), event.validationURL, window.location.hostname, (isWebViewIntegration ? applePayPaymentMethodOptions === null || applePayPaymentMethodOptions === void 0 ? void 0 : applePayPaymentMethodOptions.identifier : merchant.identifier || merchant.id) ||
238
- 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 }))];
239
252
  case 2:
240
253
  merchantSession = _a.sent();
241
254
  if (debug)
@@ -407,12 +420,19 @@ export var useApplePay = function (_a) {
407
420
  var handleClick = useCallback(function () {
408
421
  var _a, _b;
409
422
  if (isIframeIntegration) {
410
- (_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 }));
411
424
  return;
412
425
  }
413
426
  onApplePayButtonClicked();
414
427
  (_b = buttonProps.onClick) === null || _b === void 0 ? void 0 : _b.call(buttonProps);
415
- }, [applePayRequestConfiguration, applePayRequestData, buttonProps, isIframeIntegration, onApplePayButtonClicked]);
428
+ }, [
429
+ applePayRequestConfiguration,
430
+ applePayRequestData,
431
+ buttonProps,
432
+ isIframeIntegration,
433
+ onApplePayButtonClicked,
434
+ merchantValidationRequestData
435
+ ]);
416
436
  useEffect(function () {
417
437
  initialize(metaData);
418
438
  }, []);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tap-payments/apple-pay-button",
3
- "version": "0.0.85-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",