@frontegg/redux-store 5.21.0 → 5.22.0
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/auth/AcceptInvitationState/index.d.ts +2 -0
- package/auth/AccountSettingsState/index.d.ts +10 -0
- package/auth/ActivateState/index.d.ts +3 -0
- package/auth/ApiTokensState/index.d.ts +2 -0
- package/auth/ForgotPasswordState/index.d.ts +2 -0
- package/auth/LoginState/index.d.ts +2 -0
- package/auth/LoginState/interfaces.d.ts +2 -0
- package/auth/LoginState/saga.d.ts +2 -0
- package/auth/MfaState/index.d.ts +6 -6
- package/auth/ProfileState/index.d.ts +2 -0
- package/auth/ResetPhoneNumberState/index.d.ts +96 -0
- package/auth/ResetPhoneNumberState/interfaces.d.ts +18 -0
- package/auth/ResetPhoneNumberState/saga.d.ts +17 -0
- package/auth/RolesState/index.d.ts +2 -0
- package/auth/SSOState/index.d.ts +2 -0
- package/auth/SecurityPolicyState/index.d.ts +9 -0
- package/auth/SignUp/index.d.ts +2 -0
- package/auth/SocialLogins/index.d.ts +2 -8
- package/auth/TeamState/index.d.ts +2 -0
- package/auth/TenantsState/index.d.ts +2 -8
- package/auth/index.d.ts +13 -0
- package/auth/index.js +105 -15
- package/auth/interfaces.d.ts +15 -1
- package/auth/reducer.d.ts +13 -1
- package/auth/utils.d.ts +4 -0
- package/index.js +2 -2
- package/node/auth/index.js +115 -22
- package/node/index.js +15 -0
- package/node/subscriptions/index.js +167 -127
- package/package.json +2 -2
- package/subscriptions/ManagedSubscriptions/index.d.ts +10 -0
- package/subscriptions/ManagedSubscriptions/interfaces.d.ts +28 -0
- package/subscriptions/ManagedSubscriptions/saga.d.ts +1 -0
- package/subscriptions/index.d.ts +7 -0
- package/subscriptions/index.js +168 -128
- package/subscriptions/interfaces.d.ts +4 -0
- package/subscriptions/reducer.d.ts +7 -0
- package/toolkit/index.d.ts +1 -1
package/subscriptions/index.js
CHANGED
|
@@ -39,12 +39,12 @@ const plansInitialState = {
|
|
|
39
39
|
fetching: true,
|
|
40
40
|
plans: [],
|
|
41
41
|
};
|
|
42
|
-
const { actions: sliceActions$
|
|
42
|
+
const { actions: sliceActions$2, reducer: reducer$8, name: name$7 } = createSlice({
|
|
43
43
|
name: `${subscriptionsStoreName}/plans`,
|
|
44
44
|
initialState: plansInitialState,
|
|
45
45
|
reducers: Object.assign({}, createModuleCaseReducers()),
|
|
46
46
|
});
|
|
47
|
-
const actions$
|
|
47
|
+
const actions$8 = Object.assign({ loadPlans: createAction(`${name$7}/loadPlans`) }, sliceActions$2);
|
|
48
48
|
|
|
49
49
|
const configInitialState = {
|
|
50
50
|
loading: false,
|
|
@@ -53,12 +53,12 @@ const configInitialState = {
|
|
|
53
53
|
config: null,
|
|
54
54
|
};
|
|
55
55
|
const reducers$5 = Object.assign({}, createModuleCaseReducers());
|
|
56
|
-
const { actions: configActions, reducer: reducer$
|
|
56
|
+
const { actions: configActions, reducer: reducer$7, name: name$6, } = createSlice({
|
|
57
57
|
name: `${subscriptionsStoreName}/config`,
|
|
58
58
|
initialState: configInitialState,
|
|
59
59
|
reducers: reducers$5,
|
|
60
60
|
});
|
|
61
|
-
const actions$
|
|
61
|
+
const actions$7 = Object.assign({ loadPaymentConfiguration: createAction(`${name$6}/loadPaymentConfiguration`) }, configActions);
|
|
62
62
|
|
|
63
63
|
const initialBillingInformationState = {
|
|
64
64
|
loading: false,
|
|
@@ -79,12 +79,12 @@ const reducers$4 = Object.assign(Object.assign({}, createModuleCaseReducers()),
|
|
|
79
79
|
prepare: (payload) => ({ payload }),
|
|
80
80
|
reducer: (state, action) => (Object.assign(Object.assign({}, state), action.payload)),
|
|
81
81
|
}, setCancellationLoading: createKeyCaseLoadingReducer('cancellation'), setCancellationError: createKeyCaseErrorReducer('cancellation'), setRenewalLoading: createKeyCaseLoadingReducer('renewal'), setRenewalError: createKeyCaseErrorReducer('renewal') });
|
|
82
|
-
const { reducer: reducer$
|
|
82
|
+
const { reducer: reducer$6, actions: overviewActions, name: name$5, } = createSlice({
|
|
83
83
|
name: `${subscriptionsStoreName}/billing/information`,
|
|
84
84
|
initialState: initialBillingInformationState,
|
|
85
85
|
reducers: reducers$4,
|
|
86
86
|
});
|
|
87
|
-
const actions$
|
|
87
|
+
const actions$6 = Object.assign({ loadBillingInformation: createAction(`${name$5}/loadBillingInformation`), cancelSubscription: createAction(`${name$5}/cancelSubscription`), renewSubscription: createAction(`${name$5}/renewSubscription`) }, overviewActions);
|
|
88
88
|
|
|
89
89
|
const initialPaymentMethodState = {
|
|
90
90
|
loading: false,
|
|
@@ -95,12 +95,12 @@ const reducers$3 = Object.assign(Object.assign({}, createModuleCaseReducers()),
|
|
|
95
95
|
prepare: (payload) => ({ payload }),
|
|
96
96
|
reducer: (state, action) => (Object.assign(Object.assign({}, state), action.payload)),
|
|
97
97
|
} });
|
|
98
|
-
const { reducer: reducer$
|
|
98
|
+
const { reducer: reducer$5, actions: paymentActions, name: name$4, } = createSlice({
|
|
99
99
|
name: `${subscriptionsStoreName}/billing/payment`,
|
|
100
100
|
initialState: initialPaymentMethodState,
|
|
101
101
|
reducers: reducers$3,
|
|
102
102
|
});
|
|
103
|
-
const actions$
|
|
103
|
+
const actions$5 = Object.assign({ loadPaymentMethod: createAction(`${name$4}/loadPaymentMethod`), submitPaymentMethod: createAction(`${name$4}/submitPaymentMethod`), submitPaymentMethodError: createAction(`${name$4}/submitPaymentMethodError`), submitPaymentMethodSuccess: createAction(`${name$4}/submitPaymentMethodSuccess`), updatePaymentMethodBillingDetails: createAction(`${name$4}/updateBillingDetails`, (payload) => ({ payload })) }, paymentActions);
|
|
104
104
|
|
|
105
105
|
const initialInvoicesState = {
|
|
106
106
|
loading: false,
|
|
@@ -116,12 +116,12 @@ const reducers$2 = Object.assign(Object.assign({}, createModuleCaseReducers()),
|
|
|
116
116
|
prepare: (payload) => ({ payload }),
|
|
117
117
|
reducer: (state, action) => (Object.assign(Object.assign({}, state), { invoiceDownload: Object.assign(Object.assign({}, state.invoiceDownload), action.payload) })),
|
|
118
118
|
} });
|
|
119
|
-
const { reducer: reducer$
|
|
119
|
+
const { reducer: reducer$4, actions: sliceActions$1, name: name$3, } = createSlice({
|
|
120
120
|
name: `${subscriptionsStoreName}/billing/invoices`,
|
|
121
121
|
initialState: initialInvoicesState,
|
|
122
122
|
reducers: reducers$2,
|
|
123
123
|
});
|
|
124
|
-
const actions$
|
|
124
|
+
const actions$4 = Object.assign({ loadInvoices: createAction(`${name$3}/loadInvoices`), downloadInvoice: createAction(`${name$3}/downloadInvoice`, (payload) => ({ payload })) }, sliceActions$1);
|
|
125
125
|
|
|
126
126
|
const billingInitialState = {
|
|
127
127
|
information: initialBillingInformationState,
|
|
@@ -129,14 +129,14 @@ const billingInitialState = {
|
|
|
129
129
|
paymentMethod: initialPaymentMethodState,
|
|
130
130
|
};
|
|
131
131
|
const billingActions = {
|
|
132
|
-
invoices: actions$
|
|
133
|
-
information: actions$
|
|
134
|
-
paymentMethod: actions$
|
|
132
|
+
invoices: actions$4,
|
|
133
|
+
information: actions$6,
|
|
134
|
+
paymentMethod: actions$5,
|
|
135
135
|
};
|
|
136
136
|
const billingReducer = combineReducers({
|
|
137
|
-
invoices: reducer$
|
|
138
|
-
information: reducer$
|
|
139
|
-
paymentMethod: reducer$
|
|
137
|
+
invoices: reducer$4,
|
|
138
|
+
information: reducer$6,
|
|
139
|
+
paymentMethod: reducer$5,
|
|
140
140
|
});
|
|
141
141
|
|
|
142
142
|
var CheckoutStatus;
|
|
@@ -169,12 +169,12 @@ const reducers$1 = Object.assign(Object.assign({}, createModuleCaseReducers()),
|
|
|
169
169
|
prepare: (payload) => ({ payload }),
|
|
170
170
|
reducer: (state, action) => (Object.assign(Object.assign({}, state), { checkoutPlanId: action.payload })),
|
|
171
171
|
} });
|
|
172
|
-
const { actions: checkoutActions, reducer: reducer$
|
|
172
|
+
const { actions: checkoutActions, reducer: reducer$3, name: name$2 } = createSlice({
|
|
173
173
|
name: `${subscriptionsStoreName}/checkout`,
|
|
174
174
|
initialState: checkoutInitialState,
|
|
175
175
|
reducers: reducers$1,
|
|
176
176
|
});
|
|
177
|
-
const actions$
|
|
177
|
+
const actions$3 = Object.assign({ checkoutPlan: createAction(`${name$2}/checkoutPlan`, (payload) => ({ payload })), resetCheckout: createAction(`${name$2}/resetCheckout`), confirmCheckout: createAction(`${name$2}/confirmCheckout`, (payload) => ({ payload, })), cancelCheckout: createAction(`${name$2}/cancelCheckout`), submitCheckout: createAction(`${name$2}/submitCheckout`), errorCheckout: createAction(`${name$2}/errorCheckout`, (payload) => ({ payload, })), checkoutEvent: createAction(`${name$2}/checkoutEvent`, (payload) => ({ payload, })) }, checkoutActions);
|
|
178
178
|
|
|
179
179
|
const initialSubscriptionStripeState = {
|
|
180
180
|
loading: false,
|
|
@@ -185,12 +185,26 @@ const reducers = Object.assign(Object.assign({}, createModuleCaseReducers()), {
|
|
|
185
185
|
prepare: (payload) => ({ payload }),
|
|
186
186
|
reducer: (state, action) => (Object.assign(Object.assign({}, state), action.payload)),
|
|
187
187
|
} });
|
|
188
|
-
const { reducer: reducer$
|
|
188
|
+
const { reducer: reducer$2, actions: reducerActions, name: name$1, } = createSlice({
|
|
189
189
|
name: `${subscriptionsStoreName}/stripe`,
|
|
190
190
|
initialState: initialSubscriptionStripeState,
|
|
191
191
|
reducers,
|
|
192
192
|
});
|
|
193
|
-
const actions$
|
|
193
|
+
const actions$2 = Object.assign({ loadCustomer: createAction(`${name$1}/loadCustomer`), createCardSetupIntentSecret: createAction(`${name$1}/createCardSetupIntentSecret`) }, reducerActions);
|
|
194
|
+
|
|
195
|
+
const managedSubscriptionsInitialState = {
|
|
196
|
+
loading: false,
|
|
197
|
+
error: null,
|
|
198
|
+
fetching: true,
|
|
199
|
+
managedSubscriptions: [],
|
|
200
|
+
};
|
|
201
|
+
Object.assign({}, createModuleCaseReducers());
|
|
202
|
+
const { reducer: reducer$1, actions: sliceActions, name } = createSlice({
|
|
203
|
+
name: `${subscriptionsStoreName}/managedSubscriptions`,
|
|
204
|
+
initialState: managedSubscriptionsInitialState,
|
|
205
|
+
reducers: Object.assign({}, createModuleCaseReducers()),
|
|
206
|
+
});
|
|
207
|
+
const actions$1 = Object.assign({ loadManagedSubscriptions: createAction(`${name}/loadManagedSubscriptions`) }, sliceActions);
|
|
194
208
|
|
|
195
209
|
const initialState = {
|
|
196
210
|
config: configInitialState,
|
|
@@ -198,20 +212,23 @@ const initialState = {
|
|
|
198
212
|
checkout: checkoutInitialState,
|
|
199
213
|
billing: billingInitialState,
|
|
200
214
|
stripe: initialSubscriptionStripeState,
|
|
215
|
+
managedSubscriptions: managedSubscriptionsInitialState,
|
|
201
216
|
};
|
|
202
217
|
const actions = {
|
|
203
|
-
config: actions$
|
|
218
|
+
config: actions$7,
|
|
204
219
|
billing: billingActions,
|
|
205
|
-
plans: actions$
|
|
206
|
-
checkout: actions$
|
|
207
|
-
stripe: actions$
|
|
220
|
+
plans: actions$8,
|
|
221
|
+
checkout: actions$3,
|
|
222
|
+
stripe: actions$2,
|
|
223
|
+
managedSubscriptions: actions$1,
|
|
208
224
|
};
|
|
209
225
|
const reducer = combineReducers({
|
|
210
|
-
config: reducer$
|
|
226
|
+
config: reducer$7,
|
|
211
227
|
billing: billingReducer,
|
|
212
|
-
plans: reducer$
|
|
213
|
-
checkout: reducer$
|
|
214
|
-
stripe: reducer$
|
|
228
|
+
plans: reducer$8,
|
|
229
|
+
checkout: reducer$3,
|
|
230
|
+
stripe: reducer$2,
|
|
231
|
+
managedSubscriptions: reducer$1,
|
|
215
232
|
});
|
|
216
233
|
|
|
217
234
|
var PaymentProvider;
|
|
@@ -344,34 +361,34 @@ const paymentMethodsMock = [
|
|
|
344
361
|
];
|
|
345
362
|
|
|
346
363
|
function* subscriptionBillingInformationSagas() {
|
|
347
|
-
yield takeEvery(actions$
|
|
348
|
-
yield takeEvery(actions$
|
|
349
|
-
yield takeEvery(actions$
|
|
350
|
-
yield takeEvery(actions$
|
|
364
|
+
yield takeEvery(actions$6.loadBillingInformation, loadBillingInformation);
|
|
365
|
+
yield takeEvery(actions$6.cancelSubscription, cancelSubscription);
|
|
366
|
+
yield takeEvery(actions$6.renewSubscription, renewSubscription);
|
|
367
|
+
yield takeEvery(actions$3.checkoutEvent, checkoutEvent$2);
|
|
351
368
|
}
|
|
352
369
|
function* loadBillingInformation() {
|
|
353
370
|
const paymentProvider = yield select((state) => { var _a; return (_a = state.subscriptions.config.config) === null || _a === void 0 ? void 0 : _a.paymentProvider; });
|
|
354
371
|
const tenantId = yield select((state) => { var _a, _b, _c; return (_c = (_b = (_a = state.auth) === null || _a === void 0 ? void 0 : _a.profileState) === null || _b === void 0 ? void 0 : _b.profile) === null || _c === void 0 ? void 0 : _c.tenantId; });
|
|
355
|
-
yield put(actions$
|
|
372
|
+
yield put(actions$6.setLoading(true));
|
|
356
373
|
if (!paymentProvider || !tenantId) {
|
|
357
|
-
yield put(actions$
|
|
374
|
+
yield put(actions$6.setError(!paymentProvider ? 'Internal feature failure' : 'Not authorized'));
|
|
358
375
|
return;
|
|
359
376
|
}
|
|
360
377
|
try {
|
|
361
378
|
yield loadSummaries(tenantId);
|
|
362
379
|
}
|
|
363
380
|
catch (e) {
|
|
364
|
-
yield put(actions$
|
|
381
|
+
yield put(actions$6.setError(e.message));
|
|
365
382
|
}
|
|
366
383
|
}
|
|
367
384
|
function* loadSummaries(tenantId) {
|
|
368
385
|
var _a, _b;
|
|
369
|
-
yield put(actions$
|
|
386
|
+
yield put(actions$6.setLoading(true));
|
|
370
387
|
try {
|
|
371
388
|
const { currentPlanId, subscriptionId, externallyManaged, defaultPlanId } = yield call(api.subscriptions.getSubscriptionSummaries, tenantId);
|
|
372
389
|
const subscriptionResponse = yield call(api.subscriptions.getSubscription, subscriptionId);
|
|
373
390
|
const planResponse = yield call(api.subscriptions.getSubscriptionPlan, currentPlanId);
|
|
374
|
-
yield put(actions$
|
|
391
|
+
yield put(actions$6.setBillingInformation(Object.assign(Object.assign({ loading: false, fetching: false, externallyManaged,
|
|
375
392
|
defaultPlanId }, (subscriptionResponse
|
|
376
393
|
? {
|
|
377
394
|
subscription: {
|
|
@@ -402,7 +419,7 @@ function* loadSummaries(tenantId) {
|
|
|
402
419
|
: {}))));
|
|
403
420
|
}
|
|
404
421
|
catch (e) {
|
|
405
|
-
yield put(actions$
|
|
422
|
+
yield put(actions$6.setError(e.message));
|
|
406
423
|
}
|
|
407
424
|
}
|
|
408
425
|
function* cancelSubscription() {
|
|
@@ -411,24 +428,24 @@ function* cancelSubscription() {
|
|
|
411
428
|
return;
|
|
412
429
|
}
|
|
413
430
|
if (overview.externallyManaged) {
|
|
414
|
-
yield put(actions$
|
|
431
|
+
yield put(actions$6.setCancellationError('Billing is externally managed'));
|
|
415
432
|
return;
|
|
416
433
|
}
|
|
417
434
|
const { id: subscriptionId, cancellation, status } = overview.subscription || {};
|
|
418
435
|
const isCancellable = !cancellation && status === SubscriptionStatus.ACTIVE;
|
|
419
436
|
if (isCancellable) {
|
|
420
437
|
try {
|
|
421
|
-
yield put(actions$
|
|
438
|
+
yield put(actions$6.setCancellationLoading(true));
|
|
422
439
|
yield call(api.subscriptions.cancelSubscription, subscriptionId);
|
|
423
|
-
yield put(actions$
|
|
440
|
+
yield put(actions$6.setBillingInformation({
|
|
424
441
|
subscription: Object.assign(Object.assign({}, overview.subscription), { cancellation: {
|
|
425
442
|
policy: SubscriptionCancellationPolicy.AT_PERIOD_END,
|
|
426
443
|
} }),
|
|
427
444
|
}));
|
|
428
|
-
yield put(actions$
|
|
445
|
+
yield put(actions$6.setCancellationLoading(false));
|
|
429
446
|
}
|
|
430
447
|
catch (e) {
|
|
431
|
-
yield put(actions$
|
|
448
|
+
yield put(actions$6.setCancellationError(e.message));
|
|
432
449
|
}
|
|
433
450
|
}
|
|
434
451
|
}
|
|
@@ -438,22 +455,22 @@ function* renewSubscription() {
|
|
|
438
455
|
return;
|
|
439
456
|
}
|
|
440
457
|
if (overview.externallyManaged) {
|
|
441
|
-
yield put(actions$
|
|
458
|
+
yield put(actions$6.setCancellationError('Billing is externally managed'));
|
|
442
459
|
return;
|
|
443
460
|
}
|
|
444
461
|
const { id: subscriptionId, cancellation } = overview.subscription || {};
|
|
445
462
|
const renewable = (cancellation === null || cancellation === void 0 ? void 0 : cancellation.policy) === SubscriptionCancellationPolicy.AT_PERIOD_END;
|
|
446
463
|
if (renewable) {
|
|
447
464
|
try {
|
|
448
|
-
yield put(actions$
|
|
465
|
+
yield put(actions$6.setRenewalLoading(true));
|
|
449
466
|
yield call(api.subscriptions.renewSubscription, subscriptionId);
|
|
450
|
-
yield put(actions$
|
|
467
|
+
yield put(actions$6.setBillingInformation({
|
|
451
468
|
subscription: Object.assign(Object.assign({}, overview.subscription), { cancellation: null }),
|
|
452
469
|
}));
|
|
453
|
-
yield put(actions$
|
|
470
|
+
yield put(actions$6.setRenewalLoading(false));
|
|
454
471
|
}
|
|
455
472
|
catch (e) {
|
|
456
|
-
yield put(actions$
|
|
473
|
+
yield put(actions$6.setCancellationError(e.message));
|
|
457
474
|
}
|
|
458
475
|
}
|
|
459
476
|
}
|
|
@@ -466,14 +483,14 @@ function* checkoutEvent$2({ payload }) {
|
|
|
466
483
|
* Preview Sagas
|
|
467
484
|
*********************************/
|
|
468
485
|
function* loadBillingInformationMock() {
|
|
469
|
-
yield put(actions$
|
|
486
|
+
yield put(actions$6.setLoading(true));
|
|
470
487
|
yield loadSummariesMock();
|
|
471
488
|
}
|
|
472
489
|
function* loadSummariesMock() {
|
|
473
490
|
var _a, _b;
|
|
474
|
-
yield put(actions$
|
|
491
|
+
yield put(actions$6.setLoading(true));
|
|
475
492
|
yield delay(500);
|
|
476
|
-
yield put(actions$
|
|
493
|
+
yield put(actions$6.setBillingInformation({
|
|
477
494
|
loading: false,
|
|
478
495
|
fetching: false,
|
|
479
496
|
externallyManaged: false,
|
|
@@ -482,30 +499,30 @@ function* loadSummariesMock() {
|
|
|
482
499
|
}));
|
|
483
500
|
}
|
|
484
501
|
function* subscriptionBillingInformationSagasMock() {
|
|
485
|
-
yield takeEvery(actions$
|
|
502
|
+
yield takeEvery(actions$6.loadBillingInformation, loadBillingInformationMock);
|
|
486
503
|
}
|
|
487
504
|
|
|
488
505
|
function* subscriptionsPaymentMethodSagas() {
|
|
489
|
-
yield takeEvery(actions$
|
|
490
|
-
yield takeEvery(actions$
|
|
491
|
-
yield takeEvery(actions$
|
|
492
|
-
yield takeEvery(actions$
|
|
493
|
-
yield takeEvery(actions$
|
|
494
|
-
yield takeEvery(actions$
|
|
506
|
+
yield takeEvery(actions$5.loadPaymentMethod, loadPaymentMethod);
|
|
507
|
+
yield takeEvery(actions$5.submitPaymentMethod, submitPaymentMethod);
|
|
508
|
+
yield takeEvery(actions$5.submitPaymentMethodError, submitPaymentMethodError);
|
|
509
|
+
yield takeEvery(actions$5.submitPaymentMethodSuccess, submitPaymentMethodSuccess);
|
|
510
|
+
yield takeEvery(actions$5.updatePaymentMethodBillingDetails, updateBillingDetails);
|
|
511
|
+
yield takeEvery(actions$3.checkoutEvent, checkoutEvent$1);
|
|
495
512
|
}
|
|
496
513
|
function* loadPaymentMethod() {
|
|
497
|
-
yield put(actions$
|
|
514
|
+
yield put(actions$5.setLoading(true));
|
|
498
515
|
try {
|
|
499
516
|
const paymentMethods = yield call(api.subscriptions.getPaymentMethods);
|
|
500
517
|
const paymentMethod = paymentMethods[0];
|
|
501
|
-
yield put(actions$
|
|
518
|
+
yield put(actions$5.setState({
|
|
502
519
|
paymentMethod,
|
|
503
520
|
loading: false,
|
|
504
521
|
fetching: false,
|
|
505
522
|
}));
|
|
506
523
|
}
|
|
507
524
|
catch (e) {
|
|
508
|
-
yield put(actions$
|
|
525
|
+
yield put(actions$5.setError(e.message));
|
|
509
526
|
}
|
|
510
527
|
}
|
|
511
528
|
function* checkoutEvent$1({ payload }) {
|
|
@@ -514,7 +531,7 @@ function* checkoutEvent$1({ payload }) {
|
|
|
514
531
|
}
|
|
515
532
|
}
|
|
516
533
|
function* updateBillingDetails({ payload, }) {
|
|
517
|
-
yield put(actions$
|
|
534
|
+
yield put(actions$5.setLoading(true));
|
|
518
535
|
const { id, email, address, callback } = payload;
|
|
519
536
|
try {
|
|
520
537
|
yield call(api.subscriptions.updatePaymentMethodBillingDetails, id, Object.assign({ email }, address));
|
|
@@ -522,44 +539,44 @@ function* updateBillingDetails({ payload, }) {
|
|
|
522
539
|
callback === null || callback === void 0 ? void 0 : callback(true);
|
|
523
540
|
}
|
|
524
541
|
catch (e) {
|
|
525
|
-
yield put(actions$
|
|
542
|
+
yield put(actions$5.setError(e.message));
|
|
526
543
|
callback === null || callback === void 0 ? void 0 : callback(false);
|
|
527
544
|
}
|
|
528
|
-
yield put(actions$
|
|
545
|
+
yield put(actions$5.setLoading(false));
|
|
529
546
|
}
|
|
530
547
|
function* submitPaymentMethod() {
|
|
531
|
-
yield put(actions$
|
|
548
|
+
yield put(actions$5.setLoading(true));
|
|
532
549
|
}
|
|
533
550
|
function* submitPaymentMethodError({ payload: error }) {
|
|
534
|
-
yield put(actions$
|
|
551
|
+
yield put(actions$5.setError(error));
|
|
535
552
|
}
|
|
536
553
|
function* submitPaymentMethodSuccess() {
|
|
537
|
-
yield put(actions$
|
|
554
|
+
yield put(actions$5.loadPaymentMethod());
|
|
538
555
|
}
|
|
539
556
|
/*********************************
|
|
540
557
|
* Preview Sagas
|
|
541
558
|
*********************************/
|
|
542
559
|
function* loadPaymentMethodMock() {
|
|
543
|
-
yield put(actions$
|
|
560
|
+
yield put(actions$5.setLoading(true));
|
|
544
561
|
yield delay(500);
|
|
545
562
|
const paymentMethod = paymentMethodsMock[0];
|
|
546
|
-
yield put(actions$
|
|
563
|
+
yield put(actions$5.setState({
|
|
547
564
|
paymentMethod,
|
|
548
565
|
loading: false,
|
|
549
566
|
fetching: false,
|
|
550
567
|
}));
|
|
551
568
|
}
|
|
552
569
|
function* subscriptionsPaymentMethodSagasMock() {
|
|
553
|
-
yield takeEvery(actions$
|
|
570
|
+
yield takeEvery(actions$5.loadPaymentMethod, loadPaymentMethodMock);
|
|
554
571
|
}
|
|
555
572
|
|
|
556
573
|
function* subscriptionInvoicesSagas() {
|
|
557
|
-
yield takeEvery(actions$
|
|
558
|
-
yield takeEvery(actions$
|
|
559
|
-
yield takeEvery(actions$
|
|
574
|
+
yield takeEvery(actions$4.loadInvoices, loadInvoices);
|
|
575
|
+
yield takeEvery(actions$4.downloadInvoice, downloadInvoice);
|
|
576
|
+
yield takeEvery(actions$3.checkoutEvent, checkoutEvent);
|
|
560
577
|
}
|
|
561
578
|
function* loadInvoices() {
|
|
562
|
-
yield put(actions$
|
|
579
|
+
yield put(actions$4.setLoading(true));
|
|
563
580
|
try {
|
|
564
581
|
const responseInvoices = yield call(api.subscriptions.getSubscriptionInvoices);
|
|
565
582
|
const invoices = responseInvoices.map((invoice) => ({
|
|
@@ -572,24 +589,24 @@ function* loadInvoices() {
|
|
|
572
589
|
paid: invoice.paid || false,
|
|
573
590
|
receiptNumber: invoice.receiptNumber,
|
|
574
591
|
}));
|
|
575
|
-
yield put(actions$
|
|
592
|
+
yield put(actions$4.setState({
|
|
576
593
|
loading: false,
|
|
577
594
|
fetching: false,
|
|
578
595
|
invoices,
|
|
579
596
|
}));
|
|
580
597
|
}
|
|
581
598
|
catch (e) {
|
|
582
|
-
yield put(actions$
|
|
599
|
+
yield put(actions$4.setError(e.message));
|
|
583
600
|
}
|
|
584
601
|
}
|
|
585
602
|
function* downloadInvoice({ payload }) {
|
|
586
|
-
yield put(actions$
|
|
603
|
+
yield put(actions$4.setInvoiceDownloadState({ loading: true, error: null }));
|
|
587
604
|
try {
|
|
588
605
|
yield call(api.subscriptions.getSubscriptionInvoicePdf, payload.invoiceId, payload.filename);
|
|
589
|
-
yield put(actions$
|
|
606
|
+
yield put(actions$4.setInvoiceDownloadState({ loading: false, error: null }));
|
|
590
607
|
}
|
|
591
608
|
catch (e) {
|
|
592
|
-
yield put(actions$
|
|
609
|
+
yield put(actions$4.setInvoiceDownloadState({ loading: false, error: e.message || null }));
|
|
593
610
|
}
|
|
594
611
|
}
|
|
595
612
|
function* checkoutEvent({ payload }) {
|
|
@@ -601,18 +618,18 @@ function* checkoutEvent({ payload }) {
|
|
|
601
618
|
* Preview Sagas
|
|
602
619
|
*********************************/
|
|
603
620
|
function* loadInvoicesMock() {
|
|
604
|
-
yield put(actions$
|
|
621
|
+
yield put(actions$4.setLoading(true));
|
|
605
622
|
yield delay(500);
|
|
606
623
|
const selectPlanTitle = 'Premium';
|
|
607
|
-
yield put(actions$
|
|
624
|
+
yield put(actions$4.setState({
|
|
608
625
|
loading: false,
|
|
609
626
|
fetching: false,
|
|
610
627
|
invoices: invoicesMock.map((invoice) => (Object.assign(Object.assign({}, invoice), { selectedPlan: selectPlanTitle, paymentDate: new Date(Date.parse(invoice.paymentDate)), totalAmount: +((invoice.totalAmount || 0) / 100).toFixed(2) }))),
|
|
611
628
|
}));
|
|
612
|
-
yield put(actions$
|
|
629
|
+
yield put(actions$4.setLoading(false));
|
|
613
630
|
}
|
|
614
631
|
function* subscriptionInvoicesSagasMock() {
|
|
615
|
-
yield takeEvery(actions$
|
|
632
|
+
yield takeEvery(actions$4.loadInvoices, loadInvoicesMock);
|
|
616
633
|
}
|
|
617
634
|
|
|
618
635
|
function* billingSagas() {
|
|
@@ -631,15 +648,15 @@ function* billingSagasMock() {
|
|
|
631
648
|
}
|
|
632
649
|
|
|
633
650
|
function* checkoutSagas() {
|
|
634
|
-
yield takeEvery(actions$
|
|
635
|
-
yield takeEvery(actions$
|
|
636
|
-
yield takeEvery(actions$
|
|
637
|
-
yield takeEvery(actions$
|
|
638
|
-
yield takeEvery(actions$
|
|
639
|
-
yield takeEvery(actions$
|
|
651
|
+
yield takeEvery(actions$3.checkoutPlan, checkoutPlan);
|
|
652
|
+
yield takeEvery(actions$3.resetCheckout, resetCheckout);
|
|
653
|
+
yield takeEvery(actions$3.confirmCheckout, confirmPlan);
|
|
654
|
+
yield takeEvery(actions$3.cancelCheckout, cancelPlan);
|
|
655
|
+
yield takeEvery(actions$3.submitCheckout, submitCheckout);
|
|
656
|
+
yield takeEvery(actions$3.errorCheckout, errorCheckout);
|
|
640
657
|
}
|
|
641
658
|
function* checkoutPlan({ payload: planId }) {
|
|
642
|
-
yield put(actions$
|
|
659
|
+
yield put(actions$3.setState({
|
|
643
660
|
checkoutPlanId: planId,
|
|
644
661
|
loading: false,
|
|
645
662
|
error: null,
|
|
@@ -647,7 +664,7 @@ function* checkoutPlan({ payload: planId }) {
|
|
|
647
664
|
}));
|
|
648
665
|
}
|
|
649
666
|
function* resetCheckout() {
|
|
650
|
-
yield put(actions$
|
|
667
|
+
yield put(actions$3.setState({
|
|
651
668
|
checkoutPlanId: null,
|
|
652
669
|
loading: false,
|
|
653
670
|
status: CheckoutStatus.SELECTION,
|
|
@@ -663,14 +680,14 @@ function* confirmPlan({ payload: paymentMethodId }) {
|
|
|
663
680
|
const subscriptionId = subscription === null || subscription === void 0 ? void 0 : subscription.id;
|
|
664
681
|
const subscriptionItemId = (_a = subscription === null || subscription === void 0 ? void 0 : subscription.items[0]) === null || _a === void 0 ? void 0 : _a.id;
|
|
665
682
|
if (!checkoutPlanId || !subscriptionId || !subscriptionItemId) {
|
|
666
|
-
yield put(actions$
|
|
683
|
+
yield put(actions$3.setState({
|
|
667
684
|
loading: false,
|
|
668
685
|
status: CheckoutStatus.ERROR,
|
|
669
686
|
}));
|
|
670
687
|
return;
|
|
671
688
|
}
|
|
672
689
|
if (status === CheckoutStatus.CHECKOUT) {
|
|
673
|
-
yield put(actions$
|
|
690
|
+
yield put(actions$3.setState({
|
|
674
691
|
loading: true,
|
|
675
692
|
error: null,
|
|
676
693
|
}));
|
|
@@ -684,33 +701,33 @@ function* confirmPlan({ payload: paymentMethodId }) {
|
|
|
684
701
|
},
|
|
685
702
|
],
|
|
686
703
|
});
|
|
687
|
-
yield put(actions$
|
|
704
|
+
yield put(actions$3.setState({
|
|
688
705
|
checkoutPlanId: null,
|
|
689
706
|
loading: false,
|
|
690
707
|
status: CheckoutStatus.CONFIRM,
|
|
691
708
|
}));
|
|
692
|
-
yield put(actions$
|
|
709
|
+
yield put(actions$3.checkoutEvent(CheckoutEvent.CONFIRMED));
|
|
693
710
|
}
|
|
694
711
|
catch (e) {
|
|
695
|
-
yield put(actions$
|
|
712
|
+
yield put(actions$3.setState({
|
|
696
713
|
loading: false,
|
|
697
714
|
error: e.message,
|
|
698
715
|
status: CheckoutStatus.ERROR,
|
|
699
716
|
}));
|
|
700
|
-
yield put(actions$
|
|
717
|
+
yield put(actions$3.checkoutEvent(CheckoutEvent.ERROR));
|
|
701
718
|
}
|
|
702
719
|
}
|
|
703
720
|
}
|
|
704
721
|
function* cancelPlan() {
|
|
705
722
|
const { status } = yield select((state) => state.subscriptions.checkout);
|
|
706
723
|
if (status === CheckoutStatus.CHECKOUT) {
|
|
707
|
-
yield put(actions$
|
|
724
|
+
yield put(actions$3.setState({
|
|
708
725
|
checkoutPlanId: null,
|
|
709
726
|
loading: false,
|
|
710
727
|
error: null,
|
|
711
728
|
status: CheckoutStatus.CANCEL,
|
|
712
729
|
}));
|
|
713
|
-
yield put(actions$
|
|
730
|
+
yield put(actions$3.checkoutEvent(CheckoutEvent.CANCEL));
|
|
714
731
|
}
|
|
715
732
|
}
|
|
716
733
|
/**
|
|
@@ -719,35 +736,35 @@ function* cancelPlan() {
|
|
|
719
736
|
function* submitCheckout() {
|
|
720
737
|
const { paymentProvider } = yield select((state) => state.subscriptions.config.config);
|
|
721
738
|
if (paymentProvider === PaymentProvider.STRIPE) {
|
|
722
|
-
yield put(actions$
|
|
739
|
+
yield put(actions$3.setState({
|
|
723
740
|
loading: true,
|
|
724
741
|
error: null,
|
|
725
742
|
}));
|
|
726
|
-
yield put(actions$
|
|
743
|
+
yield put(actions$3.checkoutEvent(CheckoutEvent.SUBMITTED));
|
|
727
744
|
}
|
|
728
745
|
}
|
|
729
746
|
function* errorCheckout({ payload }) {
|
|
730
|
-
yield put(actions$
|
|
747
|
+
yield put(actions$3.setState({
|
|
731
748
|
loading: false,
|
|
732
749
|
error: payload,
|
|
733
750
|
status: CheckoutStatus.ERROR,
|
|
734
751
|
}));
|
|
735
|
-
yield put(actions$
|
|
752
|
+
yield put(actions$3.checkoutEvent(CheckoutEvent.ERROR));
|
|
736
753
|
}
|
|
737
754
|
/*********************************
|
|
738
755
|
* Preview Sagas
|
|
739
756
|
*********************************/
|
|
740
757
|
function* checkoutSagasMock() {
|
|
741
|
-
yield takeEvery(actions$
|
|
742
|
-
yield takeEvery(actions$
|
|
743
|
-
yield takeEvery(actions$
|
|
758
|
+
yield takeEvery(actions$3.checkoutPlan, checkoutPlan);
|
|
759
|
+
yield takeEvery(actions$3.resetCheckout, resetCheckout);
|
|
760
|
+
yield takeEvery(actions$3.cancelCheckout, cancelPlan);
|
|
744
761
|
}
|
|
745
762
|
|
|
746
763
|
function* plansSagas() {
|
|
747
|
-
yield takeEvery(actions$
|
|
764
|
+
yield takeEvery(actions$8.loadPlans, loadPlans);
|
|
748
765
|
}
|
|
749
766
|
function* loadPlans() {
|
|
750
|
-
yield put(actions$
|
|
767
|
+
yield put(actions$8.setLoading(true));
|
|
751
768
|
try {
|
|
752
769
|
const products = yield call(api.subscriptions.getSubscriptionPlans);
|
|
753
770
|
const plans = products.map((item) => {
|
|
@@ -761,23 +778,23 @@ function* loadPlans() {
|
|
|
761
778
|
recurringInterval: 'month',
|
|
762
779
|
});
|
|
763
780
|
});
|
|
764
|
-
yield put(actions$
|
|
781
|
+
yield put(actions$8.setState({
|
|
765
782
|
fetching: false,
|
|
766
783
|
loading: false,
|
|
767
784
|
plans,
|
|
768
785
|
}));
|
|
769
786
|
}
|
|
770
787
|
catch (e) {
|
|
771
|
-
yield put(actions$
|
|
788
|
+
yield put(actions$8.setError(e.message));
|
|
772
789
|
}
|
|
773
790
|
}
|
|
774
791
|
/*********************************
|
|
775
792
|
* Preview Sagas
|
|
776
793
|
*********************************/
|
|
777
794
|
function* loadPlansMock() {
|
|
778
|
-
yield put(actions$
|
|
795
|
+
yield put(actions$8.setLoading(true));
|
|
779
796
|
yield delay(500);
|
|
780
|
-
yield put(actions$
|
|
797
|
+
yield put(actions$8.setState({
|
|
781
798
|
fetching: false,
|
|
782
799
|
loading: false,
|
|
783
800
|
plans: planResponseMock.map((item) => {
|
|
@@ -787,7 +804,7 @@ function* loadPlansMock() {
|
|
|
787
804
|
}));
|
|
788
805
|
}
|
|
789
806
|
function* plansSagasMock() {
|
|
790
|
-
yield takeEvery(actions$
|
|
807
|
+
yield takeEvery(actions$8.loadPlans, loadPlansMock);
|
|
791
808
|
}
|
|
792
809
|
|
|
793
810
|
var PaymentMethodType;
|
|
@@ -796,11 +813,20 @@ var PaymentMethodType;
|
|
|
796
813
|
PaymentMethodType["CARD"] = "card";
|
|
797
814
|
})(PaymentMethodType || (PaymentMethodType = {}));
|
|
798
815
|
|
|
816
|
+
var ManagedSubscriptionStatus;
|
|
817
|
+
(function (ManagedSubscriptionStatus) {
|
|
818
|
+
ManagedSubscriptionStatus["ACTIVE"] = "ACTIVE";
|
|
819
|
+
ManagedSubscriptionStatus["CANCELED"] = "CANCELED";
|
|
820
|
+
ManagedSubscriptionStatus["INCOMPLETE"] = "INCOMPLETE";
|
|
821
|
+
ManagedSubscriptionStatus["EXPIRED"] = "EXPIRED";
|
|
822
|
+
ManagedSubscriptionStatus["TRIALING"] = "TRIALING";
|
|
823
|
+
})(ManagedSubscriptionStatus || (ManagedSubscriptionStatus = {}));
|
|
824
|
+
|
|
799
825
|
function* configSagas() {
|
|
800
|
-
yield takeEvery(actions$
|
|
826
|
+
yield takeEvery(actions$7.loadPaymentConfiguration, loadPaymentConfiguration);
|
|
801
827
|
}
|
|
802
828
|
function* loadPaymentConfiguration() {
|
|
803
|
-
yield put(actions$
|
|
829
|
+
yield put(actions$7.setLoading(true));
|
|
804
830
|
try {
|
|
805
831
|
const response = yield call(api.subscriptions.getPaymentProviders) || [];
|
|
806
832
|
const stripePaymentProvider = response.find((paymentProvider) => paymentProvider.status === '1' && paymentProvider.providerType === ProviderType.Stripe);
|
|
@@ -808,18 +834,18 @@ function* loadPaymentConfiguration() {
|
|
|
808
834
|
yield loadStripePaymentConfiguration();
|
|
809
835
|
}
|
|
810
836
|
else {
|
|
811
|
-
yield put(actions$
|
|
837
|
+
yield put(actions$7.setError('Payment provider not configured'));
|
|
812
838
|
}
|
|
813
839
|
}
|
|
814
840
|
catch (e) {
|
|
815
|
-
yield put(actions$
|
|
841
|
+
yield put(actions$7.setError(e.message));
|
|
816
842
|
}
|
|
817
843
|
}
|
|
818
844
|
function* loadStripePaymentConfiguration() {
|
|
819
|
-
yield put(actions$
|
|
845
|
+
yield put(actions$7.setLoading(true));
|
|
820
846
|
try {
|
|
821
847
|
const response = yield call(api.subscriptions.getStripePaymentProviderConfiguration);
|
|
822
|
-
yield put(actions$
|
|
848
|
+
yield put(actions$7.setState({
|
|
823
849
|
loading: false,
|
|
824
850
|
fetching: false,
|
|
825
851
|
config: {
|
|
@@ -829,16 +855,16 @@ function* loadStripePaymentConfiguration() {
|
|
|
829
855
|
}));
|
|
830
856
|
}
|
|
831
857
|
catch (e) {
|
|
832
|
-
yield put(actions$
|
|
858
|
+
yield put(actions$7.setError(e.message));
|
|
833
859
|
}
|
|
834
860
|
}
|
|
835
861
|
/*********************************
|
|
836
862
|
* Preview Sagas
|
|
837
863
|
*********************************/
|
|
838
864
|
function* loadPaymentConfigurationMock() {
|
|
839
|
-
yield put(actions$
|
|
865
|
+
yield put(actions$7.setLoading(true));
|
|
840
866
|
yield delay(500);
|
|
841
|
-
yield put(actions$
|
|
867
|
+
yield put(actions$7.setState({
|
|
842
868
|
loading: false,
|
|
843
869
|
fetching: false,
|
|
844
870
|
config: {
|
|
@@ -848,14 +874,14 @@ function* loadPaymentConfigurationMock() {
|
|
|
848
874
|
}));
|
|
849
875
|
}
|
|
850
876
|
function* configSagasMock() {
|
|
851
|
-
yield takeEvery(actions$
|
|
877
|
+
yield takeEvery(actions$7.loadPaymentConfiguration, loadPaymentConfigurationMock);
|
|
852
878
|
}
|
|
853
879
|
|
|
854
880
|
function* subscriptionStripeSagas() {
|
|
855
|
-
yield takeEvery(actions$
|
|
881
|
+
yield takeEvery(actions$2.createCardSetupIntentSecret, createCardSetupIntentSecret);
|
|
856
882
|
}
|
|
857
883
|
function* createCardSetupIntentSecret({ payload }) {
|
|
858
|
-
yield put(actions$
|
|
884
|
+
yield put(actions$2.setStripeState({
|
|
859
885
|
loading: true,
|
|
860
886
|
error: null,
|
|
861
887
|
cardSetupIntentSecret: null
|
|
@@ -864,18 +890,32 @@ function* createCardSetupIntentSecret({ payload }) {
|
|
|
864
890
|
const { setupIntentSecret } = yield call(api.subscriptions.createStripePaymentMethodSetupIntentSecret, {
|
|
865
891
|
paymentMethodId: payload || undefined
|
|
866
892
|
});
|
|
867
|
-
yield put(actions$
|
|
893
|
+
yield put(actions$2.setStripeState({
|
|
868
894
|
cardSetupIntentSecret: setupIntentSecret,
|
|
869
895
|
loading: false
|
|
870
896
|
}));
|
|
871
897
|
}
|
|
898
|
+
catch (e) {
|
|
899
|
+
yield put(actions$2.setError(e.message));
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
|
|
903
|
+
function* loadManagedSubscriptions() {
|
|
904
|
+
yield put(actions$1.setLoading(true));
|
|
905
|
+
try {
|
|
906
|
+
const managedSubscriptionsResponse = yield call(api.subscriptions.getManagedSubscriptions);
|
|
907
|
+
yield put(actions$1.setState(managedSubscriptionsResponse));
|
|
908
|
+
}
|
|
872
909
|
catch (e) {
|
|
873
910
|
yield put(actions$1.setError(e.message));
|
|
874
911
|
}
|
|
912
|
+
}
|
|
913
|
+
function* managedSubscriptionsSagas() {
|
|
914
|
+
yield takeEvery(actions$1.loadManagedSubscriptions, loadManagedSubscriptions);
|
|
875
915
|
}
|
|
876
916
|
|
|
877
917
|
function* sagas() {
|
|
878
|
-
yield all([call(billingSagas), call(checkoutSagas), call(plansSagas), call(configSagas), call(subscriptionStripeSagas)]);
|
|
918
|
+
yield all([call(billingSagas), call(checkoutSagas), call(plansSagas), call(configSagas), call(subscriptionStripeSagas), call(managedSubscriptionsSagas)]);
|
|
879
919
|
}
|
|
880
920
|
function* mockSagas() {
|
|
881
921
|
yield all([call(billingSagasMock), call(checkoutSagasMock), call(plansSagasMock), call(configSagasMock)]);
|
|
@@ -892,4 +932,4 @@ var subscriptionsStore = {
|
|
|
892
932
|
storeName: subscriptionsStoreName,
|
|
893
933
|
};
|
|
894
934
|
|
|
895
|
-
export { CheckoutEvent, CheckoutStatus, PaymentMethodType, PaymentProvider, SubscriptionCancellationPolicy, SubscriptionStatus, subscriptionsStore as default, actions as subscriptionActions, initialState as subscriptionInitialState, reducer as subscriptionReducers, sagas as subscriptionSagas, mockSagas as subscriptionSagasMock };
|
|
935
|
+
export { CheckoutEvent, CheckoutStatus, ManagedSubscriptionStatus, PaymentMethodType, PaymentProvider, SubscriptionCancellationPolicy, SubscriptionStatus, subscriptionsStore as default, actions as subscriptionActions, initialState as subscriptionInitialState, reducer as subscriptionReducers, sagas as subscriptionSagas, mockSagas as subscriptionSagasMock };
|