@osovitny/anatoly 3.19.28 → 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.
@@ -4356,6 +4356,9 @@ class PaymentsService {
4356
4356
  subtotal = subtotal - (subtotal * (this.discountPercentage / 100));
4357
4357
  subtotal = +subtotal.toFixed(2);
4358
4358
  }
4359
+ // Round to nearest whole number
4360
+ subtotal = Math.round(subtotal);
4361
+ // Ensure non-negative total
4359
4362
  return subtotal > 0 ? subtotal : 0;
4360
4363
  }
4361
4364
  //DiscountCode
@@ -5864,6 +5867,49 @@ class SubscriptionsApiService extends ApiServiceBase {
5864
5867
  type: Injectable
5865
5868
  }], () => [{ type: i1.HttpClient }], null); })();
5866
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
+
5867
5913
  /*
5868
5914
  <file>
5869
5915
  Project:
@@ -5887,15 +5933,10 @@ class PaypalSubscribeButtonComponent extends ComponentBase {
5887
5933
  this._payPalPlanId = value;
5888
5934
  this.initPayPal();
5889
5935
  }
5890
- constructor(zone, appContext, api) {
5936
+ constructor(zone, bs) {
5891
5937
  super();
5892
5938
  this.zone = zone;
5893
- this.appContext = appContext;
5894
- this.api = api;
5895
- this.paymentInProgress = false;
5896
- this.paymentFailed = false;
5897
- //Outputs
5898
- this.statusChange = new EventEmitter();
5939
+ this.bs = bs;
5899
5940
  }
5900
5941
  ngOnInit() {
5901
5942
  this.setDefaults();
@@ -5905,14 +5946,6 @@ class PaypalSubscribeButtonComponent extends ComponentBase {
5905
5946
  }
5906
5947
  setValues() {
5907
5948
  }
5908
- fireStatusChange(paymentInProgress, paymentFailed) {
5909
- this.paymentInProgress = paymentInProgress;
5910
- this.paymentFailed = paymentFailed;
5911
- this.statusChange.emit({
5912
- paymentInProgress,
5913
- paymentFailed
5914
- });
5915
- }
5916
5949
  initPayPal() {
5917
5950
  let that = this;
5918
5951
  let payPalSettings = AppCoreSettings.externalApi.pm.payPal;
@@ -5950,35 +5983,25 @@ class PaypalSubscribeButtonComponent extends ComponentBase {
5950
5983
  onApprove: (data, actions) => {
5951
5984
  try {
5952
5985
  let subscriptionId = data.subscriptionID;
5953
- that.addSubscription(subscriptionId);
5986
+ that.bs.addSubscription(SubscriptionProvider.PayPal, subscriptionId, this.planId, this.addons, this.price, this.totalPrice);
5954
5987
  }
5955
5988
  catch {
5956
- that.fireStatusChange(false, true);
5989
+ that.bs.fireSubscriptionChange(false, true);
5957
5990
  }
5958
5991
  },
5959
5992
  onCancel: (data, actions) => {
5960
- that.fireStatusChange(false, true);
5993
+ that.bs.fireSubscriptionChange(false, true);
5961
5994
  },
5962
5995
  onError: err => {
5963
- that.fireStatusChange(false, true);
5996
+ that.bs.fireSubscriptionChange(false, true);
5964
5997
  },
5965
5998
  onClick: (data, actions) => {
5966
- that.fireStatusChange(true, false);
5999
+ that.bs.fireSubscriptionChange(true, false);
5967
6000
  }
5968
6001
  };
5969
6002
  }
5970
- addSubscription(newSubscriptionId) {
5971
- this.zone.run(() => {
5972
- this.api.addSubscription(SubscriptionProvider.PayPal, newSubscriptionId, this.planId, this.addons, this.price, this.totalPrice, () => {
5973
- this.fireStatusChange(false, false);
5974
- this.appContext.updateCurrent();
5975
- }, () => {
5976
- this.fireStatusChange(false, true);
5977
- });
5978
- });
5979
- }
5980
- static { this.ɵfac = function PaypalSubscribeButtonComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || PaypalSubscribeButtonComponent)(i0.ɵɵdirectiveInject(i0.NgZone), i0.ɵɵdirectiveInject(AppContextService), i0.ɵɵdirectiveInject(SubscriptionsApiService)); }; }
5981
- 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) {
5982
6005
  i0.ɵɵelement(0, "anatoly-billing-paypal-container", 0);
5983
6006
  } if (rf & 2) {
5984
6007
  i0.ɵɵproperty("config", ctx.payPalConfig);
@@ -5987,7 +6010,7 @@ class PaypalSubscribeButtonComponent extends ComponentBase {
5987
6010
  (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(PaypalSubscribeButtonComponent, [{
5988
6011
  type: Component,
5989
6012
  args: [{ selector: 'anatoly-billing-paypal-subscribe-button', standalone: false, template: "<anatoly-billing-paypal-container [config]='payPalConfig' />\r\n\r\n" }]
5990
- }], () => [{ type: i0.NgZone }, { type: AppContextService }, { type: SubscriptionsApiService }], { payPalPlanId: [{
6013
+ }], () => [{ type: i0.NgZone }, { type: BillingService }], { payPalPlanId: [{
5991
6014
  type: Input
5992
6015
  }], quantity: [{
5993
6016
  type: Input
@@ -5999,10 +6022,8 @@ class PaypalSubscribeButtonComponent extends ComponentBase {
5999
6022
  type: Input
6000
6023
  }], totalPrice: [{
6001
6024
  type: Input
6002
- }], statusChange: [{
6003
- type: Output
6004
6025
  }] }); })();
6005
- (() => { (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 }); })();
6006
6027
 
6007
6028
  /*
6008
6029
  <file>