@tap-payments/apple-pay-button 0.0.68-development → 0.0.70-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.
@@ -60,6 +60,7 @@ export interface ApplePayButtonProps {
60
60
  };
61
61
  merchant: {
62
62
  id: string;
63
+ identifier?: string;
63
64
  };
64
65
  scope: Scope;
65
66
  interface?: Interface;
@@ -92,6 +92,7 @@ export interface PaymentMethod {
92
92
  button_style: Buttonstyle;
93
93
  display_name: string;
94
94
  default_currency: string;
95
+ identifier?: string;
95
96
  }
96
97
  interface Buttonstyle {
97
98
  background: Background2;
package/build/api.d.ts CHANGED
@@ -1,18 +1,13 @@
1
1
  import { MerchantResponse, CheckoutProfileRequest, ChargeRequestBody, AuthorizeRequestBody } from './@types';
2
2
  export declare const setAxiosGlobalHeaders: (headers: Record<string, string>) => void;
3
3
  export declare const getAxiosGlobalHeaders: () => {
4
- [x: string]: (string | number | boolean | string[] | import("axios").AxiosHeaders | null) | undefined;
5
- head?: import("axios").AxiosHeaders | undefined;
6
- link?: import("axios").AxiosHeaders | undefined;
7
- post?: import("axios").AxiosHeaders | undefined;
8
- get?: import("axios").AxiosHeaders | undefined;
9
- delete?: import("axios").AxiosHeaders | undefined;
10
- options?: import("axios").AxiosHeaders | undefined;
11
- put?: import("axios").AxiosHeaders | undefined;
12
- patch?: import("axios").AxiosHeaders | undefined;
13
- purge?: import("axios").AxiosHeaders | undefined;
14
- unlink?: import("axios").AxiosHeaders | undefined;
15
- common?: import("axios").AxiosHeaders | undefined;
4
+ [x: string]: import("axios").AxiosHeaderValue | undefined;
5
+ Accept?: import("axios").AxiosHeaderValue | undefined;
6
+ "Content-Length"?: import("axios").AxiosHeaderValue | undefined;
7
+ "User-Agent"?: import("axios").AxiosHeaderValue | undefined;
8
+ "Content-Encoding"?: import("axios").AxiosHeaderValue | undefined;
9
+ Authorization?: import("axios").AxiosHeaderValue | undefined;
10
+ 'Content-Type'?: import("axios").AxiosHeaderValue | undefined;
16
11
  };
17
12
  declare class APPService {
18
13
  setHttpHeaders(headers: Record<string, string>): Promise<void>;
@@ -25,7 +20,7 @@ declare class APPService {
25
20
  merchant: any;
26
21
  payment_options: any;
27
22
  }>;
28
- appleSession(merchant: Pick<MerchantResponse, 'name' | 'id'>, validationURL: string, merchantRegisteredDomain: string): Promise<any>;
23
+ appleSession(merchant: Pick<MerchantResponse, 'name' | 'id'>, validationURL: string, merchantRegisteredDomain: string, merchantIdentifier: string, processingWith?: string): Promise<any>;
29
24
  tapTokenization(applePaymentData: Record<string, string>): Promise<any>;
30
25
  createCharge(request: ChargeRequestBody): Promise<any>;
31
26
  createAuthorize(request: AuthorizeRequestBody): Promise<any>;
package/build/api.js CHANGED
@@ -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) {
152
+ value: function (merchant, validationURL, merchantRegisteredDomain, merchantIdentifier, processingWith) {
153
153
  return __awaiter(this, void 0, void 0, function () {
154
154
  var body, data;
155
155
  return __generator(this, function (_a) {
@@ -158,9 +158,10 @@ var APPService = (function () {
158
158
  body = {
159
159
  validationUrl: validationURL,
160
160
  origin: merchantRegisteredDomain,
161
- merchantIdentifier: merchant.id,
161
+ merchantIdentifier: merchantIdentifier,
162
162
  merchantId: merchant.id,
163
- merchantName: merchant.name
163
+ merchantName: merchant.name,
164
+ processingWith: processingWith
164
165
  };
165
166
  return [4, axiosInstance.post('/validatemerchant', body)];
166
167
  case 1:
@@ -24,6 +24,7 @@ export declare const useApplePay: ({ buttonProps }: UsaApplePayProps) => {
24
24
  };
25
25
  merchant: {
26
26
  id: string;
27
+ identifier?: string | undefined;
27
28
  };
28
29
  scope: Scope;
29
30
  customer?: import("../@types").Customer | undefined;
@@ -58,13 +58,14 @@ export var useApplePay = function (_a) {
58
58
  var buttonProps = _a.buttonProps;
59
59
  var _c = useState(), applePayRequestData = _c[0], setApplePayRequestData = _c[1];
60
60
  var _d = useState(), applePayRequestConfiguration = _d[0], setApplePayRequestConfiguration = _d[1];
61
- var _e = useState(), profileData = _e[0], setProfile = _e[1];
62
- var _f = useState(false), disabled = _f[0], setDisabled = _f[1];
63
- var _g = useState(false), initialLoading = _g[0], setInitialLoading = _g[1];
64
- var _h = useState(false), error = _h[0], setError = _h[1];
65
- var _j = useState(false), success = _j[0], setSuccess = _j[1];
66
- var _k = useState(false), loading = _k[0], setLoading = _k[1];
67
- var _l = useState(false), isRounded = _l[0], setIsRounded = _l[1];
61
+ var _e = useState(), processingWith = _e[0], setProcessingWith = _e[1];
62
+ var _f = useState(), profileData = _f[0], setProfile = _f[1];
63
+ var _g = useState(false), disabled = _g[0], setDisabled = _g[1];
64
+ var _h = useState(false), initialLoading = _h[0], setInitialLoading = _h[1];
65
+ var _j = useState(false), error = _j[0], setError = _j[1];
66
+ var _k = useState(false), success = _k[0], setSuccess = _k[1];
67
+ var _l = useState(false), loading = _l[0], setLoading = _l[1];
68
+ var _m = useState(false), isRounded = _m[0], setIsRounded = _m[1];
68
69
  var mappedProps = __assign(__assign({}, buttonProps), { interface: mapingInterface(buttonProps.interface) });
69
70
  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;
70
71
  var isIframeIntegration = buttonProps.integration === 'iframe';
@@ -92,15 +93,15 @@ export var useApplePay = function (_a) {
92
93
  return getApplePayPaymentMethod(profileData.payment_options.payment_methods || []);
93
94
  }, [profileData]);
94
95
  var initialize = function (metaData) { return __awaiter(void 0, void 0, void 0, function () {
95
- var merchantProfile, payment_options, headers_1, data, err_1;
96
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
97
- return __generator(this, function (_o) {
98
- switch (_o.label) {
96
+ var merchantProfile, payment_options, headers_1, data, applePayPreparedData, err_1;
97
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
98
+ return __generator(this, function (_p) {
99
+ switch (_p.label) {
99
100
  case 0:
100
101
  setInitialLoading(true);
101
- _o.label = 1;
102
+ _p.label = 1;
102
103
  case 1:
103
- _o.trys.push([1, 7, , 8]);
104
+ _p.trys.push([1, 7, , 8]);
104
105
  if (!shallRenderApplePay()) {
105
106
  throw new Error('The device/customer is not eligible to use ApplePay');
106
107
  }
@@ -113,7 +114,7 @@ export var useApplePay = function (_a) {
113
114
  if (!headers) return [3, 3];
114
115
  return [4, appService.setHttpHeaders(__assign(__assign({}, headers), { authorization: operator.publicKey }))];
115
116
  case 2:
116
- _o.sent();
117
+ _p.sent();
117
118
  return [3, 5];
118
119
  case 3: return [4, appService.setBrowserHeaders({
119
120
  locale: interfaceObj === null || interfaceObj === void 0 ? void 0 : interfaceObj.locale,
@@ -121,8 +122,8 @@ export var useApplePay = function (_a) {
121
122
  pk: operator.publicKey
122
123
  })];
123
124
  case 4:
124
- _o.sent();
125
- _o.label = 5;
125
+ _p.sent();
126
+ _p.label = 5;
126
127
  case 5: return [4, appService.checkoutProfile({
127
128
  supported_payment_methods: ['APPLE_PAY'],
128
129
  supported_currencies: [order.currency],
@@ -154,22 +155,24 @@ export var useApplePay = function (_a) {
154
155
  ] })
155
156
  })];
156
157
  case 6:
157
- data = _o.sent();
158
+ data = _p.sent();
158
159
  if (debug)
159
160
  console.log('merchant configuration: ', data);
160
161
  setProfile(data);
161
- setApplePayRequestData(prepareApplePayRequest(__assign(__assign({}, data), { order: order, acceptance: acceptance, customer: customer })));
162
- onOrderCreated === null || onOrderCreated === void 0 ? void 0 : onOrderCreated((_l = (_k = data.payment_options) === null || _k === void 0 ? void 0 : _k.order) === null || _l === void 0 ? void 0 : _l.id);
162
+ applePayPreparedData = prepareApplePayRequest(__assign(__assign({}, data), { order: order, acceptance: acceptance, customer: customer }));
163
+ setApplePayRequestData(applePayPreparedData.applePaySessionRequest);
164
+ setProcessingWith(((_k = applePayPreparedData.paymentMethod.identifier) === null || _k === void 0 ? void 0 : _k.includes('knet')) ? 'knet' : 'tap');
165
+ onOrderCreated === null || onOrderCreated === void 0 ? void 0 : onOrderCreated((_m = (_l = data.payment_options) === null || _l === void 0 ? void 0 : _l.order) === null || _m === void 0 ? void 0 : _m.id);
163
166
  setApplePayRequestConfiguration({
164
167
  BASE_URL: MW_BASE_URL,
165
168
  headers: getAxiosGlobalHeaders(),
166
- merchant: __assign(__assign({}, data.merchant), { id: merchant.id || ((_m = data.merchant) === null || _m === void 0 ? void 0 : _m.id) })
169
+ merchant: __assign(__assign({}, data.merchant), { id: merchant.id || ((_o = data.merchant) === null || _o === void 0 ? void 0 : _o.id) })
167
170
  });
168
171
  setInitialLoading(false);
169
172
  onReady === null || onReady === void 0 ? void 0 : onReady();
170
173
  return [3, 8];
171
174
  case 7:
172
- err_1 = _o.sent();
175
+ err_1 = _p.sent();
173
176
  onError === null || onError === void 0 ? void 0 : onError(err_1.errors || err_1);
174
177
  console.log('error in initialize', err_1);
175
178
  return [3, 8];
@@ -218,7 +221,7 @@ export var useApplePay = function (_a) {
218
221
  if (debug) {
219
222
  console.info("creating merchant session for merchantData: ".concat(JSON.stringify(profileData.merchant), " and validationURL: ").concat(event.validationURL, " and merchant.domain: ").concat(window.location.hostname));
220
223
  }
221
- return [4, appService.appleSession(__assign(__assign({}, profileData.merchant), { id: merchant.id || profileData.merchant.id }), event.validationURL, window.location.hostname)];
224
+ 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, processingWith)];
222
225
  case 2:
223
226
  merchantSession = _a.sent();
224
227
  if (debug)
@@ -7,5 +7,8 @@ export declare const getApplePayRequest: ({ order, customer, supportedNetworks,
7
7
  countryCode: string;
8
8
  name: string;
9
9
  }) => ApplePayRequestData;
10
- export declare const prepareApplePayRequest: ({ payment_options, merchant, order, customer, acceptance }: Pick<MetaData, 'merchant' | 'payment_options'> & Pick<ApplePayButtonProps, 'order' | 'customer' | 'acceptance'>) => ApplePayRequestData;
10
+ export declare const prepareApplePayRequest: ({ payment_options, merchant, order, customer, acceptance }: Pick<MetaData, 'merchant' | 'payment_options'> & Pick<ApplePayButtonProps, 'order' | 'customer' | 'acceptance'>) => {
11
+ applePaySessionRequest: ApplePayRequestData;
12
+ paymentMethod: PaymentMethod;
13
+ };
11
14
  export declare const shallRenderApplePay: () => boolean;
@@ -57,7 +57,7 @@ export var prepareApplePayRequest = function (_a) {
57
57
  merchantCapabilities: getMerchantCapabilities(acceptance === null || acceptance === void 0 ? void 0 : acceptance.supportedFundSource),
58
58
  name: merchant.name
59
59
  });
60
- return request;
60
+ return { applePaySessionRequest: request, paymentMethod: paymentMethod };
61
61
  };
62
62
  export var shallRenderApplePay = function () {
63
63
  var https = window.location.protocol === 'https:';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tap-payments/apple-pay-button",
3
- "version": "0.0.68-development",
3
+ "version": "0.0.70-development",
4
4
  "description": "Apple Pay Button React Component",
5
5
  "main": "build/index.js",
6
6
  "module": "build/index.js",