@frontegg/redux-store 5.71.0 → 5.72.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.
@@ -42,12 +42,12 @@ const plansInitialState = {
42
42
  fetching: true,
43
43
  plans: [],
44
44
  };
45
- const { actions: sliceActions$1, reducer: reducer$8, name: name$7 } = toolkit.createSlice({
45
+ const { actions: sliceActions$2, reducer: reducer$9, name: name$8 } = toolkit.createSlice({
46
46
  name: `${constants.subscriptionsStoreName}/plans`,
47
47
  initialState: plansInitialState,
48
48
  reducers: Object.assign({}, createModuleCaseReducers()),
49
49
  });
50
- const actions$8 = Object.assign({ loadPlans: toolkit.createAction(`${name$7}/loadPlans`) }, sliceActions$1);
50
+ const actions$9 = Object.assign({ loadPlans: toolkit.createAction(`${name$8}/loadPlans`) }, sliceActions$2);
51
51
 
52
52
  const configInitialState = {
53
53
  loading: false,
@@ -56,12 +56,12 @@ const configInitialState = {
56
56
  config: null,
57
57
  };
58
58
  const reducers$6 = Object.assign({}, createModuleCaseReducers());
59
- const { actions: configActions, reducer: reducer$7, name: name$6, } = toolkit.createSlice({
59
+ const { actions: configActions, reducer: reducer$8, name: name$7, } = toolkit.createSlice({
60
60
  name: `${constants.subscriptionsStoreName}/config`,
61
61
  initialState: configInitialState,
62
62
  reducers: reducers$6,
63
63
  });
64
- const actions$7 = Object.assign({ loadPaymentConfiguration: toolkit.createAction(`${name$6}/loadPaymentConfiguration`) }, configActions);
64
+ const actions$8 = Object.assign({ loadPaymentConfiguration: toolkit.createAction(`${name$7}/loadPaymentConfiguration`) }, configActions);
65
65
 
66
66
  const initialSubscriptionState = {
67
67
  loading: false,
@@ -77,12 +77,12 @@ const initialSubscriptionState = {
77
77
  },
78
78
  };
79
79
  const reducers$5 = Object.assign(Object.assign({}, createModuleCaseReducers()), { setCancellationLoading: createKeyCaseLoadingReducer('cancellation'), setCancellationError: createKeyCaseErrorReducer('cancellation'), setRenewalLoading: createKeyCaseLoadingReducer('renewal'), setRenewalError: createKeyCaseErrorReducer('renewal') });
80
- const { reducer: reducer$6, actions: overviewActions$1, name: name$5, } = toolkit.createSlice({
80
+ const { reducer: reducer$7, actions: overviewActions$1, name: name$6, } = toolkit.createSlice({
81
81
  name: `${constants.subscriptionsStoreName}/billing/subscription`,
82
82
  initialState: initialSubscriptionState,
83
83
  reducers: reducers$5,
84
84
  });
85
- const actions$6 = Object.assign({ load: toolkit.createAction(`${name$5}/loadSubscription`), cancelSubscription: toolkit.createAction(`${name$5}/cancelSubscription`), renewSubscription: toolkit.createAction(`${name$5}/renewSubscription`) }, overviewActions$1);
85
+ const actions$7 = Object.assign({ load: toolkit.createAction(`${name$6}/loadSubscription`), cancelSubscription: toolkit.createAction(`${name$6}/cancelSubscription`), renewSubscription: toolkit.createAction(`${name$6}/renewSubscription`) }, overviewActions$1);
86
86
 
87
87
  const initialBillingInformationState = {
88
88
  loading: false,
@@ -90,12 +90,12 @@ const initialBillingInformationState = {
90
90
  fetching: true,
91
91
  };
92
92
  const reducers$4 = Object.assign({}, createModuleCaseReducers());
93
- const { reducer: reducer$5, actions: overviewActions, name: name$4, } = toolkit.createSlice({
93
+ const { reducer: reducer$6, actions: overviewActions, name: name$5, } = toolkit.createSlice({
94
94
  name: `${constants.subscriptionsStoreName}/billing/information`,
95
95
  initialState: initialBillingInformationState,
96
96
  reducers: reducers$4,
97
97
  });
98
- const actions$5 = Object.assign({ loadBillingInformation: toolkit.createAction(`${name$4}/loadBillingInformation`), cancelSubscription: actions$6.cancelSubscription, renewSubscription: actions$6.renewSubscription }, overviewActions);
98
+ const actions$6 = Object.assign({ loadBillingInformation: toolkit.createAction(`${name$5}/loadBillingInformation`), cancelSubscription: actions$7.cancelSubscription, renewSubscription: actions$7.renewSubscription }, overviewActions);
99
99
 
100
100
  const initialPaymentMethodState = {
101
101
  loading: false,
@@ -106,12 +106,12 @@ const reducers$3 = Object.assign(Object.assign({}, createModuleCaseReducers()),
106
106
  prepare: (payload) => ({ payload }),
107
107
  reducer: (state, action) => (Object.assign(Object.assign({}, state), action.payload)),
108
108
  } });
109
- const { reducer: reducer$4, actions: paymentActions, name: name$3, } = toolkit.createSlice({
109
+ const { reducer: reducer$5, actions: paymentActions, name: name$4, } = toolkit.createSlice({
110
110
  name: `${constants.subscriptionsStoreName}/billing/payment`,
111
111
  initialState: initialPaymentMethodState,
112
112
  reducers: reducers$3,
113
113
  });
114
- const actions$4 = Object.assign({ loadPaymentMethod: toolkit.createAction(`${name$3}/loadPaymentMethod`), submitPaymentMethod: toolkit.createAction(`${name$3}/submitPaymentMethod`), submitPaymentMethodError: toolkit.createAction(`${name$3}/submitPaymentMethodError`), submitPaymentMethodSuccess: toolkit.createAction(`${name$3}/submitPaymentMethodSuccess`), updatePaymentMethodBillingDetails: toolkit.createAction(`${name$3}/updateBillingDetails`, (payload) => ({ payload })) }, paymentActions);
114
+ const actions$5 = Object.assign({ loadPaymentMethod: toolkit.createAction(`${name$4}/loadPaymentMethod`), submitPaymentMethod: toolkit.createAction(`${name$4}/submitPaymentMethod`), submitPaymentMethodError: toolkit.createAction(`${name$4}/submitPaymentMethodError`), submitPaymentMethodSuccess: toolkit.createAction(`${name$4}/submitPaymentMethodSuccess`), updatePaymentMethodBillingDetails: toolkit.createAction(`${name$4}/updateBillingDetails`, (payload) => ({ payload })) }, paymentActions);
115
115
 
116
116
  const initialInvoicesState = {
117
117
  loading: false,
@@ -127,12 +127,12 @@ const reducers$2 = Object.assign(Object.assign({}, createModuleCaseReducers()),
127
127
  prepare: (payload) => ({ payload }),
128
128
  reducer: (state, action) => (Object.assign(Object.assign({}, state), { invoiceDownload: Object.assign(Object.assign({}, state.invoiceDownload), action.payload) })),
129
129
  } });
130
- const { reducer: reducer$3, actions: sliceActions, name: name$2, } = toolkit.createSlice({
130
+ const { reducer: reducer$4, actions: sliceActions$1, name: name$3, } = toolkit.createSlice({
131
131
  name: `${constants.subscriptionsStoreName}/billing/invoices`,
132
132
  initialState: initialInvoicesState,
133
133
  reducers: reducers$2,
134
134
  });
135
- const actions$3 = Object.assign({ loadInvoices: toolkit.createAction(`${name$2}/loadInvoices`), downloadInvoice: toolkit.createAction(`${name$2}/downloadInvoice`, (payload) => ({ payload })) }, sliceActions);
135
+ const actions$4 = Object.assign({ loadInvoices: toolkit.createAction(`${name$3}/loadInvoices`), downloadInvoice: toolkit.createAction(`${name$3}/downloadInvoice`, (payload) => ({ payload })) }, sliceActions$1);
136
136
 
137
137
  const billingInitialState = {
138
138
  information: initialBillingInformationState,
@@ -141,16 +141,16 @@ const billingInitialState = {
141
141
  subscription: initialSubscriptionState,
142
142
  };
143
143
  const billingActions = {
144
- invoices: actions$3,
145
- information: actions$5,
146
- paymentMethod: actions$4,
147
- subscription: actions$6,
144
+ invoices: actions$4,
145
+ information: actions$6,
146
+ paymentMethod: actions$5,
147
+ subscription: actions$7,
148
148
  };
149
149
  const billingReducer = toolkit.combineReducers({
150
- invoices: reducer$3,
151
- information: reducer$5,
152
- paymentMethod: reducer$4,
153
- subscription: reducer$6,
150
+ invoices: reducer$4,
151
+ information: reducer$6,
152
+ paymentMethod: reducer$5,
153
+ subscription: reducer$7,
154
154
  });
155
155
 
156
156
  const checkoutInitialState = {
@@ -160,12 +160,12 @@ const checkoutInitialState = {
160
160
  confirmed: false,
161
161
  };
162
162
  const reducers$1 = Object.assign({}, createModuleCaseReducers());
163
- const { actions: checkoutActions, reducer: reducer$2, name: name$1 } = toolkit.createSlice({
163
+ const { actions: checkoutActions, reducer: reducer$3, name: name$2 } = toolkit.createSlice({
164
164
  name: `${constants.subscriptionsStoreName}/checkout`,
165
165
  initialState: checkoutInitialState,
166
166
  reducers: reducers$1,
167
167
  });
168
- const actions$2 = Object.assign({ loadCheckout: toolkit.createAction(`${name$1}/loadCheckout`), resetCheckout: toolkit.createAction(`${name$1}/resetCheckout`), submitCheckout: toolkit.createAction(`${name$1}/submitCheckout`), confirmCheckout: toolkit.createAction(`${name$1}/confirmCheckout`, (payload) => ({ payload })), errorCheckout: toolkit.createAction(`${name$1}/errorCheckout`, (payload) => ({ payload })) }, checkoutActions);
168
+ const actions$3 = Object.assign({ loadCheckout: toolkit.createAction(`${name$2}/loadCheckout`), resetCheckout: toolkit.createAction(`${name$2}/resetCheckout`), submitCheckout: toolkit.createAction(`${name$2}/submitCheckout`), confirmCheckout: toolkit.createAction(`${name$2}/confirmCheckout`, (payload) => ({ payload })), errorCheckout: toolkit.createAction(`${name$2}/errorCheckout`, (payload) => ({ payload })) }, checkoutActions);
169
169
 
170
170
  const initialSubscriptionStripeState = {
171
171
  loading: false,
@@ -173,12 +173,24 @@ const initialSubscriptionStripeState = {
173
173
  cardSetupIntentSecret: null,
174
174
  };
175
175
  const reducers = Object.assign({}, createModuleCaseReducers());
176
- const { reducer: reducer$1, actions: reducerActions, name, } = toolkit.createSlice({
176
+ const { reducer: reducer$2, actions: reducerActions, name: name$1, } = toolkit.createSlice({
177
177
  name: `${constants.subscriptionsStoreName}/stripe`,
178
178
  initialState: initialSubscriptionStripeState,
179
179
  reducers,
180
180
  });
181
- const actions$1 = Object.assign({ loadCustomer: toolkit.createAction(`${name}/loadCustomer`), createCardSetupIntentSecret: toolkit.createAction(`${name}/createCardSetupIntentSecret`) }, reducerActions);
181
+ const actions$2 = Object.assign({ loadCustomer: toolkit.createAction(`${name$1}/loadCustomer`), createCardSetupIntentSecret: toolkit.createAction(`${name$1}/createCardSetupIntentSecret`) }, reducerActions);
182
+
183
+ const vendorPublicConfigInitialState = {
184
+ loading: false,
185
+ fetching: true,
186
+ vendorPublicConfig: null,
187
+ };
188
+ const { actions: sliceActions, reducer: reducer$1, name, } = toolkit.createSlice({
189
+ name: `${constants.subscriptionsStoreName}/vendorPublicConfig`,
190
+ initialState: vendorPublicConfigInitialState,
191
+ reducers: Object.assign({}, createModuleCaseReducers()),
192
+ });
193
+ const actions$1 = Object.assign({ loadVendorPublicConfiguration: toolkit.createAction(`${name}/loadVendorPublicConfiguration`) }, sliceActions);
182
194
 
183
195
  const initialState = {
184
196
  config: configInitialState,
@@ -186,20 +198,23 @@ const initialState = {
186
198
  checkout: checkoutInitialState,
187
199
  billing: billingInitialState,
188
200
  stripe: initialSubscriptionStripeState,
201
+ vendorPublicConfig: vendorPublicConfigInitialState,
189
202
  };
190
203
  const actions = {
191
- config: actions$7,
204
+ config: actions$8,
192
205
  billing: billingActions,
193
- plans: actions$8,
194
- checkout: actions$2,
195
- stripe: actions$1,
206
+ plans: actions$9,
207
+ checkout: actions$3,
208
+ stripe: actions$2,
209
+ vendorPublicConfig: actions$1,
196
210
  };
197
211
  const reducer = toolkit.combineReducers({
198
- config: reducer$7,
212
+ config: reducer$8,
199
213
  billing: billingReducer,
200
- plans: reducer$8,
201
- checkout: reducer$2,
202
- stripe: reducer$1,
214
+ plans: reducer$9,
215
+ checkout: reducer$3,
216
+ stripe: reducer$2,
217
+ vendorPublicConfig: reducer$1,
203
218
  });
204
219
 
205
220
  exports.PaymentProvider = void 0;
@@ -255,21 +270,8 @@ const subscriptionResponseMock = {
255
270
  currentPeriodEnd: '2021-10-20T08:08:51.000Z',
256
271
  plan: {
257
272
  // TODO: fix dummy data
258
- slug: 'test'
259
- }
260
- // items: [
261
- // {
262
- // id: 'si_KGE0p5himocPXH',
263
- // externalId: 'prod_J60fUEvI7qV1eL',
264
- // planId: 'prod_J60fUEvI7qV1eL',
265
- // price: {
266
- // id: 'price_1IToe8Ewsu4qiqnndAV76J69',
267
- // externalId: 'price_1IToe8Ewsu4qiqnndAV76J69',
268
- // currency: 'usd',
269
- // amount: 10000,
270
- // },
271
- // },
272
- // ],
273
+ slug: 'test',
274
+ },
273
275
  };
274
276
  const planResponseMock = [
275
277
  {
@@ -336,22 +338,26 @@ const paymentMethodsMock = [
336
338
  email: 'dummy@email.com',
337
339
  },
338
340
  },
339
- ];
341
+ ];
342
+ const vendorPublicConfigurationResponseMock = {
343
+ allowPlanDowngrade: true,
344
+ allowPlanCancellation: true,
345
+ };
340
346
 
341
347
  function* subscriptionSagas() {
342
- yield effects.takeEvery(actions$6.load, loadSubscriptionTenant);
343
- yield effects.takeEvery(actions$6.cancelSubscription, cancelSubscription);
344
- yield effects.takeEvery(actions$6.renewSubscription, renewSubscription);
348
+ yield effects.takeEvery(actions$7.load, loadSubscriptionTenant);
349
+ yield effects.takeEvery(actions$7.cancelSubscription, cancelSubscription);
350
+ yield effects.takeEvery(actions$7.renewSubscription, renewSubscription);
345
351
  }
346
352
  function* loadSubscriptionTenant() {
347
353
  const tenantId = yield effects.select((state) => { var _a, _b; return (_b = (_a = state.auth) === null || _a === void 0 ? void 0 : _a.user) === null || _b === void 0 ? void 0 : _b.tenantId; });
348
354
  yield loadSummaries(tenantId);
349
355
  }
350
356
  function* loadSubscription() {
351
- yield effects.put(actions$6.setLoading(true));
357
+ yield effects.put(actions$7.setLoading(true));
352
358
  try {
353
359
  const [subscription] = yield effects.call(restApi.api.subscriptions.getManagedSubscriptions);
354
- yield effects.put(actions$6.setState({
360
+ yield effects.put(actions$7.setState({
355
361
  subscription,
356
362
  fetching: false,
357
363
  loading: false,
@@ -359,54 +365,54 @@ function* loadSubscription() {
359
365
  }));
360
366
  }
361
367
  catch (e) {
362
- yield effects.put(actions$6.setError(e));
368
+ yield effects.put(actions$7.setError(e));
363
369
  }
364
370
  }
365
371
  function* cancelSubscription() {
366
372
  const { subscription } = yield effects.select((state) => state.subscriptions.billing.subscription);
367
373
  if (!subscription) {
368
- yield effects.put(actions$6.setCancellationError('Subscription not found.'));
374
+ yield effects.put(actions$7.setCancellationError('Subscription not found.'));
369
375
  return;
370
376
  }
371
377
  if (subscription === null || subscription === void 0 ? void 0 : subscription.externallyManaged) {
372
- yield effects.put(actions$6.setCancellationError('Billing is externally managed.'));
378
+ yield effects.put(actions$7.setCancellationError('Billing is externally managed.'));
373
379
  return;
374
380
  }
375
381
  const { id: subscriptionId, cancellation, status } = subscription || {};
376
382
  const isCancellable = !cancellation && status === restApi.ISubscriptionStatus.ACTIVE;
377
383
  if (isCancellable) {
378
384
  try {
379
- yield effects.put(actions$6.setCancellationLoading(true));
385
+ yield effects.put(actions$7.setCancellationLoading(true));
380
386
  yield effects.call(restApi.api.subscriptions.cancelManagedSubscription, subscriptionId);
381
387
  yield loadSubscription();
382
- yield effects.put(actions$6.setCancellationLoading(false));
388
+ yield effects.put(actions$7.setCancellationLoading(false));
383
389
  }
384
390
  catch (e) {
385
- yield effects.put(actions$6.setCancellationError(e.message));
391
+ yield effects.put(actions$7.setCancellationError(e.message));
386
392
  }
387
393
  }
388
394
  }
389
395
  function* renewSubscription() {
390
396
  const { subscription } = yield effects.select((state) => state.subscriptions.billing.subscription);
391
397
  if (!subscription) {
392
- yield effects.put(actions$6.setCancellationError('Subscription not found.'));
398
+ yield effects.put(actions$7.setCancellationError('Subscription not found.'));
393
399
  return;
394
400
  }
395
401
  if (subscription === null || subscription === void 0 ? void 0 : subscription.externallyManaged) {
396
- yield effects.put(actions$6.setCancellationError('Billing is externally managed'));
402
+ yield effects.put(actions$7.setCancellationError('Billing is externally managed'));
397
403
  return;
398
404
  }
399
405
  const { id: subscriptionId, cancellation } = subscription || {};
400
406
  const renewable = (cancellation === null || cancellation === void 0 ? void 0 : cancellation.policy) === restApi.ISubscriptionCancellationPolicy.AT_PERIOD_END;
401
407
  if (renewable) {
402
408
  try {
403
- yield effects.put(actions$6.setRenewalLoading(true));
409
+ yield effects.put(actions$7.setRenewalLoading(true));
404
410
  yield effects.call(restApi.api.subscriptions.renewManagedSubscription, subscriptionId);
405
411
  yield loadSubscription();
406
- yield effects.put(actions$6.setRenewalLoading(false));
412
+ yield effects.put(actions$7.setRenewalLoading(false));
407
413
  }
408
414
  catch (e) {
409
- yield effects.put(actions$6.setCancellationError(e.message));
415
+ yield effects.put(actions$7.setCancellationError(e.message));
410
416
  }
411
417
  }
412
418
  }
@@ -414,9 +420,9 @@ function* renewSubscription() {
414
420
  * Preview Sagas
415
421
  *********************************/
416
422
  function* loadMock() {
417
- yield effects.put(actions$6.setLoading(true));
423
+ yield effects.put(actions$7.setLoading(true));
418
424
  yield effects.delay(500);
419
- yield effects.put(actions$6.setState({
425
+ yield effects.put(actions$7.setState({
420
426
  subscription: subscriptionResponseMock,
421
427
  fetching: false,
422
428
  loading: false,
@@ -424,11 +430,11 @@ function* loadMock() {
424
430
  }));
425
431
  }
426
432
  function* subscriptionSagasMock() {
427
- yield effects.takeEvery(actions$6.load, loadMock);
433
+ yield effects.takeEvery(actions$7.load, loadMock);
428
434
  }
429
435
 
430
436
  function* subscriptionBillingInformationSagas() {
431
- yield effects.takeEvery(actions$5.loadBillingInformation, loadBillingInformation);
437
+ yield effects.takeEvery(actions$6.loadBillingInformation, loadBillingInformation);
432
438
  }
433
439
  function* loadBillingInformation() {
434
440
  yield loadBillingInformationAction(false);
@@ -437,14 +443,14 @@ function* loadBillingInformationAction(forceActive) {
437
443
  const paymentProvider = yield effects.select((state) => { var _a; return (_a = state.subscriptions.config.config) === null || _a === void 0 ? void 0 : _a.paymentProvider; });
438
444
  const tenantId = yield effects.select((state) => { var _a, _b; return (_b = (_a = state.auth) === null || _a === void 0 ? void 0 : _a.user) === null || _b === void 0 ? void 0 : _b.tenantId; });
439
445
  if (!paymentProvider || !tenantId) {
440
- yield effects.put(actions$5.setError(!paymentProvider ? 'Internal feature failure' : 'Not authorized'));
446
+ yield effects.put(actions$6.setError(!paymentProvider ? 'Internal feature failure' : 'Not authorized'));
441
447
  return;
442
448
  }
443
449
  yield loadSummaries(tenantId, forceActive);
444
450
  }
445
451
  function* loadSummaries(tenantId, forceActive) {
446
452
  var _a, _b;
447
- yield effects.put(actions$5.setLoading(true));
453
+ yield effects.put(actions$6.setLoading(true));
448
454
  try {
449
455
  const summary = yield effects.call(restApi.api.subscriptions.getSubscriptionSummaries, tenantId);
450
456
  const { currentPlanId, externallyManaged } = summary;
@@ -460,7 +466,7 @@ function* loadSummaries(tenantId, forceActive) {
460
466
  else {
461
467
  planResponse = yield effects.call(restApi.api.subscriptions.getSubscriptionPlan, currentPlanId);
462
468
  }
463
- yield effects.put(actions$5.setState(Object.assign(Object.assign({ loading: false, fetching: false, summary }, (subscriptionResponse
469
+ yield effects.put(actions$6.setState(Object.assign(Object.assign({ loading: false, fetching: false, summary }, (subscriptionResponse
464
470
  ? {
465
471
  subscription: {
466
472
  id: subscriptionResponse.id,
@@ -488,7 +494,7 @@ function* loadSummaries(tenantId, forceActive) {
488
494
  : {}))));
489
495
  }
490
496
  catch (e) {
491
- yield effects.put(actions$5.setError(e.message));
497
+ yield effects.put(actions$6.setError(e.message));
492
498
  }
493
499
  }
494
500
  /*********************************
@@ -499,9 +505,9 @@ function* loadBillingInformationMock() {
499
505
  }
500
506
  function* loadSummariesMock() {
501
507
  var _a, _b;
502
- yield effects.put(actions$5.setLoading(true));
508
+ yield effects.put(actions$6.setLoading(true));
503
509
  yield effects.delay(500);
504
- yield effects.put(actions$5.setState({
510
+ yield effects.put(actions$6.setState({
505
511
  loading: false,
506
512
  fetching: false,
507
513
  summary: {
@@ -517,33 +523,33 @@ function* loadSummariesMock() {
517
523
  }));
518
524
  }
519
525
  function* subscriptionBillingInformationSagasMock() {
520
- yield effects.takeEvery(actions$5.loadBillingInformation, loadBillingInformationMock);
526
+ yield effects.takeEvery(actions$6.loadBillingInformation, loadBillingInformationMock);
521
527
  }
522
528
 
523
529
  function* subscriptionsPaymentMethodSagas() {
524
- yield effects.takeEvery(actions$4.loadPaymentMethod, loadPaymentMethod);
525
- yield effects.takeEvery(actions$4.submitPaymentMethod, submitPaymentMethod);
526
- yield effects.takeEvery(actions$4.submitPaymentMethodError, submitPaymentMethodError);
527
- yield effects.takeEvery(actions$4.submitPaymentMethodSuccess, submitPaymentMethodSuccess);
528
- yield effects.takeEvery(actions$4.updatePaymentMethodBillingDetails, updateBillingDetails);
530
+ yield effects.takeEvery(actions$5.loadPaymentMethod, loadPaymentMethod);
531
+ yield effects.takeEvery(actions$5.submitPaymentMethod, submitPaymentMethod);
532
+ yield effects.takeEvery(actions$5.submitPaymentMethodError, submitPaymentMethodError);
533
+ yield effects.takeEvery(actions$5.submitPaymentMethodSuccess, submitPaymentMethodSuccess);
534
+ yield effects.takeEvery(actions$5.updatePaymentMethodBillingDetails, updateBillingDetails);
529
535
  }
530
536
  function* loadPaymentMethod() {
531
- yield effects.put(actions$4.setLoading(true));
537
+ yield effects.put(actions$5.setLoading(true));
532
538
  try {
533
539
  const paymentMethods = yield effects.call(restApi.api.subscriptions.getPaymentMethods);
534
540
  const paymentMethod = paymentMethods[0];
535
- yield effects.put(actions$4.setState({
541
+ yield effects.put(actions$5.setState({
536
542
  paymentMethod,
537
543
  loading: false,
538
544
  fetching: false,
539
545
  }));
540
546
  }
541
547
  catch (e) {
542
- yield effects.put(actions$4.setError(e.message));
548
+ yield effects.put(actions$5.setError(e.message));
543
549
  }
544
550
  }
545
551
  function* updateBillingDetails({ payload, }) {
546
- yield effects.put(actions$4.setLoading(true));
552
+ yield effects.put(actions$5.setLoading(true));
547
553
  const { id, email, address, callback } = payload;
548
554
  try {
549
555
  yield effects.call(restApi.api.subscriptions.updatePaymentMethodBillingDetails, id, Object.assign({ email }, address));
@@ -551,43 +557,43 @@ function* updateBillingDetails({ payload, }) {
551
557
  callback === null || callback === void 0 ? void 0 : callback(true);
552
558
  }
553
559
  catch (e) {
554
- yield effects.put(actions$4.setError(e.message));
560
+ yield effects.put(actions$5.setError(e.message));
555
561
  callback === null || callback === void 0 ? void 0 : callback(false);
556
562
  }
557
- yield effects.put(actions$4.setLoading(false));
563
+ yield effects.put(actions$5.setLoading(false));
558
564
  }
559
565
  function* submitPaymentMethod() {
560
- yield effects.put(actions$4.setLoading(true));
566
+ yield effects.put(actions$5.setLoading(true));
561
567
  }
562
568
  function* submitPaymentMethodError({ payload: error }) {
563
- yield effects.put(actions$4.setError(error));
569
+ yield effects.put(actions$5.setError(error));
564
570
  }
565
571
  function* submitPaymentMethodSuccess() {
566
- yield effects.put(actions$4.loadPaymentMethod());
572
+ yield effects.put(actions$5.loadPaymentMethod());
567
573
  }
568
574
  /*********************************
569
575
  * Preview Sagas
570
576
  *********************************/
571
577
  function* loadPaymentMethodMock() {
572
- yield effects.put(actions$4.setLoading(true));
578
+ yield effects.put(actions$5.setLoading(true));
573
579
  yield effects.delay(500);
574
580
  const paymentMethod = paymentMethodsMock[0];
575
- yield effects.put(actions$4.setState({
581
+ yield effects.put(actions$5.setState({
576
582
  paymentMethod,
577
583
  loading: false,
578
584
  fetching: false,
579
585
  }));
580
586
  }
581
587
  function* subscriptionsPaymentMethodSagasMock() {
582
- yield effects.takeEvery(actions$4.loadPaymentMethod, loadPaymentMethodMock);
588
+ yield effects.takeEvery(actions$5.loadPaymentMethod, loadPaymentMethodMock);
583
589
  }
584
590
 
585
591
  function* subscriptionInvoicesSagas() {
586
- yield effects.takeEvery(actions$3.loadInvoices, loadInvoices);
587
- yield effects.takeEvery(actions$3.downloadInvoice, downloadInvoice);
592
+ yield effects.takeEvery(actions$4.loadInvoices, loadInvoices);
593
+ yield effects.takeEvery(actions$4.downloadInvoice, downloadInvoice);
588
594
  }
589
595
  function* loadInvoices() {
590
- yield effects.put(actions$3.setLoading(true));
596
+ yield effects.put(actions$4.setLoading(true));
591
597
  try {
592
598
  const responseInvoices = yield effects.call(restApi.api.subscriptions.getSubscriptionInvoices);
593
599
  const invoices = responseInvoices.map((invoice) => ({
@@ -600,42 +606,42 @@ function* loadInvoices() {
600
606
  paid: invoice.paid || false,
601
607
  receiptNumber: invoice.receiptNumber,
602
608
  }));
603
- yield effects.put(actions$3.setState({
609
+ yield effects.put(actions$4.setState({
604
610
  loading: false,
605
611
  fetching: false,
606
612
  invoices,
607
613
  }));
608
614
  }
609
615
  catch (e) {
610
- yield effects.put(actions$3.setError(e.message));
616
+ yield effects.put(actions$4.setError(e.message));
611
617
  }
612
618
  }
613
619
  function* downloadInvoice({ payload }) {
614
- yield effects.put(actions$3.setInvoiceDownloadState({ loading: true, error: null }));
620
+ yield effects.put(actions$4.setInvoiceDownloadState({ loading: true, error: null }));
615
621
  try {
616
622
  yield effects.call(restApi.api.subscriptions.getSubscriptionInvoicePdf, payload.invoiceId, payload.filename);
617
- yield effects.put(actions$3.setInvoiceDownloadState({ loading: false, error: null }));
623
+ yield effects.put(actions$4.setInvoiceDownloadState({ loading: false, error: null }));
618
624
  }
619
625
  catch (e) {
620
- yield effects.put(actions$3.setInvoiceDownloadState({ loading: false, error: e.message || null }));
626
+ yield effects.put(actions$4.setInvoiceDownloadState({ loading: false, error: e.message || null }));
621
627
  }
622
628
  }
623
629
  /*********************************
624
630
  * Preview Sagas
625
631
  *********************************/
626
632
  function* loadInvoicesMock() {
627
- yield effects.put(actions$3.setLoading(true));
633
+ yield effects.put(actions$4.setLoading(true));
628
634
  yield effects.delay(500);
629
635
  const selectPlanTitle = 'Premium';
630
- yield effects.put(actions$3.setState({
636
+ yield effects.put(actions$4.setState({
631
637
  loading: false,
632
638
  fetching: false,
633
639
  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) }))),
634
640
  }));
635
- yield effects.put(actions$3.setLoading(false));
641
+ yield effects.put(actions$4.setLoading(false));
636
642
  }
637
643
  function* subscriptionInvoicesSagasMock() {
638
- yield effects.takeEvery(actions$3.loadInvoices, loadInvoicesMock);
644
+ yield effects.takeEvery(actions$4.loadInvoices, loadInvoicesMock);
639
645
  }
640
646
 
641
647
  function* billingSagas() {
@@ -656,14 +662,14 @@ function* billingSagasMock() {
656
662
  }
657
663
 
658
664
  function* checkoutSagas() {
659
- yield effects.takeEvery(actions$2.loadCheckout, loadCheckout);
660
- yield effects.takeEvery(actions$2.resetCheckout, resetCheckout);
661
- yield effects.takeEvery(actions$2.submitCheckout, submitCheckout);
662
- yield effects.takeEvery(actions$2.confirmCheckout, confirmPlan);
663
- yield effects.takeEvery(actions$2.errorCheckout, errorCheckout);
665
+ yield effects.takeEvery(actions$3.loadCheckout, loadCheckout);
666
+ yield effects.takeEvery(actions$3.resetCheckout, resetCheckout);
667
+ yield effects.takeEvery(actions$3.submitCheckout, submitCheckout);
668
+ yield effects.takeEvery(actions$3.confirmCheckout, confirmPlan);
669
+ yield effects.takeEvery(actions$3.errorCheckout, errorCheckout);
664
670
  }
665
671
  function* loadCheckout() {
666
- yield effects.put(actions$2.setState({
672
+ yield effects.put(actions$3.setState({
667
673
  fetching: false,
668
674
  loading: false,
669
675
  error: null,
@@ -671,7 +677,7 @@ function* loadCheckout() {
671
677
  }));
672
678
  }
673
679
  function* resetCheckout() {
674
- yield effects.put(actions$2.setState({
680
+ yield effects.put(actions$3.setState({
675
681
  loading: false,
676
682
  error: null,
677
683
  confirmed: false,
@@ -681,7 +687,7 @@ function* resetCheckout() {
681
687
  * Based on payment provider type
682
688
  */
683
689
  function* submitCheckout() {
684
- yield effects.put(actions$2.setState({
690
+ yield effects.put(actions$3.setState({
685
691
  loading: true,
686
692
  error: null,
687
693
  }));
@@ -692,19 +698,19 @@ function* confirmPlan({ payload: { paymentMethodId, planId } }) {
692
698
  const isTrialing = (subscription === null || subscription === void 0 ? void 0 : subscription.status) === exports.SubscriptionStatus.TRIALING;
693
699
  const hasPaymentMethod = !!(summary === null || summary === void 0 ? void 0 : summary.paymentMethodId);
694
700
  if (!subscription) {
695
- yield effects.put(actions$2.setState({
701
+ yield effects.put(actions$3.setState({
696
702
  loading: false,
697
703
  error: 'Subscription not found',
698
704
  }));
699
705
  return;
700
706
  }
701
- yield effects.put(actions$2.setState({
707
+ yield effects.put(actions$3.setState({
702
708
  loading: true,
703
709
  error: null,
704
710
  }));
705
711
  if (isTrialing && hasPaymentMethod) {
706
712
  yield confirmCheckout();
707
- yield effects.put(actions$6.setState({
713
+ yield effects.put(actions$7.setState({
708
714
  subscription: Object.assign(Object.assign({}, subscription), { status: restApi.ISubscriptionStatus.ACTIVE }),
709
715
  }));
710
716
  return;
@@ -722,21 +728,21 @@ function* confirmPlan({ payload: { paymentMethodId, planId } }) {
722
728
  yield confirmCheckout();
723
729
  }
724
730
  catch (e) {
725
- yield effects.put(actions$2.setState({
731
+ yield effects.put(actions$3.setState({
726
732
  loading: false,
727
733
  error: e.message,
728
734
  }));
729
735
  }
730
736
  }
731
737
  function* confirmCheckout() {
732
- yield effects.put(actions$2.setState({
738
+ yield effects.put(actions$3.setState({
733
739
  loading: false,
734
740
  error: null,
735
741
  confirmed: true,
736
742
  }));
737
743
  }
738
744
  function* errorCheckout({ payload }) {
739
- yield effects.put(actions$2.setState({
745
+ yield effects.put(actions$3.setState({
740
746
  loading: false,
741
747
  error: payload,
742
748
  }));
@@ -745,14 +751,14 @@ function* errorCheckout({ payload }) {
745
751
  * Preview Sagas
746
752
  *********************************/
747
753
  function* checkoutSagasMock() {
748
- yield effects.takeEvery(actions$2.resetCheckout, resetCheckout);
754
+ yield effects.takeEvery(actions$3.resetCheckout, resetCheckout);
749
755
  }
750
756
 
751
757
  function* plansSagas() {
752
- yield effects.takeEvery(actions$8.loadPlans, loadPlans);
758
+ yield effects.takeEvery(actions$9.loadPlans, loadPlans);
753
759
  }
754
760
  function* loadPlans() {
755
- yield effects.put(actions$8.setLoading(true));
761
+ yield effects.put(actions$9.setLoading(true));
756
762
  try {
757
763
  const products = yield effects.call(restApi.api.subscriptions.getSubscriptionPlans);
758
764
  const plans = products.map((item) => {
@@ -767,23 +773,23 @@ function* loadPlans() {
767
773
  slug: item.slug,
768
774
  });
769
775
  });
770
- yield effects.put(actions$8.setState({
776
+ yield effects.put(actions$9.setState({
771
777
  fetching: false,
772
778
  loading: false,
773
779
  plans,
774
780
  }));
775
781
  }
776
782
  catch (e) {
777
- yield effects.put(actions$8.setError(e.message));
783
+ yield effects.put(actions$9.setError(e.message));
778
784
  }
779
785
  }
780
786
  /*********************************
781
787
  * Preview Sagas
782
788
  *********************************/
783
789
  function* loadPlansMock() {
784
- yield effects.put(actions$8.setLoading(true));
790
+ yield effects.put(actions$9.setLoading(true));
785
791
  yield effects.delay(500);
786
- yield effects.put(actions$8.setState({
792
+ yield effects.put(actions$9.setState({
787
793
  fetching: false,
788
794
  loading: false,
789
795
  plans: planResponseMock.map((item) => {
@@ -793,7 +799,7 @@ function* loadPlansMock() {
793
799
  }));
794
800
  }
795
801
  function* plansSagasMock() {
796
- yield effects.takeEvery(actions$8.loadPlans, loadPlansMock);
802
+ yield effects.takeEvery(actions$9.loadPlans, loadPlansMock);
797
803
  }
798
804
 
799
805
  exports.PaymentMethodType = void 0;
@@ -803,10 +809,10 @@ exports.PaymentMethodType = void 0;
803
809
  })(exports.PaymentMethodType || (exports.PaymentMethodType = {}));
804
810
 
805
811
  function* configSagas() {
806
- yield effects.takeEvery(actions$7.loadPaymentConfiguration, loadPaymentConfiguration);
812
+ yield effects.takeEvery(actions$8.loadPaymentConfiguration, loadPaymentConfiguration);
807
813
  }
808
814
  function* loadPaymentConfiguration() {
809
- yield effects.put(actions$7.setLoading(true));
815
+ yield effects.put(actions$8.setLoading(true));
810
816
  try {
811
817
  const response = yield effects.call(restApi.api.subscriptions.getPaymentProviders) || [];
812
818
  const stripePaymentProvider = response.find((paymentProvider) => paymentProvider.status === '1' && paymentProvider.providerType === restApi.ProviderType.Stripe);
@@ -814,18 +820,18 @@ function* loadPaymentConfiguration() {
814
820
  yield loadStripePaymentConfiguration();
815
821
  }
816
822
  else {
817
- yield effects.put(actions$7.setError('Payment provider not configured'));
823
+ yield effects.put(actions$8.setError('Payment provider not configured'));
818
824
  }
819
825
  }
820
826
  catch (e) {
821
- yield effects.put(actions$7.setError(e.message));
827
+ yield effects.put(actions$8.setError(e.message));
822
828
  }
823
829
  }
824
830
  function* loadStripePaymentConfiguration() {
825
- yield effects.put(actions$7.setLoading(true));
831
+ yield effects.put(actions$8.setLoading(true));
826
832
  try {
827
833
  const response = yield effects.call(restApi.api.subscriptions.getStripePaymentProviderConfiguration);
828
- yield effects.put(actions$7.setState({
834
+ yield effects.put(actions$8.setState({
829
835
  loading: false,
830
836
  fetching: false,
831
837
  config: {
@@ -835,16 +841,16 @@ function* loadStripePaymentConfiguration() {
835
841
  }));
836
842
  }
837
843
  catch (e) {
838
- yield effects.put(actions$7.setError(e.message));
844
+ yield effects.put(actions$8.setError(e.message));
839
845
  }
840
846
  }
841
847
  /*********************************
842
848
  * Preview Sagas
843
849
  *********************************/
844
850
  function* loadPaymentConfigurationMock() {
845
- yield effects.put(actions$7.setLoading(true));
851
+ yield effects.put(actions$8.setLoading(true));
846
852
  yield effects.delay(500);
847
- yield effects.put(actions$7.setState({
853
+ yield effects.put(actions$8.setState({
848
854
  loading: false,
849
855
  fetching: false,
850
856
  config: {
@@ -854,14 +860,14 @@ function* loadPaymentConfigurationMock() {
854
860
  }));
855
861
  }
856
862
  function* configSagasMock() {
857
- yield effects.takeEvery(actions$7.loadPaymentConfiguration, loadPaymentConfigurationMock);
863
+ yield effects.takeEvery(actions$8.loadPaymentConfiguration, loadPaymentConfigurationMock);
858
864
  }
859
865
 
860
866
  function* subscriptionStripeSagas() {
861
- yield effects.takeEvery(actions$1.createCardSetupIntentSecret, createCardSetupIntentSecret);
867
+ yield effects.takeEvery(actions$2.createCardSetupIntentSecret, createCardSetupIntentSecret);
862
868
  }
863
869
  function* createCardSetupIntentSecret({ payload }) {
864
- yield effects.put(actions$1.setState({
870
+ yield effects.put(actions$2.setState({
865
871
  loading: true,
866
872
  error: null,
867
873
  cardSetupIntentSecret: null,
@@ -872,14 +878,47 @@ function* createCardSetupIntentSecret({ payload }) {
872
878
  request.paymentMethodId = payload;
873
879
  }
874
880
  const { setupIntentSecret } = yield effects.call(restApi.api.subscriptions.createStripePaymentMethodSetupIntentSecret, request);
875
- yield effects.put(actions$1.setState({
881
+ yield effects.put(actions$2.setState({
876
882
  cardSetupIntentSecret: setupIntentSecret,
877
883
  loading: false,
878
884
  }));
879
885
  }
886
+ catch (e) {
887
+ yield effects.put(actions$2.setError(e.message));
888
+ }
889
+ }
890
+
891
+ function* vendorPublicConfigSagas() {
892
+ yield effects.takeEvery(actions$1.loadVendorPublicConfiguration, loadVendorPublicConfiguration);
893
+ }
894
+ function* loadVendorPublicConfiguration() {
895
+ yield effects.put(actions$1.setLoading(true));
896
+ try {
897
+ const vendorPublicConfig = yield effects.call(restApi.api.subscriptions.getVendorPublicConfigurations);
898
+ yield effects.put(actions$1.setState({
899
+ fetching: false,
900
+ loading: false,
901
+ vendorPublicConfig,
902
+ }));
903
+ }
880
904
  catch (e) {
881
905
  yield effects.put(actions$1.setError(e.message));
882
906
  }
907
+ }
908
+ /*********************************
909
+ * Preview Sagas
910
+ *********************************/
911
+ function* loadVendorPublicConfigurationMock() {
912
+ yield effects.put(actions$1.setLoading(true));
913
+ yield effects.delay(500);
914
+ yield effects.put(actions$1.setState({
915
+ fetching: false,
916
+ loading: false,
917
+ vendorPublicConfig: vendorPublicConfigurationResponseMock,
918
+ }));
919
+ }
920
+ function* vendorPublicConfigSagasMock() {
921
+ yield effects.takeEvery(actions$1.loadVendorPublicConfiguration, loadVendorPublicConfigurationMock);
883
922
  }
884
923
 
885
924
  function* sagas() {
@@ -889,10 +928,17 @@ function* sagas() {
889
928
  effects.call(plansSagas),
890
929
  effects.call(configSagas),
891
930
  effects.call(subscriptionStripeSagas),
931
+ effects.call(vendorPublicConfigSagas),
892
932
  ]);
893
933
  }
894
934
  function* mockSagas() {
895
- yield effects.all([effects.call(billingSagasMock), effects.call(checkoutSagasMock), effects.call(plansSagasMock), effects.call(configSagasMock)]);
935
+ yield effects.all([
936
+ effects.call(billingSagasMock),
937
+ effects.call(checkoutSagasMock),
938
+ effects.call(plansSagasMock),
939
+ effects.call(configSagasMock),
940
+ effects.call(vendorPublicConfigSagasMock),
941
+ ]);
896
942
  }
897
943
 
898
944
  // export store