@osovitny/anatoly 3.19.29 → 3.19.30

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.
@@ -5867,6 +5867,49 @@ class SubscriptionsApiService extends ApiServiceBase {
5867
5867
  type: Injectable
5868
5868
  }], () => [{ type: i1.HttpClient }], null); })();
5869
5869
 
5870
+ /*
5871
+ <file>
5872
+ Project:
5873
+ @osovitny/anatoly
5874
+
5875
+ Authors:
5876
+ Vadim Osovitny vadim.osovitny@osovitny.com
5877
+
5878
+ Created:
5879
+ 19 Jul 2025
5880
+
5881
+ Copyright (c) 2016-2025 Osovitny Inc. All rights reserved.
5882
+ </file>
5883
+ */
5884
+ //Node
5885
+ class BillingService {
5886
+ constructor(zone, appContext, api) {
5887
+ this.zone = zone;
5888
+ this.appContext = appContext;
5889
+ this.api = api;
5890
+ this._subscriptionChange = new Subject();
5891
+ this._subscriptionChange$ = this._subscriptionChange.asObservable();
5892
+ }
5893
+ fireSubscriptionChange(paymentInProgress, paymentFailed) {
5894
+ this._subscriptionChange.next({ paymentInProgress, paymentFailed });
5895
+ }
5896
+ addSubscription(sp, newSubscriptionId, planId, addons, price, totalPrice) {
5897
+ this.zone.run(() => {
5898
+ this.api.addSubscription(sp, newSubscriptionId, planId, addons, price, totalPrice, () => {
5899
+ this.fireSubscriptionChange(false, false);
5900
+ this.appContext.updateCurrent();
5901
+ }, () => {
5902
+ this.fireSubscriptionChange(false, true);
5903
+ });
5904
+ });
5905
+ }
5906
+ static { this.ɵfac = function BillingService_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || BillingService)(i0.ɵɵinject(i0.NgZone), i0.ɵɵinject(AppContextService), i0.ɵɵinject(SubscriptionsApiService)); }; }
5907
+ static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: BillingService, factory: BillingService.ɵfac }); }
5908
+ }
5909
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(BillingService, [{
5910
+ type: Injectable
5911
+ }], () => [{ type: i0.NgZone }, { type: AppContextService }, { type: SubscriptionsApiService }], null); })();
5912
+
5870
5913
  /*
5871
5914
  <file>
5872
5915
  Project:
@@ -5890,15 +5933,10 @@ class PaypalSubscribeButtonComponent extends ComponentBase {
5890
5933
  this._payPalPlanId = value;
5891
5934
  this.initPayPal();
5892
5935
  }
5893
- constructor(zone, appContext, api) {
5936
+ constructor(zone, bs) {
5894
5937
  super();
5895
5938
  this.zone = zone;
5896
- this.appContext = appContext;
5897
- this.api = api;
5898
- this.paymentInProgress = false;
5899
- this.paymentFailed = false;
5900
- //Outputs
5901
- this.statusChange = new EventEmitter();
5939
+ this.bs = bs;
5902
5940
  }
5903
5941
  ngOnInit() {
5904
5942
  this.setDefaults();
@@ -5908,14 +5946,6 @@ class PaypalSubscribeButtonComponent extends ComponentBase {
5908
5946
  }
5909
5947
  setValues() {
5910
5948
  }
5911
- fireStatusChange(paymentInProgress, paymentFailed) {
5912
- this.paymentInProgress = paymentInProgress;
5913
- this.paymentFailed = paymentFailed;
5914
- this.statusChange.emit({
5915
- paymentInProgress,
5916
- paymentFailed
5917
- });
5918
- }
5919
5949
  initPayPal() {
5920
5950
  let that = this;
5921
5951
  let payPalSettings = AppCoreSettings.externalApi.pm.payPal;
@@ -5953,35 +5983,25 @@ class PaypalSubscribeButtonComponent extends ComponentBase {
5953
5983
  onApprove: (data, actions) => {
5954
5984
  try {
5955
5985
  let subscriptionId = data.subscriptionID;
5956
- that.addSubscription(subscriptionId);
5986
+ that.bs.addSubscription(SubscriptionProvider.PayPal, subscriptionId, this.planId, this.addons, this.price, this.totalPrice);
5957
5987
  }
5958
5988
  catch {
5959
- that.fireStatusChange(false, true);
5989
+ that.bs.fireSubscriptionChange(false, true);
5960
5990
  }
5961
5991
  },
5962
5992
  onCancel: (data, actions) => {
5963
- that.fireStatusChange(false, true);
5993
+ that.bs.fireSubscriptionChange(false, true);
5964
5994
  },
5965
5995
  onError: err => {
5966
- that.fireStatusChange(false, true);
5996
+ that.bs.fireSubscriptionChange(false, true);
5967
5997
  },
5968
5998
  onClick: (data, actions) => {
5969
- that.fireStatusChange(true, false);
5999
+ that.bs.fireSubscriptionChange(true, false);
5970
6000
  }
5971
6001
  };
5972
6002
  }
5973
- addSubscription(newSubscriptionId) {
5974
- this.zone.run(() => {
5975
- this.api.addSubscription(SubscriptionProvider.PayPal, newSubscriptionId, this.planId, this.addons, this.price, this.totalPrice, () => {
5976
- this.fireStatusChange(false, false);
5977
- this.appContext.updateCurrent();
5978
- }, () => {
5979
- this.fireStatusChange(false, true);
5980
- });
5981
- });
5982
- }
5983
- static { this.ɵfac = function PaypalSubscribeButtonComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || PaypalSubscribeButtonComponent)(i0.ɵɵdirectiveInject(i0.NgZone), i0.ɵɵdirectiveInject(AppContextService), i0.ɵɵdirectiveInject(SubscriptionsApiService)); }; }
5984
- static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: PaypalSubscribeButtonComponent, selectors: [["anatoly-billing-paypal-subscribe-button"]], inputs: { payPalPlanId: "payPalPlanId", quantity: "quantity", planId: "planId", addons: "addons", price: "price", totalPrice: "totalPrice" }, outputs: { statusChange: "statusChange" }, standalone: false, features: [i0.ɵɵInheritDefinitionFeature], decls: 1, vars: 1, consts: [[3, "config"]], template: function PaypalSubscribeButtonComponent_Template(rf, ctx) { if (rf & 1) {
6003
+ static { this.ɵfac = function PaypalSubscribeButtonComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || PaypalSubscribeButtonComponent)(i0.ɵɵdirectiveInject(i0.NgZone), i0.ɵɵdirectiveInject(BillingService)); }; }
6004
+ static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: PaypalSubscribeButtonComponent, selectors: [["anatoly-billing-paypal-subscribe-button"]], inputs: { payPalPlanId: "payPalPlanId", quantity: "quantity", planId: "planId", addons: "addons", price: "price", totalPrice: "totalPrice" }, standalone: false, features: [i0.ɵɵInheritDefinitionFeature], decls: 1, vars: 1, consts: [[3, "config"]], template: function PaypalSubscribeButtonComponent_Template(rf, ctx) { if (rf & 1) {
5985
6005
  i0.ɵɵelement(0, "anatoly-billing-paypal-container", 0);
5986
6006
  } if (rf & 2) {
5987
6007
  i0.ɵɵproperty("config", ctx.payPalConfig);
@@ -5990,7 +6010,7 @@ class PaypalSubscribeButtonComponent extends ComponentBase {
5990
6010
  (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(PaypalSubscribeButtonComponent, [{
5991
6011
  type: Component,
5992
6012
  args: [{ selector: 'anatoly-billing-paypal-subscribe-button', standalone: false, template: "<anatoly-billing-paypal-container [config]='payPalConfig' />\r\n\r\n" }]
5993
- }], () => [{ type: i0.NgZone }, { type: AppContextService }, { type: SubscriptionsApiService }], { payPalPlanId: [{
6013
+ }], () => [{ type: i0.NgZone }, { type: BillingService }], { payPalPlanId: [{
5994
6014
  type: Input
5995
6015
  }], quantity: [{
5996
6016
  type: Input
@@ -6002,10 +6022,8 @@ class PaypalSubscribeButtonComponent extends ComponentBase {
6002
6022
  type: Input
6003
6023
  }], totalPrice: [{
6004
6024
  type: Input
6005
- }], statusChange: [{
6006
- type: Output
6007
6025
  }] }); })();
6008
- (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(PaypalSubscribeButtonComponent, { className: "PaypalSubscribeButtonComponent", filePath: "lib/billing/components/pm/paypal/paypal-subscribe-button.component.ts", lineNumber: 32 }); })();
6026
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(PaypalSubscribeButtonComponent, { className: "PaypalSubscribeButtonComponent", filePath: "lib/billing/components/pm/paypal/paypal-subscribe-button.component.ts", lineNumber: 31 }); })();
6009
6027
 
6010
6028
  /*
6011
6029
  <file>