ouisys-engine 2.1.22 → 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.
@@ -8,9 +8,8 @@ import IMoRedirConstants from "../reducers/moRedirFlow/IMoRedirConstants";
8
8
  import IOneClickConstants from "../reducers/oneClickFlow/IOneClickConstants";
9
9
  import IClick2smsConstants from "../reducers/click2smsFlow/IClick2smsConstants";
10
10
  import IUssdConstants from "../reducers/ussdFlow/IUssdConstants";
11
- import ITpayHeConstants from "../reducers/tpayHeFlow/ITpayHeConstants";
12
11
 
13
- type IAllActionConstants = IStategyActionContants | IPinConstants | IMoConstants | IMoRedirConstants | IOneClickConstants | IClick2smsConstants | IUssdConstants | ITpayHeConstants;
12
+ type IAllActionConstants = IStategyActionContants | IPinConstants | IMoConstants | IMoRedirConstants | IOneClickConstants | IClick2smsConstants | IUssdConstants;
14
13
 
15
14
  export type AppThunk<ReturnType = void> = ThunkAction<
16
15
  ReturnType,
@@ -12,8 +12,7 @@ function strategy<R>(
12
12
  moRedirFlow,
13
13
  oneClickFlow,
14
14
  click2smsFlow,
15
- ussdFlow,
16
- tpayHeFlow
15
+ ussdFlow
17
16
  }:
18
17
  {
19
18
  identifyFlowByOperatorSelect: (data: OPERATORSelectFlowIdentifySuccess) => R,
@@ -24,7 +23,6 @@ function strategy<R>(
24
23
  oneClickFlow: (data: IdentifyFlowOptionsResult<"getRedirectUrlAction">) => R
25
24
  click2smsFlow: (data: IdentifyFlowOptionsResult<"loadOc2sms">) => R,
26
25
  ussdFlow: (data: IdentifyFlowOptionsResult<"submitMSISDNAction">) => R,
27
- tpayHeFlow: (data: IdentifyFlowOptionsResult<"loadTpayAction">) => R,
28
26
  }): (state: IStrategyCurrentState) => R {
29
27
 
30
28
 
@@ -46,8 +44,6 @@ function strategy<R>(
46
44
  return click2smsFlow(state.result);
47
45
  case 'USSD':
48
46
  return ussdFlow(state.result);
49
- case 'TPAY_HE':
50
- return tpayHeFlow(state.result);
51
47
  }
52
48
  }
53
49
  }
@@ -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 | ITpayHeActions;
18
+ export type IApplicationActions = IStrategyActions | IPinActions | IMoActions | IMoRedirActions | IOneClickActions | IClick2SmsActions | IUssdActions;
20
19
 
21
20
  const log = createLogger({ diff: true, collapsed: true });
22
21
 
@@ -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
  });
@@ -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,7 +0,0 @@
1
- type ITpayHeConstants = "LOAD_TPAY_HE" |
2
- "CONFIRM_TPAY"
3
- | "CONFIRM_TPAY_CLICK"
4
- | "LOAD_TPAY_HE_SUCCESS"
5
- | "MOCK_TPAY_FLOW_STATE"
6
-
7
- export default ITpayHeConstants
@@ -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
- }