ouisys-engine 2.1.19 → 2.1.24
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.
- package/dist/api/click2sms.js +357 -0
- package/dist/api/index.d.ts +1 -3
- package/dist/api/index.js +93 -169
- package/dist/api/mo.js +274 -0
- package/dist/api/moRedir.js +186 -0
- package/dist/api/oneClick.js +366 -0
- package/dist/api/pin.js +493 -0
- package/dist/api/strategies.js +704 -0
- package/dist/api/ussd.js +1 -0
- package/dist/app/store.js +35 -0
- package/dist/common-types/AppThunk.d.ts +1 -2
- package/dist/features/strategies/categories/askMobileNumber.js +395 -0
- package/dist/features/strategies/categories/askOperator.js +311 -0
- package/dist/features/strategies/categories/detectOperatorByIp.js +606 -0
- package/dist/features/strategies/categories/headerEnrichment.js +670 -0
- package/dist/features/strategies/categories/typings/click2smsSliceTypes.js +12 -0
- package/dist/features/strategies/categories/typings/identifySliceTypes.js +22 -0
- package/dist/features/strategies/categories/typings/moFlowSliceTypes.js +22 -0
- package/dist/features/strategies/categories/typings/moRedirFlowSliceTypes.js +21 -0
- package/dist/features/strategies/categories/typings/oneClickSliceTypes.js +13 -0
- package/dist/features/strategies/categories/typings/pinFlowSliceTypes.js +13 -0
- package/dist/features/strategies/click2smsFlowSlice.js +172 -0
- package/dist/features/strategies/identifySlice.js +455 -0
- package/dist/features/strategies/moFlowSlice.js +196 -0
- package/dist/features/strategies/moRedirFlowSlice.js +190 -0
- package/dist/features/strategies/oneClickFlowSlice.js +277 -0
- package/dist/features/strategies/pinFlowSlice.js +313 -0
- package/dist/features/strategies/ussdFlowSlice.js +1 -0
- package/dist/flows/strategy.d.ts +1 -2
- package/dist/flows/strategy.js +1 -5
- package/dist/ips/tryGetIPRangeName.js +14 -13
- package/dist/mockServer/browser.js +48 -0
- package/dist/mockServer/handlers.js +22 -0
- package/dist/mockServer/server.js +48 -0
- package/dist/pacman/index.js +0 -1
- package/dist/reducers/click2smsFlow/utils.js +1 -3
- package/dist/reducers/oneClickFlow/utils.js +8 -7
- package/dist/reducers/pinFlow/utils.js +16 -15
- package/dist/reducers/strategy/strategies/header_enrichment.js +31 -25
- package/dist/reducers/strategy/utils.js +11 -12
- package/dist/reducers/tpayHeFlow/utils.js +1 -1
- package/dist/store/index.d.ts +1 -2
- package/dist/store/reducers.d.ts +0 -2
- package/dist/store/reducers.js +1 -4
- package/dist/test/setup.js +24 -0
- package/dist/test/test-utils.js +51 -0
- package/package.json +1 -1
- package/src/@types/window.d.ts +1 -0
- package/src/api/index.ts +4 -37
- package/src/common-types/AppThunk.ts +1 -2
- package/src/flows/strategy.ts +1 -5
- package/src/ips/tryGetIPRangeName.ts +3 -2
- package/src/pacman/index.ts +1 -1
- package/src/reducers/click2smsFlow/utils.ts +0 -3
- package/src/reducers/oneClickFlow/utils.ts +3 -2
- package/src/reducers/pinFlow/utils.ts +3 -1
- package/src/reducers/strategy/strategies/header_enrichment.ts +14 -11
- package/src/reducers/strategy/utils.ts +1 -2
- package/src/store/index.ts +1 -2
- package/src/store/reducers.ts +1 -5
- package/src/flows/tpayHeFlow.ts +0 -20
- package/src/reducers/tpayHeFlow/ITpayHeConstants.ts +0 -7
- package/src/reducers/tpayHeFlow/TpayHeTypes.ts +0 -135
- package/src/reducers/tpayHeFlow/index.ts +0 -207
- package/src/reducers/tpayHeFlow/utils.ts +0 -311
|
@@ -124,6 +124,3 @@ export async function checkSubscription(window: Window, maybeConfig: IConfig): P
|
|
|
124
124
|
throw error
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
|
-
|
|
128
|
-
// {"success":true,"uid":"*5QADM","shortcode":"1901","keyword":"TIPS"}%
|
|
129
|
-
// curl "http://w1.mozzi.com/spa-api/?country=gh&device=smart&slug=18plus-oc2sms&action=oc2sms"
|
|
@@ -95,10 +95,11 @@ export const getRedirectUrl = async(window:Window, maybeConfig: IConfig, extraP
|
|
|
95
95
|
|
|
96
96
|
|
|
97
97
|
export const subscribe:(url:string, extraParams?:IHash)=>Promise<string> = async(url:string, extraParams?:IHash)=>{
|
|
98
|
-
|
|
98
|
+
const evinaTid = (typeof window != "undefined" && window.tid) ? window.tid : "";
|
|
99
99
|
const extraParamsQs = !extraParams ? '' : '&' + Object.keys(extraParams).map(k => `${k}=${extraParams[k]}`).join('&')
|
|
100
100
|
|
|
101
|
-
|
|
101
|
+
|
|
102
|
+
const result:ISubscribeResult = await fetch(`${url}&sam_evina_tid=${evinaTid}${extraParamsQs}`).then((x)=>x.json())
|
|
102
103
|
|
|
103
104
|
if(false === result.success){
|
|
104
105
|
const subscribeError = new Error(`Error in subscribe() one-click-subscribe action:\n${result.message}`) as {productUrl:string} & IError;
|
|
@@ -171,7 +171,9 @@ export async function submitPIN(window:Window, pin: string, config:IConfig, extr
|
|
|
171
171
|
throw emptyPinError
|
|
172
172
|
}
|
|
173
173
|
const uniqid = uniqidResult != "" ? `&mcpUniqid=${uniqidResult}` : '';
|
|
174
|
-
const
|
|
174
|
+
const evinaTid = (typeof window != "undefined" && window.tid) ? window.tid : "";
|
|
175
|
+
|
|
176
|
+
const pinResult: IPINSubmissionResult = await window.tallymanApi.verifyPin(host, country, slug, device, offer, rockmanId, pin, extraParamsQs, uniqid, evinaTid)
|
|
175
177
|
if (false === pinResult.success) {
|
|
176
178
|
const pinError = new Error(`Error in submitMSISDN() verify-pin action:\n${pinResult.message}`) as IError & {type:string}
|
|
177
179
|
pinError['type'] = "InvalidPIN";
|
|
@@ -71,7 +71,8 @@ export const pin_header_enrichment = (defaultFlow:IFlow):AppThunk=>{
|
|
|
71
71
|
if(heResult.msisdn !== undefined && heResult.msisdn !== ""){
|
|
72
72
|
const msisdn = heResult.msisdn;
|
|
73
73
|
const operator = heResult.operator;
|
|
74
|
-
tracker.
|
|
74
|
+
tracker.customEvent('Flow', 'advance-auto', 'msisdn-detected', {msisdn})
|
|
75
|
+
|
|
75
76
|
tracker.sendOptInFlowEvent("Hybrid Pin")
|
|
76
77
|
return dispatch({
|
|
77
78
|
type:"IDENTIFY_FLOW_BY_HE",
|
|
@@ -101,7 +102,7 @@ export const pin_header_enrichment = (defaultFlow:IFlow):AppThunk=>{
|
|
|
101
102
|
}
|
|
102
103
|
}catch(err){
|
|
103
104
|
console.warn(err)
|
|
104
|
-
tracker.
|
|
105
|
+
tracker.customEvent('Flow', 'advance-auto', 'msisdn-detection-failure', {errorType: err.toString()})
|
|
105
106
|
tracker.sendOptInFlowEvent("Pin")
|
|
106
107
|
|
|
107
108
|
dispatch({
|
|
@@ -183,9 +184,9 @@ export const he_pin_one_click_header_enrichment = (defaultFlow:IFlow):AppThunk=>
|
|
|
183
184
|
}
|
|
184
185
|
}
|
|
185
186
|
let ipRangeName = await tryGetIPRangeName(window.pac_analytics.visitor);
|
|
186
|
-
console.log("IP ipRangeName", ipRangeName);
|
|
187
187
|
|
|
188
188
|
if (ipRangeName == null) {
|
|
189
|
+
tracker.sendOptInFlowEvent("Pin")
|
|
189
190
|
return dispatch({
|
|
190
191
|
type:"IDENTIFY_FLOW_BY_HE",
|
|
191
192
|
payload:{
|
|
@@ -209,7 +210,7 @@ export const he_pin_one_click_header_enrichment = (defaultFlow:IFlow):AppThunk=>
|
|
|
209
210
|
|
|
210
211
|
const operator = heResult.operator ? heResult.operator.toUpperCase() : ipRangeName.toUpperCase()
|
|
211
212
|
if(msisdn && msisdn !== ""){
|
|
212
|
-
tracker.
|
|
213
|
+
tracker.customEvent('Flow', 'advance-auto', 'msisdn-detected', {msisdn})
|
|
213
214
|
const flowObj = determineFlowByOperator(operator);
|
|
214
215
|
switchState({flowObj, msisdn, operator, subscription_url, redirect_url})
|
|
215
216
|
}else{
|
|
@@ -217,6 +218,7 @@ export const he_pin_one_click_header_enrichment = (defaultFlow:IFlow):AppThunk=>
|
|
|
217
218
|
switchState({flowObj, redirect_url, subscription_url, operator})
|
|
218
219
|
}
|
|
219
220
|
}else{
|
|
221
|
+
tracker.sendOptInFlowEvent("Pin")
|
|
220
222
|
return dispatch({
|
|
221
223
|
type:"IDENTIFY_FLOW_BY_HE",
|
|
222
224
|
payload:{
|
|
@@ -232,7 +234,7 @@ export const he_pin_one_click_header_enrichment = (defaultFlow:IFlow):AppThunk=>
|
|
|
232
234
|
|
|
233
235
|
}catch(err){
|
|
234
236
|
console.warn(err)
|
|
235
|
-
tracker.
|
|
237
|
+
tracker.customEvent('Flow', 'advance-auto', 'msisdn-detection-failure', {errorType: err.toString()})
|
|
236
238
|
tracker.sendOptInFlowEvent("Pin")
|
|
237
239
|
dispatch({
|
|
238
240
|
type:"IDENTIFY_FLOW_BY_HE",
|
|
@@ -310,9 +312,9 @@ export const he_mo_redir_one_click_header_enrichment = (defaultFlow:IFlow):AppTh
|
|
|
310
312
|
}
|
|
311
313
|
}
|
|
312
314
|
let ipRangeName = await tryGetIPRangeName(window.pac_analytics.visitor);
|
|
313
|
-
console.log("IP ipRangeName", ipRangeName);
|
|
314
315
|
|
|
315
316
|
if (ipRangeName == null) {
|
|
317
|
+
tracker.sendOptInFlowEvent("Redirect")
|
|
316
318
|
return dispatch({
|
|
317
319
|
type:"IDENTIFY_FLOW_BY_HE",
|
|
318
320
|
payload:{
|
|
@@ -336,7 +338,7 @@ export const he_mo_redir_one_click_header_enrichment = (defaultFlow:IFlow):AppTh
|
|
|
336
338
|
|
|
337
339
|
const operator = heResult.operator ? heResult.operator.toUpperCase() : ipRangeName.toUpperCase()
|
|
338
340
|
if(msisdn && msisdn !== ""){
|
|
339
|
-
tracker.
|
|
341
|
+
tracker.customEvent('Flow', 'advance-auto', 'msisdn-detected', {msisdn})
|
|
340
342
|
const flowObj = determineFlowByOperator(operator);
|
|
341
343
|
switchState({flowObj, msisdn, operator, subscription_url, redirect_url})
|
|
342
344
|
}else{
|
|
@@ -344,6 +346,7 @@ export const he_mo_redir_one_click_header_enrichment = (defaultFlow:IFlow):AppTh
|
|
|
344
346
|
switchState({flowObj, redirect_url, subscription_url, operator})
|
|
345
347
|
}
|
|
346
348
|
}else{
|
|
349
|
+
tracker.sendOptInFlowEvent("Redirect")
|
|
347
350
|
return dispatch({
|
|
348
351
|
type:"IDENTIFY_FLOW_BY_HE",
|
|
349
352
|
payload:{
|
|
@@ -359,8 +362,8 @@ export const he_mo_redir_one_click_header_enrichment = (defaultFlow:IFlow):AppTh
|
|
|
359
362
|
|
|
360
363
|
}catch(err){
|
|
361
364
|
console.warn(err)
|
|
362
|
-
tracker.
|
|
363
|
-
tracker.sendOptInFlowEvent("
|
|
365
|
+
tracker.customEvent('Flow', 'advance-auto', 'msisdn-detection-failure', {errorType: err.toString()})
|
|
366
|
+
tracker.sendOptInFlowEvent("Redirect")
|
|
364
367
|
dispatch({
|
|
365
368
|
type:"IDENTIFY_FLOW_BY_HE",
|
|
366
369
|
payload:{
|
|
@@ -442,7 +445,7 @@ export const he_pin_mo_redir_header_enrichment = (defaultFlow:IFlow):AppThunk=>{
|
|
|
442
445
|
const msisdn = heResult.msisdn;
|
|
443
446
|
const operator = heResult.operator;
|
|
444
447
|
|
|
445
|
-
tracker.
|
|
448
|
+
tracker.customEvent('Flow', 'advance-auto', 'msisdn-detected', {msisdn})
|
|
446
449
|
|
|
447
450
|
if(!!operator && operator !== ""){
|
|
448
451
|
const flowObj = determineFlowByOperator(operator);
|
|
@@ -458,7 +461,7 @@ export const he_pin_mo_redir_header_enrichment = (defaultFlow:IFlow):AppThunk=>{
|
|
|
458
461
|
}
|
|
459
462
|
}catch(err){
|
|
460
463
|
console.warn(err)
|
|
461
|
-
tracker.
|
|
464
|
+
tracker.customEvent('Flow', 'advance-auto', 'msisdn-detection-failure', {errorType: err.toString()})
|
|
462
465
|
|
|
463
466
|
try{
|
|
464
467
|
const flowObj = await determineFlowByOperatorFromIp()
|
|
@@ -225,7 +225,6 @@ export const identifyUser = async(extraParams?:ILinkExtraParams):
|
|
|
225
225
|
return {redirect_url, msisdn:msisdn, operator:operator}
|
|
226
226
|
}
|
|
227
227
|
}else{
|
|
228
|
-
console.log("newUrl",window.location.href)
|
|
229
228
|
const newUrl = new URL(window.location.href);
|
|
230
229
|
const queryString = newUrl.search;
|
|
231
230
|
const urlParams = new URLSearchParams(queryString);
|
|
@@ -237,7 +236,7 @@ export const identifyUser = async(extraParams?:ILinkExtraParams):
|
|
|
237
236
|
|
|
238
237
|
}
|
|
239
238
|
}else{
|
|
240
|
-
const url = `https://${newHost}/tallyman/v1/?action=identify-user&country=${bupperizeCountry(country)}&slug=${slug}&device=${device}&offerId=${offer}&page=${window.location.href}&pixel_url=${encodeURIComponent(`http
|
|
239
|
+
const url = `https://${newHost}/tallyman/v1/?action=identify-user&country=${bupperizeCountry(country)}&slug=${slug}&device=${device}&offerId=${offer}&page=${window.location.href}&pixel_url=${encodeURIComponent(`http://${window.location.host}/pixels?xcid=${window.location.pathname.replace("/", "")}&xaid=${window.pac_analytics.visitor.xaid}&country=${bupperizeCountry(country)}`)}&rockman_id=${rockmanId}${extraParamsQs}&${search}`
|
|
241
240
|
|
|
242
241
|
const result = await fetchJsonp<IStrategyIDentifyUserResult>(url);
|
|
243
242
|
if(false === result.success){
|
package/src/store/index.ts
CHANGED
|
@@ -13,10 +13,9 @@ import { IMoRedirActions } from "../reducers/moRedirFlow/MoRedirTypes";
|
|
|
13
13
|
import { IOneClickActions } from "../reducers/oneClickFlow/OneClickTypes";
|
|
14
14
|
import { RealTallyman, MockTallyman } from "../api";
|
|
15
15
|
import { IClick2SmsActions } from "../reducers/click2smsFlow/Click2smsTypes";
|
|
16
|
-
import { ITpayHeActions } from "../reducers/tpayHeFlow/TpayHeTypes";
|
|
17
16
|
import { getConfig, getOperators } from "../reducers/strategy/utils";
|
|
18
17
|
|
|
19
|
-
export type IApplicationActions = IStrategyActions | IPinActions | IMoActions | IMoRedirActions | IOneClickActions | IClick2SmsActions | IUssdActions
|
|
18
|
+
export type IApplicationActions = IStrategyActions | IPinActions | IMoActions | IMoRedirActions | IOneClickActions | IClick2SmsActions | IUssdActions;
|
|
20
19
|
|
|
21
20
|
const log = createLogger({ diff: true, collapsed: true });
|
|
22
21
|
|
package/src/store/reducers.ts
CHANGED
|
@@ -7,7 +7,6 @@ import moRedirFlow from "../reducers/moRedirFlow";
|
|
|
7
7
|
import oneClickFlow from "../reducers/oneClickFlow";
|
|
8
8
|
import click2smsFlow from "../reducers/click2smsFlow";
|
|
9
9
|
import ussdFlow from "../reducers/ussdFlow";
|
|
10
|
-
import tpayHeFlow from "../reducers/tpayHeFlow";
|
|
11
10
|
|
|
12
11
|
import { IStrategyReducerState } from "../reducers/strategy/StrategyTypes";
|
|
13
12
|
import { IPinFlowReducerState } from "../reducers/pinFlow/PinTypes";
|
|
@@ -16,7 +15,6 @@ import { IMoRedirFlowReducerState } from "../reducers/moRedirFlow/MoRedirTypes";
|
|
|
16
15
|
import { IOneClickFlowReducerState } from "../reducers/oneClickFlow/OneClickTypes";
|
|
17
16
|
import { IClick2smsFlowReducerState } from "../reducers/click2smsFlow/Click2smsTypes";
|
|
18
17
|
import { IUssdFlowReducerState } from "../reducers/ussdFlow/UssdTypes";
|
|
19
|
-
import { ITpayHeFlowReducerState } from "../reducers/tpayHeFlow/TpayHeTypes";
|
|
20
18
|
|
|
21
19
|
|
|
22
20
|
export interface IApplicationState {
|
|
@@ -27,7 +25,6 @@ export interface IApplicationState {
|
|
|
27
25
|
oneClickFlow:IOneClickFlowReducerState;
|
|
28
26
|
click2smsFlow:IClick2smsFlowReducerState;
|
|
29
27
|
ussdFlow:IUssdFlowReducerState;
|
|
30
|
-
tpayHeFlow:ITpayHeFlowReducerState;
|
|
31
28
|
}
|
|
32
29
|
export default() => combineReducers<IApplicationState>({
|
|
33
30
|
strategy,
|
|
@@ -36,6 +33,5 @@ export default() => combineReducers<IApplicationState>({
|
|
|
36
33
|
moRedirFlow,
|
|
37
34
|
oneClickFlow,
|
|
38
35
|
click2smsFlow,
|
|
39
|
-
ussdFlow
|
|
40
|
-
tpayHeFlow
|
|
36
|
+
ussdFlow
|
|
41
37
|
});
|
package/src/flows/tpayHeFlow.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import * as RDS from "../common-types/RemoteDataState";
|
|
2
|
-
|
|
3
|
-
import { CONFIRMTpayFailure, CONFIRMTpaySuccess, ILOADTPAYFailure, ILOADTPAYSuccess, ITpayHeCurrentState } from "../reducers/tpayHeFlow/TpayHeTypes";
|
|
4
|
-
|
|
5
|
-
function tpayHeFlowMatch <R>(
|
|
6
|
-
{ loadTpay, confirmTpay }:
|
|
7
|
-
{ loadTpay: (rds: RDS.RemoteDataState<ILOADTPAYFailure, ILOADTPAYSuccess>) => R,
|
|
8
|
-
confirmTpay: (rds: RDS.RemoteDataState<CONFIRMTpayFailure, CONFIRMTpaySuccess>) => R
|
|
9
|
-
}): (state: ITpayHeCurrentState) => R {
|
|
10
|
-
return state => {
|
|
11
|
-
switch (state.type) {
|
|
12
|
-
case 'LOAD_TPAY_HE':
|
|
13
|
-
return loadTpay(state.result)
|
|
14
|
-
case 'CONFIRM_TPAY':
|
|
15
|
-
return confirmTpay(state.result)
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export default tpayHeFlowMatch;
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import * as RDS from "../../common-types/RemoteDataState";
|
|
2
|
-
import { AppThunk } from "../../common-types/AppThunk";
|
|
3
|
-
|
|
4
|
-
export type ILOADTPAYFailure = {
|
|
5
|
-
errorType:LOADTPAYErrorTypes;
|
|
6
|
-
productUrl?:string;
|
|
7
|
-
}
|
|
8
|
-
export type ILOADTPAYSuccess = {
|
|
9
|
-
redirectUrl:string;
|
|
10
|
-
nextAction:"getRedirectUrlAction";
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export type LOADTPAYErrorTypes = "UnknownError" | "NotSupported" | "UnexpectedState" | "InvalidConfig" | "AlreadySubscribed" | "SubscriptionFailed";
|
|
14
|
-
|
|
15
|
-
export type ITpayHeCurrentState = {
|
|
16
|
-
type: "LOAD_TPAY_HE",
|
|
17
|
-
result:RDS.RemoteDataState<ILOADTPAYFailure, ILOADTPAYSuccess>
|
|
18
|
-
}
|
|
19
|
-
|
|
|
20
|
-
{
|
|
21
|
-
type: "CONFIRM_TPAY";
|
|
22
|
-
result:RDS.RemoteDataState<CONFIRMTpayFailure, CONFIRMTpaySuccess>
|
|
23
|
-
}
|
|
24
|
-
export type ITpayHeFlowReducerState =
|
|
25
|
-
{
|
|
26
|
-
currentState:ITpayHeCurrentState;
|
|
27
|
-
tpayConfig:ITpayConsentResult;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
export type ILoadTpayPayload = {
|
|
31
|
-
type:"LOAD_TPAY_HE",
|
|
32
|
-
result:RDS.RemoteDataState<ILOADTPAYFailure, ILOADTPAYSuccess>
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export type ITpayHeFlowActionMaps = {
|
|
36
|
-
loadTpayAction:(theme:string, locale:string)=>AppThunk
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
export type IConfirmTpayPayload = {
|
|
41
|
-
type: "CONFIRM_TPAY";
|
|
42
|
-
result: RDS.RemoteDataState<CONFIRMTpayFailure, CONFIRMTpaySuccess>;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export type CONFIRMTpayFailure = {
|
|
46
|
-
errorType: CONFIRMTpayErrorTypes;
|
|
47
|
-
error?: Error;
|
|
48
|
-
productUrl?:string;
|
|
49
|
-
};
|
|
50
|
-
export type CONFIRMTpaySuccess = { finalUrl: string};
|
|
51
|
-
export type CONFIRMTpayErrorTypes = "UnknownError" | "TooEarly" | "UnexpectedState" | "AlreadySubscribed" | "ConfirmError";
|
|
52
|
-
|
|
53
|
-
export type ITpayHeActions = {
|
|
54
|
-
type:"LOAD_TPAY_HE";
|
|
55
|
-
payload:ILoadTpayPayload;
|
|
56
|
-
}
|
|
57
|
-
|
|
|
58
|
-
{
|
|
59
|
-
type: "CONFIRM_TPAY_CLICK";
|
|
60
|
-
payload:IConfirmTpayPayload
|
|
61
|
-
}
|
|
62
|
-
|
|
|
63
|
-
{
|
|
64
|
-
type: "LOAD_TPAY_HE_SUCCESS";
|
|
65
|
-
payload:ILoadTpayPayload
|
|
66
|
-
}
|
|
67
|
-
|
|
|
68
|
-
{
|
|
69
|
-
type:"MOCK_TPAY_FLOW_STATE";
|
|
70
|
-
payload:ILoadTpayPayload;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
export type IConfig = {
|
|
76
|
-
host?: string, country?: string, slug?: string, queryString?: Array<[string, string]>, device?:string
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
export type ITpayConsentResult = {
|
|
80
|
-
prodSku: string;
|
|
81
|
-
lang: string;
|
|
82
|
-
country: string;
|
|
83
|
-
config: ITPayConfig;
|
|
84
|
-
redirectUrl: string;
|
|
85
|
-
subscription_url:string;
|
|
86
|
-
rid: string;
|
|
87
|
-
success: true;
|
|
88
|
-
} | {
|
|
89
|
-
success: false
|
|
90
|
-
rockman_id: string
|
|
91
|
-
message: string
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
export interface ITPayConfig {
|
|
95
|
-
product_url: string;
|
|
96
|
-
subscription_plan_id: number;
|
|
97
|
-
public: string;
|
|
98
|
-
private: string;
|
|
99
|
-
flow: string;
|
|
100
|
-
catalog_name: { [key: string]: string };
|
|
101
|
-
replace_uid?:boolean;
|
|
102
|
-
product_full_access?:string;
|
|
103
|
-
domain?:string;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
export type IRedirectResult = {
|
|
108
|
-
Status:string;
|
|
109
|
-
OperatorCode:number;
|
|
110
|
-
SessionId:number;
|
|
111
|
-
OrderId:number;
|
|
112
|
-
Details:string;
|
|
113
|
-
SubId:string;
|
|
114
|
-
Signature:string;
|
|
115
|
-
SessionToken:string;
|
|
116
|
-
rockman_id:string;
|
|
117
|
-
ReferenceCode:string;
|
|
118
|
-
Msisdn:string;
|
|
119
|
-
subscription_url:string;
|
|
120
|
-
language_code:string;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
export type IMockTpayFlowStates = "confirm-state"
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
export type ITpaySubscribeResult = {
|
|
127
|
-
success:true;
|
|
128
|
-
rockman_id: string;
|
|
129
|
-
product_url:string;
|
|
130
|
-
} |
|
|
131
|
-
{
|
|
132
|
-
success: false;
|
|
133
|
-
rockman_id: string;
|
|
134
|
-
message: string;
|
|
135
|
-
}
|
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
// LIBRARIES
|
|
2
|
-
import * as RDS from "../../common-types/RemoteDataState";
|
|
3
|
-
|
|
4
|
-
import { ITpayHeFlowReducerState, ITpayHeActions, ITpayHeFlowActionMaps, ILOADTPAYFailure, ILOADTPAYSuccess, ILoadTpayPayload, CONFIRMTpayErrorTypes, CONFIRMTpayFailure, CONFIRMTpaySuccess, ITPayConfig, ITpayConsentResult, LOADTPAYErrorTypes, IMockTpayFlowStates } from "./TpayHeTypes";
|
|
5
|
-
import { AppThunk } from "../../common-types/AppThunk";
|
|
6
|
-
import { confirmTPay, confirmTPayCheck, getTpayConfig, mockedConfirmState } from "./utils";
|
|
7
|
-
import { genericHandler, tracker } from "../strategy";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
//ACTION CREATORS
|
|
13
|
-
export function loadTpayAction(theme:string, locale:string):AppThunk{
|
|
14
|
-
return async (dispatch, store)=>{
|
|
15
|
-
const {currentState} = store().strategy
|
|
16
|
-
if(currentState.type === "TPAY_HE"){
|
|
17
|
-
const config = currentState.result.config;
|
|
18
|
-
try {
|
|
19
|
-
|
|
20
|
-
//Check if Error or Success Page
|
|
21
|
-
const product_url = await confirmTPayCheck();
|
|
22
|
-
if(product_url !== null){
|
|
23
|
-
window.location.href = product_url;
|
|
24
|
-
}else{
|
|
25
|
-
dispatch({
|
|
26
|
-
type: "LOAD_TPAY_HE",
|
|
27
|
-
payload:{
|
|
28
|
-
type: "LOAD_TPAY_HE",
|
|
29
|
-
result: RDS.Loading()
|
|
30
|
-
}
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
const result = await getTpayConfig(
|
|
34
|
-
window,
|
|
35
|
-
config
|
|
36
|
-
)
|
|
37
|
-
// await addLookUpTpay(result, theme, locale);
|
|
38
|
-
|
|
39
|
-
tracker.advancedInFlow('tallyman.v1-tpay-he', 'load-tpay-success');
|
|
40
|
-
|
|
41
|
-
dispatch({
|
|
42
|
-
type: "LOAD_TPAY_HE_SUCCESS",
|
|
43
|
-
payload:{
|
|
44
|
-
type: "LOAD_TPAY_HE",
|
|
45
|
-
result: RDS.Success(result)
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
} catch (ex) {
|
|
51
|
-
console.warn(ex);
|
|
52
|
-
//@ts-ignore
|
|
53
|
-
const errorType: LOADTPAYErrorTypes =
|
|
54
|
-
"AlreadySubscribed" === ex.type
|
|
55
|
-
? "AlreadySubscribed"
|
|
56
|
-
: "NotSupported" === ex.type
|
|
57
|
-
? "NotSupported"
|
|
58
|
-
: "SubscriptionFailed" === ex.type
|
|
59
|
-
? "SubscriptionFailed"
|
|
60
|
-
: "UnknownError";
|
|
61
|
-
|
|
62
|
-
tracker.recedeInFlow('tallyman.v1-tpay-he', 'tpay-config-failure',{errorType: errorType || 'UnknownError'})
|
|
63
|
-
dispatch({
|
|
64
|
-
type: "LOAD_TPAY_HE",
|
|
65
|
-
payload:{
|
|
66
|
-
type: "LOAD_TPAY_HE",
|
|
67
|
-
result: RDS.Failure({
|
|
68
|
-
errorType: errorType,
|
|
69
|
-
error: ex
|
|
70
|
-
})
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
dispatch({
|
|
75
|
-
type:"IDENTIFY_STRATEGY",
|
|
76
|
-
payload:{
|
|
77
|
-
type:"PIN",
|
|
78
|
-
result: {
|
|
79
|
-
nextAction:"submitMSISDNAction",
|
|
80
|
-
config:config
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
}else{
|
|
86
|
-
tracker.recedeInFlow('tallyman.v1-tpay-he', 'tpay-config-failure',{errorType: 'UnknownError'})
|
|
87
|
-
dispatch({
|
|
88
|
-
type: "LOAD_TPAY_HE",
|
|
89
|
-
payload:{
|
|
90
|
-
type: "LOAD_TPAY_HE",
|
|
91
|
-
result: RDS.Failure({
|
|
92
|
-
errorType:"UnexpectedState"
|
|
93
|
-
})
|
|
94
|
-
}
|
|
95
|
-
})
|
|
96
|
-
throw "Unexpected state";
|
|
97
|
-
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
export function confirmTpayAction(locale:string, redirectUrl?:string):AppThunk{
|
|
104
|
-
return async (dispatch, store)=>{
|
|
105
|
-
try {
|
|
106
|
-
dispatch({
|
|
107
|
-
type: "CONFIRM_TPAY_CLICK",
|
|
108
|
-
payload:{
|
|
109
|
-
type: "CONFIRM_TPAY",
|
|
110
|
-
result: RDS.Loading()
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
tracker.advancedInFlow('tallyman.v1-tpay-he', 'confirm-tpay-clicked',{})
|
|
114
|
-
const {currentState} = store().strategy
|
|
115
|
-
if(currentState.type === "TPAY_HE"){
|
|
116
|
-
const {tpayConfig} = store().tpayHeFlow
|
|
117
|
-
//@ts-ignore
|
|
118
|
-
const result = await confirmTPay(window, tpayConfig, locale, redirectUrl)
|
|
119
|
-
tracker.advancedInFlow('tallyman.v1-tpay-he', 'confirm-tpay-success',{finalUrl: result})
|
|
120
|
-
|
|
121
|
-
dispatch({
|
|
122
|
-
type: "CONFIRM_TPAY_CLICK",
|
|
123
|
-
payload:{
|
|
124
|
-
type:"CONFIRM_TPAY",
|
|
125
|
-
result: RDS.Success<CONFIRMTpayFailure, CONFIRMTpaySuccess>({
|
|
126
|
-
finalUrl: ""
|
|
127
|
-
})
|
|
128
|
-
}
|
|
129
|
-
})
|
|
130
|
-
}else{
|
|
131
|
-
tracker.recedeInFlow('tallyman.v1-tpay-he', 'confirm-tpay-failure',{})
|
|
132
|
-
dispatch({
|
|
133
|
-
type: "CONFIRM_TPAY_CLICK",
|
|
134
|
-
payload:{
|
|
135
|
-
type:"CONFIRM_TPAY",
|
|
136
|
-
result: RDS.Failure<CONFIRMTpayFailure, CONFIRMTpaySuccess>({errorType: "UnexpectedState"})
|
|
137
|
-
}
|
|
138
|
-
})
|
|
139
|
-
throw "Unexpected state"
|
|
140
|
-
}
|
|
141
|
-
} catch(ex) {
|
|
142
|
-
console.error(ex)
|
|
143
|
-
const errorType: CONFIRMTpayErrorTypes =
|
|
144
|
-
"AlreadySubscribed" === ex.type
|
|
145
|
-
? "AlreadySubscribed"
|
|
146
|
-
: "ConfirmError" === ex.type
|
|
147
|
-
? "ConfirmError"
|
|
148
|
-
: "UnknownError";
|
|
149
|
-
tracker.recedeInFlow('tallyman.v1-tpay-he', 'confirm-tpay',{errorType: errorType || 'UnknownError'})
|
|
150
|
-
|
|
151
|
-
dispatch({
|
|
152
|
-
type: "CONFIRM_TPAY_CLICK",
|
|
153
|
-
payload:{
|
|
154
|
-
type:"CONFIRM_TPAY",
|
|
155
|
-
result: RDS.Failure<CONFIRMTpayFailure, CONFIRMTpaySuccess>({errorType: errorType || 'UnknownError'})
|
|
156
|
-
}
|
|
157
|
-
})
|
|
158
|
-
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
export function mockTpayFlow(mockState:IMockTpayFlowStates):AppThunk {
|
|
166
|
-
return (dispatch)=>{
|
|
167
|
-
if(mockState !== undefined){
|
|
168
|
-
switch (mockState) {
|
|
169
|
-
case "confirm-state":
|
|
170
|
-
return dispatch({
|
|
171
|
-
type:"MOCK_TPAY_FLOW_STATE",
|
|
172
|
-
payload:mockedConfirmState.currentState
|
|
173
|
-
})
|
|
174
|
-
default:
|
|
175
|
-
throw "Mock Flow not supported";
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
const initialState:ITpayHeFlowReducerState = {
|
|
183
|
-
currentState:{
|
|
184
|
-
type: "LOAD_TPAY_HE",
|
|
185
|
-
result: RDS.NothingYet<ILOADTPAYFailure, ILOADTPAYSuccess>()
|
|
186
|
-
},
|
|
187
|
-
tpayConfig:null
|
|
188
|
-
};
|
|
189
|
-
export const TpayHeFlowFlowActionMaps:ITpayHeFlowActionMaps = {
|
|
190
|
-
loadTpayAction:loadTpayAction
|
|
191
|
-
}
|
|
192
|
-
export default function TpayHeFlowReducer(state = initialState, action:ITpayHeActions) {
|
|
193
|
-
switch (action.type) {
|
|
194
|
-
case "LOAD_TPAY_HE":
|
|
195
|
-
return genericHandler<ITpayHeFlowReducerState, ILoadTpayPayload>(state, action.payload)
|
|
196
|
-
case "CONFIRM_TPAY_CLICK":
|
|
197
|
-
//@ts-ignore
|
|
198
|
-
return genericHandler<ITpayHeFlowReducerState, ILoadTpayPayload>(state, action.payload)
|
|
199
|
-
case "LOAD_TPAY_HE_SUCCESS":
|
|
200
|
-
return genericHandler<ITpayHeFlowReducerState, ILoadTpayPayload>(state, action.payload)
|
|
201
|
-
case "MOCK_TPAY_FLOW_STATE":
|
|
202
|
-
//@ts-ignore
|
|
203
|
-
return handleMockFlow<ITpayHeFlowReducerState, any>(state, action.payload)
|
|
204
|
-
default:
|
|
205
|
-
return state;
|
|
206
|
-
}
|
|
207
|
-
}
|