@tap-payments/auth-jsconnect 2.7.4-test → 2.7.6-test

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.
@@ -1,4 +1,5 @@
1
1
  /// <reference types="react" />
2
+ import { PaymentProvider } from './config';
2
3
  import { LanguageMode, DialogEdgeFormat } from './theme';
3
4
  export interface CountryCode {
4
5
  created: number;
@@ -219,6 +220,7 @@ export interface LibConfig extends LibCallbacks {
219
220
  scope: string;
220
221
  platforms?: Array<string>;
221
222
  dialogEdgeFormat?: DialogEdgeFormat;
223
+ paymentProvider?: PaymentProvider;
222
224
  postURL?: string;
223
225
  redirectUrl?: string;
224
226
  data?: Array<string>;
@@ -9,6 +9,11 @@ export interface ConfigInfo {
9
9
  post?: Redirect;
10
10
  connect?: Redirect;
11
11
  platforms?: string[];
12
+ payment_provider?: PaymentProvider;
13
+ }
14
+ export interface PaymentProvider {
15
+ technology_id: string;
16
+ settlement_by: string;
12
17
  }
13
18
  interface Redirect {
14
19
  url: string;
@@ -1,3 +1,4 @@
1
+ import { PaymentProvider } from '../@types';
1
2
  export type CreateAccountBody = {
2
3
  lead_id: string;
3
4
  notify: {
@@ -12,6 +13,7 @@ export type ExpressCreateAccountBody = {
12
13
  post_url: string;
13
14
  lead_id: string;
14
15
  platforms?: string[];
16
+ payment_provider?: PaymentProvider;
15
17
  };
16
18
  declare const accountService: {
17
19
  createAccount: (data: CreateAccountBody) => Promise<any>;
@@ -1,5 +1,5 @@
1
- import { httpClient } from './axios';
2
1
  import { ENDPOINT_PATHS } from '../constants';
2
+ import { httpClient } from './axios';
3
3
  var createAccount = function (data) {
4
4
  return httpClient({
5
5
  method: 'post',
@@ -1,4 +1,5 @@
1
1
  import { AxiosRequestConfig } from 'axios';
2
+ import { PaymentProvider } from '../@types';
2
3
  export type EntityInfoBody = {
3
4
  id: string;
4
5
  lead_id?: string;
@@ -119,6 +120,7 @@ export type MerchantListBody = {
119
120
  brand_id: string;
120
121
  create_if_not_present: boolean;
121
122
  platforms?: Array<string>;
123
+ payment_provider?: PaymentProvider;
122
124
  };
123
125
  export type CreateEntityBody = {
124
126
  business_id: string;
@@ -53,7 +53,7 @@ import i18n from '../i18n';
53
53
  import { updateLocale } from '../utils/locale';
54
54
  import API, { getAxiosHeaders, setAxiosGlobalHeaders } from '../api';
55
55
  export var fetchAppSettingsSync = createAsyncThunk('fetchAppSettingsSync', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
56
- var settings, _a, appConfig, language, _b, client, device, os, disableLocale, maturity, disableCountries, configToken, onVerifyConfigTokenSuccess, _c, visitorId, locale, configInfo, matureData, lang, initPayload, _d, country_list, ip_info, merchant, operator, config, list, _e, ip, latitude, longitude, country_code, countries, _f, operator_1, scope, data, lead, board, interfaceData, redirect, post, platforms, _g, locale_1, edges, deviceInfo, isValidOperator, countryCode, businessCountry, ipCountry;
56
+ var settings, _a, appConfig, language, _b, client, device, os, disableLocale, maturity, disableCountries, configToken, onVerifyConfigTokenSuccess, _c, visitorId, locale, configInfo, matureData, lang, initPayload, _d, country_list, ip_info, merchant, operator, config, list, _e, ip, latitude, longitude, country_code, countries, _f, operator_1, scope, data, lead, board, interfaceData, redirect, post, platforms, payment_provider, _g, locale_1, edges, deviceInfo, isValidOperator, countryCode, businessCountry, ipCountry;
57
57
  var _h;
58
58
  return __generator(this, function (_j) {
59
59
  switch (_j.label) {
@@ -83,11 +83,11 @@ export var fetchAppSettingsSync = createAsyncThunk('fetchAppSettingsSync', funct
83
83
  _e = ip_info || {}, ip = _e.ip, latitude = _e.latitude, longitude = _e.longitude, country_code = _e.country_code;
84
84
  countries = sortCountries(list);
85
85
  if (config) {
86
- _f = config, operator_1 = _f.operator, scope = _f.scope, data = _f.data, lead = _f.lead, board = _f.board, interfaceData = _f.interface, redirect = _f.redirect, post = _f.post, platforms = _f.platforms;
86
+ _f = config, operator_1 = _f.operator, scope = _f.scope, data = _f.data, lead = _f.lead, board = _f.board, interfaceData = _f.interface, redirect = _f.redirect, post = _f.post, platforms = _f.platforms, payment_provider = _f.payment_provider;
87
87
  _g = interfaceData || {}, locale_1 = _g.locale, edges = _g.edges;
88
88
  if (locale_1)
89
89
  lang = locale_1 === 'dynamic' ? getUserLanguage() : locale_1;
90
- configInfo = __assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign({}, configInfo), ((lead === null || lead === void 0 ? void 0 : lead.id) && { leadId: lead.id })), (scope && { scope: scope.toLowerCase() })), ((operator_1 === null || operator_1 === void 0 ? void 0 : operator_1.public_key) && { publicKey: operator_1.public_key })), ((post === null || post === void 0 ? void 0 : post.url) && { postURL: post.url })), ((redirect === null || redirect === void 0 ? void 0 : redirect.url) && { redirectUrl: redirect.url })), (data && { data: data })), (edges && { dialogEdgeFormat: edges })), (platforms && { platforms: platforms }));
90
+ configInfo = __assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign({}, configInfo), ((lead === null || lead === void 0 ? void 0 : lead.id) && { leadId: lead.id })), (scope && { scope: scope.toLowerCase() })), ((operator_1 === null || operator_1 === void 0 ? void 0 : operator_1.public_key) && { publicKey: operator_1.public_key })), ((post === null || post === void 0 ? void 0 : post.url) && { postURL: post.url })), ((redirect === null || redirect === void 0 ? void 0 : redirect.url) && { redirectUrl: redirect.url })), (data && { data: data })), (edges && { dialogEdgeFormat: edges })), (platforms && { platforms: platforms })), (payment_provider && { payment_provider: payment_provider }));
91
91
  matureData = 'express';
92
92
  thunkApi.dispatch(handleSetAppConfig(configInfo));
93
93
  thunkApi.dispatch(handleLanguage(lang));
@@ -449,22 +449,24 @@ export var checkAccountAvailability = createAsyncThunk('auth/checkAccountAvailab
449
449
  export var getMerchantList = createAsyncThunk('auth/getMerchantList', function (_a, thunkApi) {
450
450
  var brandInfo = _a.brandInfo, entityInfo = _a.entityInfo;
451
451
  return __awaiter(void 0, void 0, void 0, function () {
452
- var _b, settings, auth, platforms, payload, merchants, list;
453
- var _c, _d, _e;
454
- return __generator(this, function (_f) {
455
- switch (_f.label) {
452
+ var _b, settings, auth, platforms, payment_provider, payload, merchants, list;
453
+ var _c, _d, _e, _f, _g, _h;
454
+ return __generator(this, function (_j) {
455
+ switch (_j.label) {
456
456
  case 0:
457
457
  _b = thunkApi.getState(), settings = _b.settings, auth = _b.auth;
458
458
  platforms = (_e = (_d = (_c = auth.data.responseData) === null || _c === void 0 ? void 0 : _c.leadResponse) === null || _d === void 0 ? void 0 : _d.platforms) !== null && _e !== void 0 ? _e : settings.data.appConfig.platforms;
459
+ payment_provider = (_h = (_g = (_f = auth.data.responseData) === null || _f === void 0 ? void 0 : _f.leadResponse) === null || _g === void 0 ? void 0 : _g.payment_provider) !== null && _h !== void 0 ? _h : settings.data.appConfig.paymentProvider;
459
460
  payload = {
460
461
  business_entity_id: (entityInfo === null || entityInfo === void 0 ? void 0 : entityInfo.id) || '',
461
462
  brand_id: (brandInfo === null || brandInfo === void 0 ? void 0 : brandInfo.id) || '',
462
463
  create_if_not_present: true,
463
- platforms: platforms
464
+ platforms: platforms,
465
+ payment_provider: payment_provider
464
466
  };
465
467
  return [4, API.entityService.getMerchantListUsingEntityId(payload)];
466
468
  case 1:
467
- merchants = (_f.sent()).merchants;
469
+ merchants = (_j.sent()).merchants;
468
470
  list = merchants || [];
469
471
  if ((list === null || list === void 0 ? void 0 : list.length) > 1) {
470
472
  thunkApi.dispatch(handleNextScreenStep('AUTH_MERCHANT_LIST_STEP'));
@@ -281,6 +281,10 @@ export declare const createAccountAsync: import("@reduxjs/toolkit").AsyncThunk<{
281
281
  boardInfo: any;
282
282
  boardData: any;
283
283
  account: any;
284
+ } | {
285
+ account: any;
286
+ boardInfo?: undefined;
287
+ boardData?: undefined;
284
288
  } | undefined, void, {
285
289
  state?: unknown;
286
290
  dispatch?: import("redux").Dispatch<import("redux").AnyAction> | undefined;
@@ -123,7 +123,7 @@ export var retrieveLeadIdentityByIdAsync = createAsyncThunk('expressConnect/retr
123
123
  }
124
124
  if (isRegistered && !showBoard) {
125
125
  (_j = (_h = settings.data.appConfig).onFlowCompleted) === null || _j === void 0 ? void 0 : _j.call(_h, data);
126
- thunkApi.dispatch(handleOpen(false));
126
+ thunkApi.dispatch(handleCurrentActiveScreen('CONNECT_EXPRESS_ACCOUNT_ALREADY_CREATED_STEP'));
127
127
  return [2, { data: data, countryCode: countryCode }];
128
128
  }
129
129
  if (isRegistered && !(board_id && board_info_id)) {
@@ -216,22 +216,24 @@ export var retrieveAuthenticationListAsync = createAsyncThunk('connectExpress/re
216
216
  export var getMerchantListAsync = createAsyncThunk('connectExpress/getMerchantListAsync', function (_a, thunkApi) {
217
217
  var brandInfo = _a.brandInfo, entityInfo = _a.entityInfo;
218
218
  return __awaiter(void 0, void 0, void 0, function () {
219
- var _b, settings, connectExpress, platforms, payload, merchants, list;
220
- var _c, _d, _e;
221
- return __generator(this, function (_f) {
222
- switch (_f.label) {
219
+ var _b, settings, connectExpress, platforms, payment_provider, payload, merchants, list;
220
+ var _c, _d, _e, _f, _g, _h;
221
+ return __generator(this, function (_j) {
222
+ switch (_j.label) {
223
223
  case 0:
224
224
  _b = thunkApi.getState(), settings = _b.settings, connectExpress = _b.connectExpress;
225
225
  platforms = (_e = (_d = (_c = connectExpress.data.responseData) === null || _c === void 0 ? void 0 : _c.leadData) === null || _d === void 0 ? void 0 : _d.platforms) !== null && _e !== void 0 ? _e : settings.data.appConfig.platforms;
226
+ payment_provider = (_h = (_g = (_f = connectExpress.data.responseData) === null || _f === void 0 ? void 0 : _f.leadResponse) === null || _g === void 0 ? void 0 : _g.payment_provider) !== null && _h !== void 0 ? _h : settings.data.appConfig.paymentProvider;
226
227
  payload = {
227
228
  business_entity_id: (entityInfo === null || entityInfo === void 0 ? void 0 : entityInfo.id) || '',
228
229
  brand_id: (brandInfo === null || brandInfo === void 0 ? void 0 : brandInfo.id) || '',
229
230
  create_if_not_present: true,
230
- platforms: platforms
231
+ platforms: platforms,
232
+ payment_provider: payment_provider
231
233
  };
232
234
  return [4, API.entityService.getMerchantListUsingEntityId(payload)];
233
235
  case 1:
234
- merchants = (_f.sent()).merchants;
236
+ merchants = (_j.sent()).merchants;
235
237
  list = merchants || [];
236
238
  if ((list === null || list === void 0 ? void 0 : list.length) > 1) {
237
239
  thunkApi.dispatch(handleNextScreenStep('CONNECT_EXPRESS_AUTH_MERCHANT_LIST_STEP'));
@@ -861,41 +863,50 @@ export var checkBrandNameAvailabilityAsync = createAsyncThunk('connectExpress/ch
861
863
  });
862
864
  });
863
865
  export var createAccountAsync = createAsyncThunk('connectExpress/createAccountAsync', function (_, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
864
- var _a, connectExpress, settings, _b, responseData, showBoard, _c, postURL, scope, platforms, body, data, leadData, board_id, board_info_id, _d, boardInfo, boardData;
865
- var _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
866
- return __generator(this, function (_q) {
867
- switch (_q.label) {
866
+ var _a, connectExpress, settings, _b, responseData, showBoard, _c, postURL, scope, redirectUrl, mode, platforms, payment_provider, authId, bi, body, data, leadData, board_id, board_info_id, _d, boardInfo, boardData, urlQueryStart;
867
+ var _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
868
+ return __generator(this, function (_u) {
869
+ switch (_u.label) {
868
870
  case 0:
869
871
  _a = thunkApi.getState(), connectExpress = _a.connectExpress, settings = _a.settings;
870
872
  _b = connectExpress.data, responseData = _b.responseData, showBoard = _b.showBoard;
871
- _c = settings.data.appConfig, postURL = _c.postURL, scope = _c.scope;
873
+ _c = settings.data.appConfig, postURL = _c.postURL, scope = _c.scope, redirectUrl = _c.redirectUrl, mode = _c.mode;
872
874
  platforms = (_f = (_e = responseData === null || responseData === void 0 ? void 0 : responseData.leadData) === null || _e === void 0 ? void 0 : _e.platforms) !== null && _f !== void 0 ? _f : settings.data.appConfig.platforms;
875
+ payment_provider = (_h = (_g = responseData === null || responseData === void 0 ? void 0 : responseData.leadResponse) === null || _g === void 0 ? void 0 : _g.payment_provider) !== null && _h !== void 0 ? _h : settings.data.appConfig.paymentProvider;
876
+ authId = (_k = (_j = responseData === null || responseData === void 0 ? void 0 : responseData.authData) === null || _j === void 0 ? void 0 : _j.auth) === null || _k === void 0 ? void 0 : _k.id;
877
+ bi = settings.data.deviceInfo.browser.browser_id;
873
878
  body = {
874
879
  lead_id: responseData === null || responseData === void 0 ? void 0 : responseData.leadData.id,
875
880
  post_url: scope === SCOPE_AUTH ? '' : postURL || '',
876
- platforms: platforms
881
+ platforms: platforms,
882
+ payment_provider: payment_provider
877
883
  };
878
884
  return [4, API.accountService.expressCreateAccount(body)];
879
885
  case 1:
880
- data = _q.sent();
881
- (_h = (_g = settings.data.appConfig).onCreated) === null || _h === void 0 ? void 0 : _h.call(_g, data);
882
- (_k = (_j = settings.data.appConfig).onFlowCompleted) === null || _k === void 0 ? void 0 : _k.call(_j, data);
883
- (_m = (_l = settings.data.appConfig).onStepCompleted) === null || _m === void 0 ? void 0 : _m.call(_l, settings.data.activeScreen.name, data);
886
+ data = _u.sent();
887
+ (_m = (_l = settings.data.appConfig).onCreated) === null || _m === void 0 ? void 0 : _m.call(_l, data);
888
+ (_p = (_o = settings.data.appConfig).onFlowCompleted) === null || _p === void 0 ? void 0 : _p.call(_o, data);
889
+ (_r = (_q = settings.data.appConfig).onStepCompleted) === null || _r === void 0 ? void 0 : _r.call(_q, settings.data.activeScreen.name, data);
884
890
  if (!showBoard) return [3, 4];
885
891
  return [4, thunkApi.dispatch(getLeadByIdAsync(data.lead.id)).unwrap()];
886
892
  case 2:
887
- leadData = (_q.sent()).data;
888
- board_id = (_o = data.board_id) !== null && _o !== void 0 ? _o : leadData.board_id;
889
- board_info_id = (_p = data.board_info_id) !== null && _p !== void 0 ? _p : leadData.board_info_id;
893
+ leadData = (_u.sent()).data;
894
+ board_id = (_s = data.board_id) !== null && _s !== void 0 ? _s : leadData.board_id;
895
+ board_info_id = (_t = data.board_info_id) !== null && _t !== void 0 ? _t : leadData.board_info_id;
890
896
  return [4, Promise.all([
891
897
  API.boardService.retrieveBoardInfo({ id: board_id, infoId: board_info_id }),
892
898
  API.boardService.retrieveBoardDetails(board_id)
893
899
  ])];
894
900
  case 3:
895
- _d = _q.sent(), boardInfo = _d[0], boardData = _d[1];
901
+ _d = _u.sent(), boardInfo = _d[0], boardData = _d[1];
896
902
  sleep(100).then(function () { return thunkApi.dispatch(handleNextScreenStep()); });
897
903
  return [2, { boardInfo: boardInfo, boardData: boardData, account: data }];
898
904
  case 4:
905
+ if (redirectUrl && mode === 'page') {
906
+ urlQueryStart = redirectUrl.includes('?') ? '&' : '?';
907
+ window.open("".concat(redirectUrl).concat(urlQueryStart, "authentication_id=").concat(authId, "&bi=").concat(bi), '_self');
908
+ return [2, { account: data }];
909
+ }
899
910
  thunkApi.dispatch(handleOpen(false));
900
911
  return [2];
901
912
  }
@@ -1,14 +1,26 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import * as React from 'react';
3
3
  import { useTranslation } from 'react-i18next';
4
- import { useAppDispatch } from '../../../../hooks';
4
+ import { useAppDispatch, useAppSelector } from '../../../../hooks';
5
5
  import SuccessScreen from '../../../shared/SuccessScreen';
6
- import { handleOpen } from '../../../../app/settings';
6
+ import { handleOpen, settingsSelector } from '../../../../app/settings';
7
+ import { connectExpressSelector } from '../../../app/connectExpress/connectExpressStore';
7
8
  var AccountAlreadyCreated = function (_a) {
8
9
  var t = useTranslation().t;
9
10
  var dispatch = useAppDispatch();
11
+ var data = useAppSelector(settingsSelector).data;
12
+ var expressData = useAppSelector(connectExpressSelector).data;
10
13
  var onSuccess = function () {
14
+ var _a, _b, _c;
15
+ var _d = data.appConfig, mode = _d.mode, redirectUrl = _d.redirectUrl;
16
+ var authId = (_c = (_b = (_a = expressData === null || expressData === void 0 ? void 0 : expressData.responseData) === null || _a === void 0 ? void 0 : _a.authData) === null || _b === void 0 ? void 0 : _b.auth) === null || _c === void 0 ? void 0 : _c.id;
17
+ var bi = data.deviceInfo.browser.browser_id;
11
18
  dispatch(handleOpen(false));
19
+ if (redirectUrl && mode === 'page') {
20
+ var urlQueryStart = redirectUrl.includes('?') ? '&' : '?';
21
+ window.open("".concat(redirectUrl).concat(urlQueryStart, "authentication_id=").concat(authId, "&bi=").concat(bi), '_self');
22
+ return { account: data };
23
+ }
12
24
  };
13
25
  return (_jsx(SuccessScreen, { title: t('express_account_already_created_title'), description: t('express_account_already_created_description'), onSuccess: onSuccess, successTitle: t('express_account_already_created_close_button') }));
14
26
  };
@@ -8,5 +8,5 @@ interface AppConfigProps extends LibConfig {
8
8
  configToken?: string;
9
9
  onVerifyConfigTokenSuccess?: (data: ConfigInfo) => Promise<void>;
10
10
  }
11
- export declare const useAppConfig: ({ appInfo, navigation, publicKey, disableCountries, disableLocale, disableSettingFetching, maturity, boardMaturity, configToken, onVerifyConfigTokenSuccess, scope, ...rest }: AppConfigProps) => void;
11
+ export declare const useAppConfig: ({ appInfo, navigation, publicKey, disableCountries, disableLocale, disableSettingFetching, maturity, boardMaturity, configToken, onVerifyConfigTokenSuccess, scope, mode, ...rest }: AppConfigProps) => void;
12
12
  export {};
@@ -26,12 +26,12 @@ import { useAppDispatch } from './useAppDispatch';
26
26
  import { useAppSelector } from './useAppSelector';
27
27
  import { isConnectTapDomain, removeRequestHeaders, setBaseUrl } from '../utils';
28
28
  export var useAppConfig = function (_a) {
29
- var appInfo = _a.appInfo, navigation = _a.navigation, publicKey = _a.publicKey, disableCountries = _a.disableCountries, disableLocale = _a.disableLocale, disableSettingFetching = _a.disableSettingFetching, maturity = _a.maturity, boardMaturity = _a.boardMaturity, configToken = _a.configToken, onVerifyConfigTokenSuccess = _a.onVerifyConfigTokenSuccess, scope = _a.scope, rest = __rest(_a, ["appInfo", "navigation", "publicKey", "disableCountries", "disableLocale", "disableSettingFetching", "maturity", "boardMaturity", "configToken", "onVerifyConfigTokenSuccess", "scope"]);
29
+ var appInfo = _a.appInfo, navigation = _a.navigation, publicKey = _a.publicKey, disableCountries = _a.disableCountries, disableLocale = _a.disableLocale, disableSettingFetching = _a.disableSettingFetching, maturity = _a.maturity, boardMaturity = _a.boardMaturity, configToken = _a.configToken, onVerifyConfigTokenSuccess = _a.onVerifyConfigTokenSuccess, scope = _a.scope, mode = _a.mode, rest = __rest(_a, ["appInfo", "navigation", "publicKey", "disableCountries", "disableLocale", "disableSettingFetching", "maturity", "boardMaturity", "configToken", "onVerifyConfigTokenSuccess", "scope", "mode"]);
30
30
  var dispatch = useAppDispatch();
31
31
  var data = useAppSelector(settingsSelector).data;
32
32
  var setAppConfig = function () {
33
33
  if (!disableSettingFetching) {
34
- dispatch(handleSetAppConfig(__assign({ appInfo: appInfo, publicKey: publicKey, scope: scope === null || scope === void 0 ? void 0 : scope.toLowerCase() }, rest)));
34
+ dispatch(handleSetAppConfig(__assign({ appInfo: appInfo, publicKey: publicKey, scope: scope === null || scope === void 0 ? void 0 : scope.toLowerCase(), mode: mode !== null && mode !== void 0 ? mode : 'page' }, rest)));
35
35
  }
36
36
  dispatch(handleActiveFlowScreens(navigation));
37
37
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tap-payments/auth-jsconnect",
3
- "version": "2.7.4-test",
3
+ "version": "2.7.6-test",
4
4
  "description": "connect library, auth",
5
5
  "private": false,
6
6
  "main": "build/index.js",