@osovitny/anatoly 3.19.31 → 3.19.33

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.
@@ -28,10 +28,10 @@ import * as i1$6 from '@angular/platform-browser';
28
28
  import * as i2$1 from '@angular/forms';
29
29
  import { FormControl, Validators, ReactiveFormsModule, FormsModule } from '@angular/forms';
30
30
  import * as dropin from 'braintree-web-drop-in';
31
- import * as i2$2 from '@progress/kendo-angular-dialog';
31
+ import * as i4$1 from '@progress/kendo-angular-dialog';
32
32
  import { DialogsModule } from '@progress/kendo-angular-dialog';
33
33
  import { loadStripe } from '@stripe/stripe-js';
34
- import * as i4$1 from '@progress/kendo-angular-label';
34
+ import * as i4$2 from '@progress/kendo-angular-label';
35
35
  import { LabelModule } from '@progress/kendo-angular-label';
36
36
  import * as i3 from '@progress/kendo-angular-dropdowns';
37
37
  import { DropDownsModule } from '@progress/kendo-angular-dropdowns';
@@ -1342,7 +1342,6 @@ class XmlFormatter {
1342
1342
 
1343
1343
  Authors:
1344
1344
  Vadim Osovitny vadim.osovitny@osovitny.com
1345
- Anatoly Osovitny anatoly.osovitny@osovitny.com
1346
1345
 
1347
1346
  Created:
1348
1347
  11 Nov 2024
@@ -4224,64 +4223,6 @@ class ComponentBase {
4224
4223
  }] }); })();
4225
4224
  (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(ComponentBase, { className: "ComponentBase", filePath: "lib/ui/components/base/components/component.ts", lineNumber: 25 }); })();
4226
4225
 
4227
- /*
4228
- <file>
4229
- Project:
4230
- @osovitny/anatoly
4231
-
4232
- Authors:
4233
- Vadim Osovitny vadim.osovitny@osovitny.com
4234
-
4235
- Created:
4236
- 10 Nov 2024
4237
-
4238
- Copyright (c) 2017-2025 Osovitny Inc. All rights reserved.
4239
- </file>
4240
- */
4241
- //Node
4242
- class PaymentsApiService extends ApiServiceBase {
4243
- constructor(http) {
4244
- super(http);
4245
- this.http = http;
4246
- this.baseUrl = `${ApiUrl}/billing/payments`;
4247
- }
4248
- //Stripe
4249
- createStripeSession(amount, currency, name, description, image) {
4250
- return this.post('createStripeSession', { amount, currency, name, description, image }, 'json');
4251
- }
4252
- //Braintree
4253
- createBraintreeToken() {
4254
- return this.get('createBraintreeToken');
4255
- }
4256
- pay(paymentMethod, paidFor,
4257
- //Amount
4258
- subtotal, promoCode, total, currency,
4259
- //Payment method details (PayPal/Stripe/Braintree)
4260
- pmId, pmStatus, pmDetails, success, error) {
4261
- return this.post('pay', {
4262
- paymentMethod, paidFor,
4263
- //Amount
4264
- subtotal, promoCode, total, currency,
4265
- //Payment method details (PayPal/Stripe/Braintree)
4266
- pmId, pmStatus, pmDetails,
4267
- }, 'json').subscribe({
4268
- next: (data) => {
4269
- if (success)
4270
- success(data);
4271
- },
4272
- error: (e) => {
4273
- if (error)
4274
- error(e);
4275
- }
4276
- });
4277
- }
4278
- static { this.ɵfac = function PaymentsApiService_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || PaymentsApiService)(i0.ɵɵinject(i1.HttpClient)); }; }
4279
- static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: PaymentsApiService, factory: PaymentsApiService.ɵfac }); }
4280
- }
4281
- (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(PaymentsApiService, [{
4282
- type: Injectable
4283
- }], () => [{ type: i1.HttpClient }], null); })();
4284
-
4285
4226
  /*
4286
4227
  <file>
4287
4228
  Project:
@@ -4302,27 +4243,20 @@ class PaymentsApiService extends ApiServiceBase {
4302
4243
  */
4303
4244
  //Node
4304
4245
  class PaymentsService {
4305
- constructor(zone, api, ns, ga) {
4306
- this.zone = zone;
4307
- this.api = api;
4308
- this.ns = ns;
4309
- this.ga = ga;
4310
- this.paymentInProgress = false;
4311
- this.isPaymentFailed = false;
4246
+ constructor() {
4312
4247
  this.subtotal = 0;
4313
- this.discountCode = null;
4314
- this.discountPercentage = null;
4315
- this.discountAmount = null;
4248
+ this.promoCode = null;
4249
+ this.promoPercentage = null;
4250
+ this.promoAmount = null;
4316
4251
  this.currency = 'USD';
4317
- //Private Streams
4318
- this._discountCodeApplied = new Subject();
4319
- this._paymentAdded = new Subject();
4252
+ //promoApplied
4253
+ this._promoCodeApplied = new Subject();
4254
+ this.promoCodeApplied$ = this._promoCodeApplied.asObservable();
4255
+ //showStripeDialog
4320
4256
  this._showStripeDialog = new Subject();
4321
- this._showBraintreeDialog = new Subject();
4322
- //Public Streams
4323
- this.discountCodeApplied$ = this._discountCodeApplied.asObservable();
4324
- this.paymentAdded$ = this._paymentAdded.asObservable();
4325
4257
  this.showStripeDialog$ = this._showStripeDialog.asObservable();
4258
+ //showBraintreeDialog
4259
+ this._showBraintreeDialog = new Subject();
4326
4260
  this.showBraintreeDialog$ = this._showBraintreeDialog.asObservable();
4327
4261
  }
4328
4262
  setDefaults() {
@@ -4330,11 +4264,8 @@ class PaymentsService {
4330
4264
  setValues() {
4331
4265
  }
4332
4266
  //fires
4333
- fireDiscountCodeApplied() {
4334
- this._discountCodeApplied.next(this.discountCode);
4335
- }
4336
- firePaymentAdded(paymentId) {
4337
- this._paymentAdded.next(paymentId);
4267
+ firePromoCodeApplied() {
4268
+ this._promoCodeApplied.next(this.promoCode);
4338
4269
  }
4339
4270
  //Public
4340
4271
  init() {
@@ -4343,17 +4274,17 @@ class PaymentsService {
4343
4274
  }
4344
4275
  resetState() {
4345
4276
  this.subtotal = 0;
4346
- this.discountCode = null;
4347
- this.discountPercentage = null;
4348
- this.discountAmount = null;
4277
+ this.promoCode = null;
4278
+ this.promoPercentage = null;
4279
+ this.promoAmount = null;
4349
4280
  }
4350
4281
  getTotal() {
4351
4282
  let subtotal = this.subtotal;
4352
- if (this.discountAmount != 0) {
4353
- subtotal = subtotal - this.discountAmount;
4283
+ if (this.promoAmount != 0) {
4284
+ subtotal = subtotal - this.promoAmount;
4354
4285
  }
4355
- else if (this.discountPercentage != 0) {
4356
- subtotal = subtotal - (subtotal * (this.discountPercentage / 100));
4286
+ else if (this.promoPercentage != 0) {
4287
+ subtotal = subtotal - (subtotal * (this.promoPercentage / 100));
4357
4288
  subtotal = +subtotal.toFixed(2);
4358
4289
  }
4359
4290
  // Round to nearest whole number
@@ -4361,28 +4292,27 @@ class PaymentsService {
4361
4292
  // Ensure non-negative total
4362
4293
  return subtotal > 0 ? subtotal : 0;
4363
4294
  }
4364
- //DiscountCode
4365
- applyDiscountCode(data) {
4295
+ applyPromoCode(data) {
4366
4296
  if (!data) {
4367
4297
  return;
4368
4298
  }
4369
- this.discountCode = data.code;
4299
+ this.promoCode = data.code;
4370
4300
  if (data.amount) {
4371
- this.discountPercentage = 0;
4372
- this.discountAmount = parseInt(data.amount);
4301
+ this.promoPercentage = 0;
4302
+ this.promoAmount = parseInt(data.amount);
4373
4303
  }
4374
4304
  else if (data.percentage) {
4375
- this.discountPercentage = parseInt(data.percentage);
4376
- this.discountAmount = 0;
4305
+ this.promoPercentage = parseInt(data.percentage);
4306
+ this.promoAmount = 0;
4377
4307
  }
4378
- this.fireDiscountCodeApplied();
4308
+ this.firePromoCodeApplied();
4379
4309
  }
4380
- getDiscountCodeAsString() {
4381
- if (this.discountAmount > 0) {
4382
- return "$" + this.discountAmount;
4310
+ getPromoCodeAsString() {
4311
+ if (this.promoAmount > 0) {
4312
+ return "$" + this.promoAmount;
4383
4313
  }
4384
- else if (this.discountPercentage > 0) {
4385
- return this.discountPercentage + "%";
4314
+ else if (this.promoPercentage > 0) {
4315
+ return this.promoPercentage + "%";
4386
4316
  }
4387
4317
  return '$0';
4388
4318
  }
@@ -4395,57 +4325,12 @@ class PaymentsService {
4395
4325
  closeBraintreePaymentDialog() {
4396
4326
  this._showBraintreeDialog.next(false);
4397
4327
  }
4398
- createStripeSession(title, description, image) {
4399
- const amount = this.getTotal();
4400
- const currency = this.currency;
4401
- return this.api.createStripeSession(amount, currency, title, description, image);
4402
- }
4403
- createBraintreeToken() {
4404
- return this.api.createBraintreeToken();
4405
- }
4406
- pay(paidFor, pmId, pmStatus, pmDetails) {
4407
- //GA
4408
- this.ga.event(GABillingEvents.payment);
4409
- let paymentMethod = this.selectedPaymentMethod;
4410
- let paidForAsString = JSON.stringify(paidFor);
4411
- let payType = this.selectedPaymentType;
4412
- //Amount
4413
- let subtotal = this.subtotal;
4414
- let promoCode = this.discountCode;
4415
- let total = this.getTotal();
4416
- let currency = this.currency;
4417
- if (total == 0) {
4418
- paymentMethod = PaymentMethod.None;
4419
- }
4420
- this.zone.run(() => {
4421
- this.api.pay(paymentMethod, paidForAsString,
4422
- //Amount
4423
- subtotal, promoCode, total, currency,
4424
- //Payment method details (PayPal/Stripe/Braintree)
4425
- pmId, pmStatus, pmDetails, (data) => {
4426
- if (!data || !data?.isPaymentValid) {
4427
- this.paymentFailed(PaymentStage.External);
4428
- return;
4429
- }
4430
- this.paymentInProgress = false;
4431
- this.firePaymentAdded(data.paymentId);
4432
- }, () => {
4433
- this.paymentFailed(PaymentStage.External);
4434
- });
4435
- });
4436
- }
4437
- paymentFailed(stage) {
4438
- this.paymentStage = stage;
4439
- this.paymentInProgress = false;
4440
- this.isPaymentFailed = true;
4441
- this.ns.error("Payment Failed");
4442
- }
4443
- static { this.ɵfac = function PaymentsService_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || PaymentsService)(i0.ɵɵinject(i0.NgZone), i0.ɵɵinject(PaymentsApiService), i0.ɵɵinject(NotificationService), i0.ɵɵinject(GoogleAnalyticsService)); }; }
4328
+ static { this.ɵfac = function PaymentsService_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || PaymentsService)(); }; }
4444
4329
  static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: PaymentsService, factory: PaymentsService.ɵfac }); }
4445
4330
  }
4446
4331
  (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(PaymentsService, [{
4447
4332
  type: Injectable
4448
- }], () => [{ type: i0.NgZone }, { type: PaymentsApiService }, { type: NotificationService }, { type: GoogleAnalyticsService }], null); })();
4333
+ }], null, null); })();
4449
4334
 
4450
4335
  /*
4451
4336
  <file>
@@ -4462,19 +4347,19 @@ class PaymentsService {
4462
4347
  </file>
4463
4348
  */
4464
4349
  //Node
4465
- class DiscountCodesApiService extends ApiServiceBase {
4350
+ class PromoCodesApiService extends ApiServiceBase {
4466
4351
  constructor(http) {
4467
4352
  super(http);
4468
4353
  this.http = http;
4469
- this.baseUrl = `${ApiUrl}/billing/discountCodes`;
4354
+ this.baseUrl = `${ApiUrl}/billing/promoCodes`;
4470
4355
  }
4471
- getDiscountCode(code) {
4472
- return this.get('getDiscountCode', { code });
4356
+ getPromoCode(code) {
4357
+ return this.get('getPromoCode', { code });
4473
4358
  }
4474
- static { this.ɵfac = function DiscountCodesApiService_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || DiscountCodesApiService)(i0.ɵɵinject(i1.HttpClient)); }; }
4475
- static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: DiscountCodesApiService, factory: DiscountCodesApiService.ɵfac }); }
4359
+ static { this.ɵfac = function PromoCodesApiService_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || PromoCodesApiService)(i0.ɵɵinject(i1.HttpClient)); }; }
4360
+ static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: PromoCodesApiService, factory: PromoCodesApiService.ɵfac }); }
4476
4361
  }
4477
- (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(DiscountCodesApiService, [{
4362
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(PromoCodesApiService, [{
4478
4363
  type: Injectable
4479
4364
  }], () => [{ type: i1.HttpClient }], null); })();
4480
4365
 
@@ -4540,7 +4425,7 @@ class OrderSummaryComponent extends ComponentBase {
4540
4425
  this.ns.info("Please enter a promo code");
4541
4426
  return;
4542
4427
  }
4543
- this.api.getDiscountCode(this.promoCode).subscribe({
4428
+ this.api.getPromoCode(this.promoCode).subscribe({
4544
4429
  next: (data) => {
4545
4430
  if (!data) {
4546
4431
  this.ns.error("Invalid Promo Code");
@@ -4548,8 +4433,8 @@ class OrderSummaryComponent extends ComponentBase {
4548
4433
  }
4549
4434
  switch (data.status) {
4550
4435
  case DiscountCodeStatus.Exist:
4551
- this.ps.applyDiscountCode(data);
4552
- this.discount = this.ps.getDiscountCodeAsString();
4436
+ this.ps.applyPromoCode(data);
4437
+ this.discount = this.ps.getPromoCodeAsString();
4553
4438
  this.ns.success("Discount applied successfully");
4554
4439
  break;
4555
4440
  case DiscountCodeStatus.NotFound:
@@ -4568,7 +4453,7 @@ class OrderSummaryComponent extends ComponentBase {
4568
4453
  },
4569
4454
  });
4570
4455
  }
4571
- static { this.ɵfac = function OrderSummaryComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || OrderSummaryComponent)(i0.ɵɵdirectiveInject(PaymentsService), i0.ɵɵdirectiveInject(DiscountCodesApiService), i0.ɵɵdirectiveInject(NotificationService)); }; }
4456
+ static { this.ɵfac = function OrderSummaryComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || OrderSummaryComponent)(i0.ɵɵdirectiveInject(PaymentsService), i0.ɵɵdirectiveInject(PromoCodesApiService), i0.ɵɵdirectiveInject(NotificationService)); }; }
4572
4457
  static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: OrderSummaryComponent, selectors: [["anatoly-billing-order-summary"]], standalone: false, features: [i0.ɵɵInheritDefinitionFeature], ngContentSelectors: _c0$h, decls: 30, vars: 7, consts: [[1, "card"], [1, "card-header"], [1, "card-title"], [1, "card-body"], [1, "order-summary"], [1, "subtotal"], [1, "divider"], [1, "add-promo-code", 3, "click", "ngClass"], [1, "has-arrow"], [1, "add-promo-code", 3, "ngClass"], [1, "discounts"], [1, "total"], [1, "promo-code"], ["type", "text", "placeholder", "Promo code", 1, "input-text", 3, "ngModelChange", "ngModel"], [1, "btn", 3, "click"]], template: function OrderSummaryComponent_Template(rf, ctx) { if (rf & 1) {
4573
4458
  i0.ɵɵprojectionDef();
4574
4459
  i0.ɵɵelementStart(0, "div", 0)(1, "div", 1)(2, "div", 2)(3, "h2");
@@ -4619,7 +4504,7 @@ class OrderSummaryComponent extends ComponentBase {
4619
4504
  (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(OrderSummaryComponent, [{
4620
4505
  type: Component,
4621
4506
  args: [{ selector: "anatoly-billing-order-summary", standalone: false, template: "<div class='card'>\r\n <div class='card-header'>\r\n <div class='card-title'>\r\n <h2>Order Summary</h2>\r\n </div>\r\n </div>\r\n <div class='card-body'>\r\n <div class='order-summary'>\r\n <ng-content></ng-content>\r\n\r\n <div class='subtotal'>\r\n <span>Subtotal:</span><strong>${{ ps.subtotal }}</strong>\r\n </div>\r\n <div class='divider'></div>\r\n <div class=\"add-promo-code\" [ngClass]=\"{ 'show': showPromoCode }\" (click)=\"onTogglePromoCode()\">\r\n <span class='has-arrow'>Add a Promo Code:</span>\r\n </div>\r\n\r\n @if (showPromoCode) {\r\n <div class=\"add-promo-code\" [ngClass]=\"{ 'show': showPromoCode }\">\r\n <div class=\"promo-code\">\r\n <input type=\"text\" [(ngModel)]=\"promoCode\" class=\"input-text\" placeholder=\"Promo code\">\r\n <button class=\"btn\" (click)=\"onApplyPromoCode()\">Apply</button>\r\n </div>\r\n </div>\r\n }\r\n\r\n <div class='divider'></div>\r\n <div class='discounts'>\r\n <span>Discounts & Savings:</span>\r\n <strong>{{ discount }}</strong>\r\n </div>\r\n <div class='divider'></div>\r\n <div class='total'>\r\n <span>Total:</span>\r\n <strong>${{ toTotal() }}</strong>\r\n </div>\r\n </div>\r\n </div>\r\n</div>\r\n" }]
4622
- }], () => [{ type: PaymentsService }, { type: DiscountCodesApiService }, { type: NotificationService }], null); })();
4507
+ }], () => [{ type: PaymentsService }, { type: PromoCodesApiService }, { type: NotificationService }], null); })();
4623
4508
  (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(OrderSummaryComponent, { className: "OrderSummaryComponent", filePath: "lib/billing/components/order-summary/order-summary.component.ts", lineNumber: 32 }); })();
4624
4509
 
4625
4510
  /*
@@ -5098,6 +4983,245 @@ class DialogBase extends EditComponentBase {
5098
4983
  }] }); })();
5099
4984
  (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(DialogBase, { className: "DialogBase", filePath: "lib/ui/components/base/dialog.ts", lineNumber: 28 }); })();
5100
4985
 
4986
+ /*
4987
+ <file>
4988
+ Project:
4989
+ @osovitny/anatoly
4990
+
4991
+ Authors:
4992
+ Vadim Osovitny vadim.osovitny@osovitny.com
4993
+
4994
+ Created:
4995
+ 11 Nov 2024
4996
+
4997
+ Copyright (c) 2016-2025 Osovitny Inc. All rights reserved.
4998
+ </file>
4999
+ */
5000
+
5001
+ /*
5002
+ <file>
5003
+ Project:
5004
+ @osovitny/anatoly
5005
+
5006
+ Authors:
5007
+ Vadim Osovitny vadim.osovitny@osovitny.com
5008
+
5009
+ Created:
5010
+ 10 Nov 2024
5011
+
5012
+ Copyright (c) 2017-2025 Osovitny Inc. All rights reserved.
5013
+ </file>
5014
+ */
5015
+ //Node
5016
+ class PaymentsApiService extends ApiServiceBase {
5017
+ constructor(http) {
5018
+ super(http);
5019
+ this.http = http;
5020
+ this.baseUrl = `${ApiUrl}/billing/payments`;
5021
+ }
5022
+ //Stripe
5023
+ createStripeSession(amount, currency, name, description, image) {
5024
+ return this.post('createStripeSession', { amount, currency, name, description, image }, 'json');
5025
+ }
5026
+ //Braintree
5027
+ createBraintreeToken() {
5028
+ return this.get('createBraintreeToken');
5029
+ }
5030
+ addPayment(paymentMethod, paidFor,
5031
+ //Amount
5032
+ subtotal, promoCode, total, currency,
5033
+ //Payment method details (PayPal/Stripe/Braintree)
5034
+ pmId, pmStatus, pmDetails, success, error) {
5035
+ return this.post('addPayment', {
5036
+ paymentMethod, paidFor,
5037
+ //Amount
5038
+ subtotal, promoCode, total, currency,
5039
+ //Payment method details (PayPal/Stripe/Braintree)
5040
+ pmId, pmStatus, pmDetails,
5041
+ }, 'json').subscribe({
5042
+ next: (data) => {
5043
+ if (success)
5044
+ success(data);
5045
+ },
5046
+ error: (e) => {
5047
+ if (error)
5048
+ error(e);
5049
+ }
5050
+ });
5051
+ }
5052
+ static { this.ɵfac = function PaymentsApiService_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || PaymentsApiService)(i0.ɵɵinject(i1.HttpClient)); }; }
5053
+ static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: PaymentsApiService, factory: PaymentsApiService.ɵfac }); }
5054
+ }
5055
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(PaymentsApiService, [{
5056
+ type: Injectable
5057
+ }], () => [{ type: i1.HttpClient }], null); })();
5058
+
5059
+ /*
5060
+ <file>
5061
+ Project:
5062
+ @osovitny/anatoly
5063
+
5064
+ Authors:
5065
+ Vadim Osovitny vadim.osovitny@osovitny.com
5066
+
5067
+ Created:
5068
+ 10 Nov 2024
5069
+
5070
+ Copyright (c) 2017-2025 Osovitny Inc. All rights reserved.
5071
+ </file>
5072
+ */
5073
+ //Node
5074
+ class SubscriptionsApiService extends ApiServiceBase {
5075
+ constructor(http) {
5076
+ super(http);
5077
+ this.http = http;
5078
+ this.baseUrl = `${ApiUrl}/billing/subscriptions`;
5079
+ }
5080
+ getSubscriptions(data) {
5081
+ return this.get('getSubscriptions', data);
5082
+ }
5083
+ addSubscription(
5084
+ //Subscription
5085
+ subscriptionProvider, newSubscriptionId,
5086
+ //Plan & Price
5087
+ planId, addons, subtotal, promoCode, total, currency, success, error) {
5088
+ this.post('addSubscription', {
5089
+ subscriptionProvider, newSubscriptionId,
5090
+ planId, addons, subtotal, promoCode, total, currency
5091
+ }).subscribe({
5092
+ next: (data) => {
5093
+ if (success)
5094
+ success(data);
5095
+ },
5096
+ error: (e) => {
5097
+ if (error)
5098
+ error(e);
5099
+ }
5100
+ });
5101
+ }
5102
+ cancelSubscription(subscriptionProvider, subscriptionId, success, error) {
5103
+ this.post('cancelSubscription', { subscriptionProvider, subscriptionId }).subscribe({
5104
+ next: (data) => {
5105
+ if (success)
5106
+ success(data);
5107
+ },
5108
+ error: (e) => {
5109
+ if (error)
5110
+ error(e);
5111
+ }
5112
+ });
5113
+ }
5114
+ static { this.ɵfac = function SubscriptionsApiService_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || SubscriptionsApiService)(i0.ɵɵinject(i1.HttpClient)); }; }
5115
+ static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: SubscriptionsApiService, factory: SubscriptionsApiService.ɵfac }); }
5116
+ }
5117
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(SubscriptionsApiService, [{
5118
+ type: Injectable
5119
+ }], () => [{ type: i1.HttpClient }], null); })();
5120
+
5121
+ /*
5122
+ <file>
5123
+ Project:
5124
+ @osovitny/anatoly
5125
+
5126
+ Authors:
5127
+ Vadim Osovitny vadim.osovitny@osovitny.com
5128
+
5129
+ Created:
5130
+ 19 Jul 2025
5131
+
5132
+ Copyright (c) 2016-2025 Osovitny Inc. All rights reserved.
5133
+ </file>
5134
+ */
5135
+ //Node
5136
+ class BillingService {
5137
+ constructor(zone, appContext, apiPayments, apiSubscriptions, ns) {
5138
+ this.zone = zone;
5139
+ this.appContext = appContext;
5140
+ this.apiPayments = apiPayments;
5141
+ this.apiSubscriptions = apiSubscriptions;
5142
+ this.ns = ns;
5143
+ //paymentAdded
5144
+ this._paymentAdded = new Subject();
5145
+ this.paymentAdded$ = this._paymentAdded.asObservable();
5146
+ //paymentProgress
5147
+ this._paymentProgress = new Subject();
5148
+ this.paymentProgress$ = this._paymentProgress.asObservable();
5149
+ //subscriptionAdded
5150
+ this._subscriptionAdded = new Subject();
5151
+ this.subscriptionAdded$ = this._subscriptionAdded.asObservable();
5152
+ }
5153
+ //fires
5154
+ firePaymentAdded(isPaymentValid, paymentId) {
5155
+ this._paymentAdded.next({ isPaymentValid, paymentId });
5156
+ }
5157
+ firePaymentProgress(paymentStage, paymentInProgress, isPaymentFailed) {
5158
+ this._paymentAdded.next({ paymentStage, paymentInProgress, isPaymentFailed });
5159
+ }
5160
+ fireSubscriptionAdded(paymentInProgress, paymentFailed) {
5161
+ this._subscriptionAdded.next({ paymentInProgress, paymentFailed });
5162
+ }
5163
+ createStripeSession(amount, currency, title, description, image) {
5164
+ return this.apiPayments.createStripeSession(amount, currency, title, description, image);
5165
+ }
5166
+ createBraintreeToken() {
5167
+ return this.apiPayments.createBraintreeToken();
5168
+ }
5169
+ /*
5170
+ */
5171
+ addPayment(paymentMethod, paidFor, subtotal, promoCode, total, currency, pmId, pmStatus, pmDetails) {
5172
+ this.zone.run(() => {
5173
+ let paidForAsString = JSON.stringify(paidFor);
5174
+ if (total == 0) {
5175
+ paymentMethod = PaymentMethod.None;
5176
+ }
5177
+ this.apiPayments.addPayment(paymentMethod, paidForAsString,
5178
+ //Amount
5179
+ subtotal, promoCode, total, currency,
5180
+ //Payment method details (PayPal/Stripe/Braintree)
5181
+ pmId, pmStatus, pmDetails, (data) => {
5182
+ if (!data || !data?.isPaymentValid) {
5183
+ this.paymentFailed(PaymentStage.External);
5184
+ return;
5185
+ }
5186
+ this.paymentSuccessful(PaymentStage.External);
5187
+ this.firePaymentAdded(data.isPaymentValid, data.paymentId);
5188
+ }, () => {
5189
+ this.paymentFailed(PaymentStage.External);
5190
+ });
5191
+ });
5192
+ }
5193
+ paymentSuccessful(stage) {
5194
+ this.setPaymentProgress(stage, false, false);
5195
+ }
5196
+ paymentFailed(stage) {
5197
+ this.setPaymentProgress(stage, false, true);
5198
+ }
5199
+ setPaymentProgress(stage, paymentInProgress, isPaymentFailed) {
5200
+ this.firePaymentProgress(stage, paymentInProgress, isPaymentFailed);
5201
+ if (!paymentInProgress && isPaymentFailed) {
5202
+ this.ns.error("Payment Failed");
5203
+ }
5204
+ }
5205
+ /*
5206
+ Adding Subscription after it is paid
5207
+ */
5208
+ addSubscription(sp, newSubscriptionId, planId, addons, subtotal, promoCode, total, currency) {
5209
+ this.zone.run(() => {
5210
+ this.apiSubscriptions.addSubscription(sp, newSubscriptionId, planId, addons, subtotal, promoCode, total, currency, () => {
5211
+ this.fireSubscriptionAdded(false, false);
5212
+ this.appContext.updateCurrent();
5213
+ }, () => {
5214
+ this.fireSubscriptionAdded(false, true);
5215
+ });
5216
+ });
5217
+ }
5218
+ static { this.ɵfac = function BillingService_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || BillingService)(i0.ɵɵinject(i0.NgZone), i0.ɵɵinject(AppContextService), i0.ɵɵinject(PaymentsApiService), i0.ɵɵinject(SubscriptionsApiService), i0.ɵɵinject(NotificationService)); }; }
5219
+ static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: BillingService, factory: BillingService.ɵfac }); }
5220
+ }
5221
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(BillingService, [{
5222
+ type: Injectable
5223
+ }], () => [{ type: i0.NgZone }, { type: AppContextService }, { type: PaymentsApiService }, { type: SubscriptionsApiService }, { type: NotificationService }], null); })();
5224
+
5101
5225
  /*
5102
5226
  <file>
5103
5227
  Project:
@@ -5140,8 +5264,9 @@ function BraintreeDialog_Conditional_0_Template(rf, ctx) { if (rf & 1) {
5140
5264
  i0.ɵɵproperty("width", 480)("height", 560)("themeColor", ctx_r1.themeColor);
5141
5265
  } }
5142
5266
  class BraintreeDialog extends DialogBase {
5143
- constructor(ps, ns) {
5267
+ constructor(bs, ps, ns) {
5144
5268
  super();
5269
+ this.bs = bs;
5145
5270
  this.ps = ps;
5146
5271
  this.ns = ns;
5147
5272
  }
@@ -5158,7 +5283,7 @@ class BraintreeDialog extends DialogBase {
5158
5283
  const that = this;
5159
5284
  // let totalPrice = this.bs.getTotal().toString();
5160
5285
  // let currency = this.bs.currency;
5161
- this.ps.createBraintreeToken().subscribe((response) => {
5286
+ this.bs.createBraintreeToken().subscribe((response) => {
5162
5287
  if (response?.token) {
5163
5288
  dropin.create({
5164
5289
  authorization: response?.token,
@@ -5195,7 +5320,13 @@ class BraintreeDialog extends DialogBase {
5195
5320
  });
5196
5321
  }
5197
5322
  submitPayment(payload) {
5198
- this.ps.pay(this.paidFor, payload.nonce, 'COMPLETED', this.deviceData);
5323
+ //ps
5324
+ let paymentMethod = this.ps.selectedPaymentMethod;
5325
+ let subtotal = this.ps.subtotal;
5326
+ let promoCode = this.ps.promoCode;
5327
+ let total = this.ps.getTotal();
5328
+ let currency = this.ps.currency;
5329
+ this.bs.addPayment(paymentMethod, this.paidFor, subtotal, promoCode, total, currency, payload.nonce, 'COMPLETED', this.deviceData);
5199
5330
  }
5200
5331
  closeDialog() {
5201
5332
  super.close();
@@ -5224,17 +5355,17 @@ class BraintreeDialog extends DialogBase {
5224
5355
  get visible() {
5225
5356
  return this.isOpen && this.ps.getTotal() > 0;
5226
5357
  }
5227
- static { this.ɵfac = function BraintreeDialog_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || BraintreeDialog)(i0.ɵɵdirectiveInject(PaymentsService), i0.ɵɵdirectiveInject(NotificationService)); }; }
5358
+ static { this.ɵfac = function BraintreeDialog_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || BraintreeDialog)(i0.ɵɵdirectiveInject(BillingService), i0.ɵɵdirectiveInject(PaymentsService), i0.ɵɵdirectiveInject(NotificationService)); }; }
5228
5359
  static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: BraintreeDialog, selectors: [["anatoly-billing-braintree-dialog"]], inputs: { paidFor: "paidFor", title: "title", description: "description", image: "image" }, standalone: false, features: [i0.ɵɵInheritDefinitionFeature], decls: 1, vars: 1, consts: [[1, "send-message__kendo-dialog"], [3, "close", "width", "height", "themeColor"], [1, "kendo-dialog-content"], ["id", "braintree-container"], ["layout", "end"], ["type", "button", 1, "btn", "btn-sm", "btn-success", 3, "click"], ["type", "button", 1, "btn", "btn-sm", "btn-danger", 3, "click"]], template: function BraintreeDialog_Template(rf, ctx) { if (rf & 1) {
5229
5360
  i0.ɵɵtemplate(0, BraintreeDialog_Conditional_0_Template, 11, 3, "div", 0);
5230
5361
  } if (rf & 2) {
5231
5362
  i0.ɵɵconditional(ctx.visible ? 0 : -1);
5232
- } }, dependencies: [i2$2.DialogComponent, i2$2.DialogTitleBarComponent, i2$2.DialogActionsComponent], encapsulation: 2 }); }
5363
+ } }, dependencies: [i4$1.DialogComponent, i4$1.DialogTitleBarComponent, i4$1.DialogActionsComponent], encapsulation: 2 }); }
5233
5364
  }
5234
5365
  (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(BraintreeDialog, [{
5235
5366
  type: Component,
5236
5367
  args: [{ selector: 'anatoly-billing-braintree-dialog', standalone: false, template: "@if (visible) {\r\n <div class='send-message__kendo-dialog'>\r\n <kendo-dialog [width]='480' [height]='560' [themeColor]='themeColor' (close)='onClose()'>\r\n <kendo-dialog-titlebar>Pay with Credit Card</kendo-dialog-titlebar>\r\n <div class='kendo-dialog-content'>\r\n <div id=\"braintree-container\"></div>\r\n </div>\r\n <kendo-dialog-actions layout='end'>\r\n <button class='btn btn-sm btn-success' type='button' (click)='onPay()'>Pay</button>\r\n <button class='btn btn-sm btn-danger' type='button' (click)='onClose()'>Cancel</button>\r\n </kendo-dialog-actions>\r\n </kendo-dialog>\r\n </div>\r\n}\r\n" }]
5237
- }], () => [{ type: PaymentsService }, { type: NotificationService }], { paidFor: [{
5368
+ }], () => [{ type: BillingService }, { type: PaymentsService }, { type: NotificationService }], { paidFor: [{
5238
5369
  type: Input
5239
5370
  }], title: [{
5240
5371
  type: Input
@@ -5243,7 +5374,7 @@ class BraintreeDialog extends DialogBase {
5243
5374
  }], image: [{
5244
5375
  type: Input
5245
5376
  }] }); })();
5246
- (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(BraintreeDialog, { className: "BraintreeDialog", filePath: "lib/billing/components/pm/braintree/braintree.component.ts", lineNumber: 33 }); })();
5377
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(BraintreeDialog, { className: "BraintreeDialog", filePath: "lib/billing/components/pm/braintree/braintree.component.ts", lineNumber: 34 }); })();
5247
5378
 
5248
5379
  /*
5249
5380
  <file>
@@ -5680,8 +5811,9 @@ function PaypalButtonComponent_Conditional_0_Template(rf, ctx) { if (rf & 1) {
5680
5811
  i0.ɵɵproperty("config", ctx_r0.payPalConfig);
5681
5812
  } }
5682
5813
  class PaypalButtonComponent extends ComponentBase {
5683
- constructor(ps) {
5814
+ constructor(bs, ps) {
5684
5815
  super();
5816
+ this.bs = bs;
5685
5817
  this.ps = ps;
5686
5818
  this.paidForTitle = 'Payment for Prodiuct';
5687
5819
  }
@@ -5693,7 +5825,7 @@ class PaypalButtonComponent extends ComponentBase {
5693
5825
  }
5694
5826
  setValues() {
5695
5827
  this.initPayPal();
5696
- this.ps.discountCodeApplied$.subscribe((data) => {
5828
+ this.ps.promoCodeApplied$.subscribe((data) => {
5697
5829
  this.initPayPal();
5698
5830
  });
5699
5831
  }
@@ -5753,34 +5885,38 @@ class PaypalButtonComponent extends ComponentBase {
5753
5885
  onApprove: (data, actions) => {
5754
5886
  return actions.order.capture().then(function (orderData) {
5755
5887
  try {
5888
+ //
5756
5889
  let payment = orderData.purchase_units[0].payments.captures[0];
5757
5890
  let paymentId = payment.id;
5758
5891
  let status = payment.status;
5759
5892
  let amount = payment.amount.value;
5760
5893
  let currencyCode = payment.amount.currency_code;
5761
5894
  let details = JSON.stringify(orderData);
5762
- that.ps.pay(that.paidFor, paymentId, status, details);
5895
+ //ps
5896
+ let paymentMethod = this.ps.selectedPaymentMethod;
5897
+ let subtotal = this.ps.subtotal;
5898
+ let promoCode = this.ps.promoCode;
5899
+ let total = this.ps.getTotal();
5900
+ let currency = this.ps.currency;
5901
+ that.bs.addPayment(paymentMethod, that.paidFor, subtotal, promoCode, total, currency, paymentId, status, details);
5763
5902
  }
5764
5903
  catch {
5765
- that.ps.paymentFailed(PaymentStage.External);
5904
+ that.bs.paymentFailed(PaymentStage.External);
5766
5905
  }
5767
5906
  });
5768
5907
  },
5769
5908
  onCancel: (data, actions) => {
5770
- that.ps.paymentInProgress = false;
5771
5909
  },
5772
5910
  onError: err => {
5773
- that.ps.paymentInProgress = false;
5774
5911
  },
5775
5912
  onClick: (data, actions) => {
5776
- that.ps.paymentInProgress = true;
5777
5913
  }
5778
5914
  };
5779
5915
  }
5780
5916
  get visible() {
5781
5917
  return this.ps.selectedPaymentMethod == PaymentMethod.PayPal && this.ps.getTotal() > 0;
5782
5918
  }
5783
- static { this.ɵfac = function PaypalButtonComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || PaypalButtonComponent)(i0.ɵɵdirectiveInject(PaymentsService)); }; }
5919
+ static { this.ɵfac = function PaypalButtonComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || PaypalButtonComponent)(i0.ɵɵdirectiveInject(BillingService), i0.ɵɵdirectiveInject(PaymentsService)); }; }
5784
5920
  static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: PaypalButtonComponent, selectors: [["anatoly-billing-paypal-button"]], inputs: { paidForTitle: "paidForTitle", paidFor: "paidFor" }, standalone: false, features: [i0.ɵɵInheritDefinitionFeature], decls: 1, vars: 1, consts: [[3, "config"]], template: function PaypalButtonComponent_Template(rf, ctx) { if (rf & 1) {
5785
5921
  i0.ɵɵtemplate(0, PaypalButtonComponent_Conditional_0_Template, 1, 1, "anatoly-billing-paypal-container", 0);
5786
5922
  } if (rf & 2) {
@@ -5790,125 +5926,12 @@ class PaypalButtonComponent extends ComponentBase {
5790
5926
  (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(PaypalButtonComponent, [{
5791
5927
  type: Component,
5792
5928
  args: [{ selector: 'anatoly-billing-paypal-button', standalone: false, template: "@if (visible) {\r\n <anatoly-billing-paypal-container [config]='payPalConfig' />\r\n}\r\n" }]
5793
- }], () => [{ type: PaymentsService }], { paidForTitle: [{
5929
+ }], () => [{ type: BillingService }, { type: PaymentsService }], { paidForTitle: [{
5794
5930
  type: Input
5795
5931
  }], paidFor: [{
5796
5932
  type: Input
5797
5933
  }] }); })();
5798
- (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(PaypalButtonComponent, { className: "PaypalButtonComponent", filePath: "lib/billing/components/pm/paypal/paypal-button.component.ts", lineNumber: 43 }); })();
5799
-
5800
- /*
5801
- <file>
5802
- Project:
5803
- @osovitny/anatoly
5804
-
5805
- Authors:
5806
- Vadim Osovitny vadim.osovitny@osovitny.com
5807
-
5808
- Created:
5809
- 11 Nov 2024
5810
-
5811
- Copyright (c) 2016-2025 Osovitny Inc. All rights reserved.
5812
- </file>
5813
- */
5814
-
5815
- /*
5816
- <file>
5817
- Project:
5818
- @osovitny/anatoly
5819
-
5820
- Authors:
5821
- Vadim Osovitny vadim.osovitny@osovitny.com
5822
-
5823
- Created:
5824
- 10 Nov 2024
5825
-
5826
- Copyright (c) 2017-2025 Osovitny Inc. All rights reserved.
5827
- </file>
5828
- */
5829
- //Node
5830
- class SubscriptionsApiService extends ApiServiceBase {
5831
- constructor(http) {
5832
- super(http);
5833
- this.http = http;
5834
- this.baseUrl = `${ApiUrl}/billing/subscriptions`;
5835
- }
5836
- getSubscriptions(data) {
5837
- return this.get('getSubscriptions', data);
5838
- }
5839
- addSubscription(subscriptionProvider, newSubscriptionId, planId, addons, price, totalPrice, success, error) {
5840
- this.post('addSubscription', { subscriptionProvider, newSubscriptionId, planId, addons, price, totalPrice }).subscribe({
5841
- next: (data) => {
5842
- if (success)
5843
- success(data);
5844
- },
5845
- error: (e) => {
5846
- if (error)
5847
- error(e);
5848
- }
5849
- });
5850
- }
5851
- cancelSubscription(subscriptionProvider, subscriptionId, success, error) {
5852
- this.post('cancelSubscription', { subscriptionProvider, subscriptionId }).subscribe({
5853
- next: (data) => {
5854
- if (success)
5855
- success(data);
5856
- },
5857
- error: (e) => {
5858
- if (error)
5859
- error(e);
5860
- }
5861
- });
5862
- }
5863
- static { this.ɵfac = function SubscriptionsApiService_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || SubscriptionsApiService)(i0.ɵɵinject(i1.HttpClient)); }; }
5864
- static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: SubscriptionsApiService, factory: SubscriptionsApiService.ɵfac }); }
5865
- }
5866
- (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(SubscriptionsApiService, [{
5867
- type: Injectable
5868
- }], () => [{ type: i1.HttpClient }], null); })();
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); })();
5934
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(PaypalButtonComponent, { className: "PaypalButtonComponent", filePath: "lib/billing/components/pm/paypal/paypal-button.component.ts", lineNumber: 44 }); })();
5912
5935
 
5913
5936
  /*
5914
5937
  <file>
@@ -5933,10 +5956,10 @@ class PaypalSubscribeButtonComponent extends ComponentBase {
5933
5956
  this._payPalPlanId = value;
5934
5957
  this.initPayPal();
5935
5958
  }
5936
- constructor(zone, bs) {
5959
+ constructor(bs) {
5937
5960
  super();
5938
- this.zone = zone;
5939
5961
  this.bs = bs;
5962
+ this.currency = 'USD';
5940
5963
  }
5941
5964
  ngOnInit() {
5942
5965
  this.setDefaults();
@@ -5983,25 +6006,25 @@ class PaypalSubscribeButtonComponent extends ComponentBase {
5983
6006
  onApprove: (data, actions) => {
5984
6007
  try {
5985
6008
  let subscriptionId = data.subscriptionID;
5986
- that.bs.addSubscription(SubscriptionProvider.PayPal, subscriptionId, this.planId, this.addons, this.price, this.totalPrice);
6009
+ that.bs.addSubscription(SubscriptionProvider.PayPal, subscriptionId, this.planId, this.addons, this.subtotal, this.promoCode, this.total, this.currency);
5987
6010
  }
5988
6011
  catch {
5989
- that.bs.fireSubscriptionChange(false, true);
6012
+ that.bs.fireSubscriptionAdded(false, true);
5990
6013
  }
5991
6014
  },
5992
6015
  onCancel: (data, actions) => {
5993
- that.bs.fireSubscriptionChange(false, true);
6016
+ that.bs.fireSubscriptionAdded(false, true);
5994
6017
  },
5995
6018
  onError: err => {
5996
- that.bs.fireSubscriptionChange(false, true);
6019
+ that.bs.fireSubscriptionAdded(false, true);
5997
6020
  },
5998
6021
  onClick: (data, actions) => {
5999
- that.bs.fireSubscriptionChange(true, false);
6022
+ that.bs.fireSubscriptionAdded(true, false);
6000
6023
  }
6001
6024
  };
6002
6025
  }
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) {
6026
+ static { this.ɵfac = function PaypalSubscribeButtonComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || PaypalSubscribeButtonComponent)(i0.ɵɵdirectiveInject(BillingService)); }; }
6027
+ static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: PaypalSubscribeButtonComponent, selectors: [["anatoly-billing-paypal-subscribe-button"]], inputs: { payPalPlanId: "payPalPlanId", quantity: "quantity", planId: "planId", addons: "addons", subtotal: "subtotal", promoCode: "promoCode", total: "total", currency: "currency" }, standalone: false, features: [i0.ɵɵInheritDefinitionFeature], decls: 1, vars: 1, consts: [[3, "config"]], template: function PaypalSubscribeButtonComponent_Template(rf, ctx) { if (rf & 1) {
6005
6028
  i0.ɵɵelement(0, "anatoly-billing-paypal-container", 0);
6006
6029
  } if (rf & 2) {
6007
6030
  i0.ɵɵproperty("config", ctx.payPalConfig);
@@ -6010,7 +6033,7 @@ class PaypalSubscribeButtonComponent extends ComponentBase {
6010
6033
  (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(PaypalSubscribeButtonComponent, [{
6011
6034
  type: Component,
6012
6035
  args: [{ selector: 'anatoly-billing-paypal-subscribe-button', standalone: false, template: "<anatoly-billing-paypal-container [config]='payPalConfig' />\r\n\r\n" }]
6013
- }], () => [{ type: i0.NgZone }, { type: BillingService }], { payPalPlanId: [{
6036
+ }], () => [{ type: BillingService }], { payPalPlanId: [{
6014
6037
  type: Input
6015
6038
  }], quantity: [{
6016
6039
  type: Input
@@ -6018,9 +6041,13 @@ class PaypalSubscribeButtonComponent extends ComponentBase {
6018
6041
  type: Input
6019
6042
  }], addons: [{
6020
6043
  type: Input
6021
- }], price: [{
6044
+ }], subtotal: [{
6022
6045
  type: Input
6023
- }], totalPrice: [{
6046
+ }], promoCode: [{
6047
+ type: Input
6048
+ }], total: [{
6049
+ type: Input
6050
+ }], currency: [{
6024
6051
  type: Input
6025
6052
  }] }); })();
6026
6053
  (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(PaypalSubscribeButtonComponent, { className: "PaypalSubscribeButtonComponent", filePath: "lib/billing/components/pm/paypal/paypal-subscribe-button.component.ts", lineNumber: 31 }); })();
@@ -6059,8 +6086,9 @@ function StripeDialog_Conditional_0_Template(rf, ctx) { if (rf & 1) {
6059
6086
  i0.ɵɵproperty("width", 1080)("height", 800)("themeColor", ctx_r1.themeColor);
6060
6087
  } }
6061
6088
  class StripeDialog extends DialogBase {
6062
- constructor(ps) {
6089
+ constructor(bs, ps) {
6063
6090
  super();
6091
+ this.bs = bs;
6064
6092
  this.ps = ps;
6065
6093
  }
6066
6094
  ngOnInit() {
@@ -6074,11 +6102,13 @@ class StripeDialog extends DialogBase {
6074
6102
  }
6075
6103
  async initializeEmbedForm() {
6076
6104
  let stripePk = AppCoreSettings.external.pm.stripe.publishableKey;
6077
- this.stripe = await loadStripe(stripePk);
6078
6105
  const that = this;
6106
+ this.stripe = await loadStripe(stripePk);
6079
6107
  this.stripeCheckout = await this.stripe.initEmbeddedCheckout({
6080
6108
  fetchClientSecret: async () => {
6081
- const response = await firstValueFrom(that.ps.createStripeSession(this.title, this.description, this.image));
6109
+ const amount = this.ps.getTotal();
6110
+ const currency = this.ps.currency;
6111
+ const response = await firstValueFrom(that.bs.createStripeSession(amount, currency, this.title, this.description, this.image));
6082
6112
  if (response) {
6083
6113
  that.sessionId = response.sessionId;
6084
6114
  return response?.sessionSecret ? response.sessionSecret : '';
@@ -6086,7 +6116,13 @@ class StripeDialog extends DialogBase {
6086
6116
  return '';
6087
6117
  },
6088
6118
  onComplete: () => {
6089
- that.ps.pay(this.paidFor, this.sessionId, 'COMPLETED', '');
6119
+ //ps
6120
+ let paymentMethod = this.ps.selectedPaymentMethod;
6121
+ let subtotal = this.ps.subtotal;
6122
+ let promoCode = this.ps.promoCode;
6123
+ let total = this.ps.getTotal();
6124
+ let currency = this.ps.currency;
6125
+ this.bs.addPayment(paymentMethod, this.paidFor, subtotal, promoCode, total, currency, this.sessionId, 'COMPLETED', '');
6090
6126
  that.onClose();
6091
6127
  }
6092
6128
  });
@@ -6104,17 +6140,17 @@ class StripeDialog extends DialogBase {
6104
6140
  get visible() {
6105
6141
  return this.isOpen && this.ps.getTotal() > 0;
6106
6142
  }
6107
- static { this.ɵfac = function StripeDialog_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || StripeDialog)(i0.ɵɵdirectiveInject(PaymentsService)); }; }
6143
+ static { this.ɵfac = function StripeDialog_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || StripeDialog)(i0.ɵɵdirectiveInject(BillingService), i0.ɵɵdirectiveInject(PaymentsService)); }; }
6108
6144
  static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: StripeDialog, selectors: [["anatoly-billing-stripe-dialog"]], inputs: { paidFor: "paidFor", title: "title", description: "description", image: "image" }, standalone: false, features: [i0.ɵɵInheritDefinitionFeature], decls: 1, vars: 1, consts: [[1, "send-message__kendo-dialog"], [3, "close", "width", "height", "themeColor"], [1, "kendo-dialog-content"], ["id", "stripeCheckout"]], template: function StripeDialog_Template(rf, ctx) { if (rf & 1) {
6109
6145
  i0.ɵɵtemplate(0, StripeDialog_Conditional_0_Template, 6, 3, "div", 0);
6110
6146
  } if (rf & 2) {
6111
6147
  i0.ɵɵconditional(ctx.visible ? 0 : -1);
6112
- } }, dependencies: [i2$2.DialogComponent, i2$2.DialogTitleBarComponent], encapsulation: 2 }); }
6148
+ } }, dependencies: [i4$1.DialogComponent, i4$1.DialogTitleBarComponent], encapsulation: 2 }); }
6113
6149
  }
6114
6150
  (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(StripeDialog, [{
6115
6151
  type: Component,
6116
6152
  args: [{ selector: 'anatoly-billing-stripe-dialog', standalone: false, template: "@if (visible) {\r\n <div class='send-message__kendo-dialog'>\r\n <kendo-dialog [width]='1080' [height]='800' [themeColor]='themeColor' (close)='onClose()'>\r\n <kendo-dialog-titlebar>Pay with Stripe</kendo-dialog-titlebar> \r\n <div class='kendo-dialog-content'>\r\n <div id=\"stripeCheckout\"></div>\r\n </div>\r\n </kendo-dialog>\r\n </div>\r\n}\r\n" }]
6117
- }], () => [{ type: PaymentsService }], { paidFor: [{
6153
+ }], () => [{ type: BillingService }, { type: PaymentsService }], { paidFor: [{
6118
6154
  type: Input
6119
6155
  }], title: [{
6120
6156
  type: Input
@@ -6123,7 +6159,7 @@ class StripeDialog extends DialogBase {
6123
6159
  }], image: [{
6124
6160
  type: Input
6125
6161
  }] }); })();
6126
- (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(StripeDialog, { className: "StripeDialog", filePath: "lib/billing/components/pm/stripe/stripe.component.ts", lineNumber: 34 }); })();
6162
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(StripeDialog, { className: "StripeDialog", filePath: "lib/billing/components/pm/stripe/stripe.component.ts", lineNumber: 35 }); })();
6127
6163
 
6128
6164
  /*
6129
6165
  <file>
@@ -7138,7 +7174,7 @@ class CountryDropdownlist extends EditComponentBase {
7138
7174
  i0.ɵɵproperty("ngIf", ctx.isNgModelBased);
7139
7175
  i0.ɵɵadvance();
7140
7176
  i0.ɵɵproperty("ngIf", !ctx.isNgModelBased);
7141
- } }, dependencies: [i1$1.NgForOf, i1$1.NgIf, i2$1.NgSelectOption, i2$1.ɵNgSelectMultipleOption, i2$1.SelectControlValueAccessor, i2$1.NgControlStatus, i2$1.NgControlStatusGroup, i2$1.FormGroupDirective, i2$1.FormControlName, i4$1.LabelComponent, NativeElementDirective], encapsulation: 2 }); }
7177
+ } }, dependencies: [i1$1.NgForOf, i1$1.NgIf, i2$1.NgSelectOption, i2$1.ɵNgSelectMultipleOption, i2$1.SelectControlValueAccessor, i2$1.NgControlStatus, i2$1.NgControlStatusGroup, i2$1.FormGroupDirective, i2$1.FormControlName, i4$2.LabelComponent, NativeElementDirective], encapsulation: 2 }); }
7142
7178
  }
7143
7179
  (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(CountryDropdownlist, [{
7144
7180
  type: Component,
@@ -7386,7 +7422,7 @@ class ModerationStatusDropdownlist extends EnumEditComponentBase {
7386
7422
  i0.ɵɵproperty("ngIf", ctx.isNgModelBased);
7387
7423
  i0.ɵɵadvance();
7388
7424
  i0.ɵɵproperty("ngIf", !ctx.isNgModelBased);
7389
- } }, dependencies: [i1$1.NgIf, i2$1.NgControlStatus, i2$1.NgControlStatusGroup, i2$1.FormGroupDirective, i2$1.FormControlName, i2$1.NgModel, i3.DropDownListComponent, i4$1.LabelComponent, NativeElementDirective, ItemValidationSummaryComponent], encapsulation: 2 }); }
7425
+ } }, dependencies: [i1$1.NgIf, i2$1.NgControlStatus, i2$1.NgControlStatusGroup, i2$1.FormGroupDirective, i2$1.FormControlName, i2$1.NgModel, i3.DropDownListComponent, i4$2.LabelComponent, NativeElementDirective, ItemValidationSummaryComponent], encapsulation: 2 }); }
7390
7426
  }
7391
7427
  (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ModerationStatusDropdownlist, [{
7392
7428
  type: Component,
@@ -7465,7 +7501,7 @@ class PublishStatusDropdownlist extends EnumEditComponentBase {
7465
7501
  i0.ɵɵproperty("ngIf", ctx.isNgModelBased);
7466
7502
  i0.ɵɵadvance();
7467
7503
  i0.ɵɵproperty("ngIf", !ctx.isNgModelBased);
7468
- } }, dependencies: [i1$1.NgIf, i2$1.NgControlStatus, i2$1.NgControlStatusGroup, i2$1.FormGroupDirective, i2$1.FormControlName, i2$1.NgModel, i3.DropDownListComponent, i4$1.LabelComponent, NativeElementDirective, ItemValidationSummaryComponent], encapsulation: 2 }); }
7504
+ } }, dependencies: [i1$1.NgIf, i2$1.NgControlStatus, i2$1.NgControlStatusGroup, i2$1.FormGroupDirective, i2$1.FormControlName, i2$1.NgModel, i3.DropDownListComponent, i4$2.LabelComponent, NativeElementDirective, ItemValidationSummaryComponent], encapsulation: 2 }); }
7469
7505
  }
7470
7506
  (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(PublishStatusDropdownlist, [{
7471
7507
  type: Component,
@@ -7850,7 +7886,7 @@ class HtmlEditorComponent extends HtmlEditorComponentBase {
7850
7886
  i0.ɵɵproperty("ngIf", ctx.isNgModelBased);
7851
7887
  i0.ɵɵadvance();
7852
7888
  i0.ɵɵproperty("ngIf", !ctx.isNgModelBased);
7853
- } }, dependencies: [i1$1.NgIf, i2$1.DefaultValueAccessor, i2$1.NgControlStatus, i2$1.NgControlStatusGroup, i2$1.FormGroupDirective, i2$1.FormControlName, i3$1.FroalaEditorDirective, i4$1.LabelComponent, NativeElementDirective, ItemValidationSummaryComponent], encapsulation: 2 }); }
7889
+ } }, dependencies: [i1$1.NgIf, i2$1.DefaultValueAccessor, i2$1.NgControlStatus, i2$1.NgControlStatusGroup, i2$1.FormGroupDirective, i2$1.FormControlName, i3$1.FroalaEditorDirective, i4$2.LabelComponent, NativeElementDirective, ItemValidationSummaryComponent], encapsulation: 2 }); }
7854
7890
  }
7855
7891
  (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(HtmlEditorComponent, [{
7856
7892
  type: Component,
@@ -8921,7 +8957,7 @@ class UrlSlugComponent extends EditComponentBase {
8921
8957
  i0.ɵɵproperty("formControlName", ctx.controlName);
8922
8958
  i0.ɵɵadvance();
8923
8959
  i0.ɵɵproperty("ngIf", ctx.isGoButtonVisible);
8924
- } }, dependencies: [i1$1.NgClass, i1$1.NgIf, i2$1.DefaultValueAccessor, i2$1.NgControlStatus, i2$1.NgControlStatusGroup, i2$1.FormGroupDirective, i2$1.FormControlName, i4$1.LabelDirective, AReplacerDirective, NativeElementDirective, ItemValidationSummaryComponent], encapsulation: 2 }); }
8960
+ } }, dependencies: [i1$1.NgClass, i1$1.NgIf, i2$1.DefaultValueAccessor, i2$1.NgControlStatus, i2$1.NgControlStatusGroup, i2$1.FormGroupDirective, i2$1.FormControlName, i4$2.LabelDirective, AReplacerDirective, NativeElementDirective, ItemValidationSummaryComponent], encapsulation: 2 }); }
8925
8961
  }
8926
8962
  (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(UrlSlugComponent, [{
8927
8963
  type: Component,
@@ -9407,7 +9443,7 @@ class ContactUsDialog extends DialogBase {
9407
9443
  i0.ɵɵtemplate(0, ContactUsDialog_kendo_dialog_0_Template, 10, 2, "kendo-dialog", 1);
9408
9444
  } if (rf & 2) {
9409
9445
  i0.ɵɵproperty("ngIf", ctx.isOpen);
9410
- } }, dependencies: [i1$1.NgIf, i2$2.DialogComponent, i2$2.DialogActionsComponent, ContactUsForm], encapsulation: 2 }); }
9446
+ } }, dependencies: [i1$1.NgIf, i4$1.DialogComponent, i4$1.DialogActionsComponent, ContactUsForm], encapsulation: 2 }); }
9411
9447
  }
9412
9448
  (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ContactUsDialog, [{
9413
9449
  type: Component,
@@ -10136,8 +10172,8 @@ class AnatolyDataModule {
10136
10172
  //Billing
10137
10173
  CurrenciesApiService,
10138
10174
  CurrenciesStorageService,
10139
- DiscountCodesApiService,
10140
10175
  PaymentsApiService,
10176
+ PromoCodesApiService,
10141
10177
  SubscriptionsApiService,
10142
10178
  TransactionsApiService,
10143
10179
  //App
@@ -10155,8 +10191,8 @@ class AnatolyDataModule {
10155
10191
  //Billing
10156
10192
  CurrenciesApiService,
10157
10193
  CurrenciesStorageService,
10158
- DiscountCodesApiService,
10159
10194
  PaymentsApiService,
10195
+ PromoCodesApiService,
10160
10196
  SubscriptionsApiService,
10161
10197
  TransactionsApiService,
10162
10198
  //App
@@ -11097,5 +11133,5 @@ class AnatolyModule {
11097
11133
  * Generated bundle index. Do not edit.
11098
11134
  */
11099
11135
 
11100
- export { AReplacerDirective, AddressComponent, AdminGuard, Alerts, AnatolyBillingModule, AnatolyCoreModule, AnatolyDataModule, AnatolyHttpInterceptor, AnatolyIAMModule, AnatolyIAMPagesModule, AnatolyModule, AnatolyUIModule, ApiServiceBase, ApiUrl, AppContextService, AppCoreSettings, AppName, AppSettings, AppVersion, AppsGoServiceBase, AuthService, AuthenticationGuard, BillingService, BillingUtils, BraintreeDialog, BrowserService, BuyAccessButtonComponent, CardBodyComponent, CardComponent, CardFooterComponent, CardHeaderComponent, CheckIconComponent, ClientApps, CompanyComponent, ComponentBase, ContactUsDialog, ContactUsForm, ControlPanelComponent, Convert, Copy2ClipboardComponent, CoreApiService, CountryDropdownlist, CurrenciesApiService, CurrenciesStorageService, DOM, DataPagerComponent, DataViewType, DateConvert, DefaultEditorOptions, DialogBase, DigitalMarketingService, DiscountCodeStatus, DiscountCodeType, DiscountCodesApiService, EditComponentBase, EditPageBase, EmailsApiService, EnumEditComponentBase, FeatureWillBeReadyComponent, FileSizePipe, FormValidationSummaryComponent, GABillingEvents, GAEvents, GlobalErrorHandler, GoServiceBase, GoogleAnalyticsService, GridEditServiceBase, GridReadServiceBase, Guid, HoveringDirective, HtmlEditorComponent, HtmlEditorComponentBase, IdleService, ImageReplacerDirective, InjectorInstance, IsDevMode, IsProdMode, ItemValidationSummaryComponent, L10nUtils, ListBase, LoadingComponent, LoadingService, LocalStorageService, LocalizationModule, LocalizationService, LocalizationSettingsModule, LocalizePipe, LoggingService, MSALUtils, ModerationStatus, ModerationStatusDropdownlist, NativeElementDirective, NoMobileSupportComponent, NodataComponent, NotificationService, OrderSummaryComponent, PageBase, PageSpinnerComponent, PagedPageBase, PayPalComponent, PayPalScriptService, PaymentMethod, PaymentMethodsComponent, PaymentOptionsComponent, PaymentStage, PaymentType, PaymentsApiService, PaymentsService, PaypalButtonComponent, PaypalSubscribeButtonComponent, PublishStatus, PublishStatusDropdownlist, QSUtils, ReplaceTextPipe, SafeHtmlPipe, ScriptService, SessionStorageService, SignInButtonComponent, SignOutButtonComponent, SignUpButtonComponent, StarterGuard, StarterService, Stopwatch, StripeDialog, Subs, SubscribePlanButtonComponent, SubscriptionProvider, SubscriptionsApiService, TimezoneDropdownlist, TransactionsApiService, UrlSlugComponent, Utils, ValidationSummaryComponent, XmlFormatter, YouAgreeToOurTermsComponent, dateFormats, dateTimeFormats, formatUrl, getAppSettingsById, getAppSettingsByName, getCurrentApp, getLocalizationInjector, is, throwIfAlreadyLoaded, timeFormats, translateLoaderFactory };
11136
+ export { AReplacerDirective, AddressComponent, AdminGuard, Alerts, AnatolyBillingModule, AnatolyCoreModule, AnatolyDataModule, AnatolyHttpInterceptor, AnatolyIAMModule, AnatolyIAMPagesModule, AnatolyModule, AnatolyUIModule, ApiServiceBase, ApiUrl, AppContextService, AppCoreSettings, AppName, AppSettings, AppVersion, AppsGoServiceBase, AuthService, AuthenticationGuard, BillingService, BillingUtils, BraintreeDialog, BrowserService, BuyAccessButtonComponent, CardBodyComponent, CardComponent, CardFooterComponent, CardHeaderComponent, CheckIconComponent, ClientApps, CompanyComponent, ComponentBase, ContactUsDialog, ContactUsForm, ControlPanelComponent, Convert, Copy2ClipboardComponent, CoreApiService, CountryDropdownlist, CurrenciesApiService, CurrenciesStorageService, DOM, DataPagerComponent, DataViewType, DateConvert, DefaultEditorOptions, DialogBase, DigitalMarketingService, DiscountCodeStatus, DiscountCodeType, EditComponentBase, EditPageBase, EmailsApiService, EnumEditComponentBase, FeatureWillBeReadyComponent, FileSizePipe, FormValidationSummaryComponent, GABillingEvents, GAEvents, GlobalErrorHandler, GoServiceBase, GoogleAnalyticsService, GridEditServiceBase, GridReadServiceBase, Guid, HoveringDirective, HtmlEditorComponent, HtmlEditorComponentBase, IdleService, ImageReplacerDirective, InjectorInstance, IsDevMode, IsProdMode, ItemValidationSummaryComponent, L10nUtils, ListBase, LoadingComponent, LoadingService, LocalStorageService, LocalizationModule, LocalizationService, LocalizationSettingsModule, LocalizePipe, LoggingService, MSALUtils, ModerationStatus, ModerationStatusDropdownlist, NativeElementDirective, NoMobileSupportComponent, NodataComponent, NotificationService, OrderSummaryComponent, PageBase, PageSpinnerComponent, PagedPageBase, PayPalComponent, PayPalScriptService, PaymentMethod, PaymentMethodsComponent, PaymentOptionsComponent, PaymentStage, PaymentType, PaymentsApiService, PaymentsService, PaypalButtonComponent, PaypalSubscribeButtonComponent, PromoCodesApiService, PublishStatus, PublishStatusDropdownlist, QSUtils, ReplaceTextPipe, SafeHtmlPipe, ScriptService, SessionStorageService, SignInButtonComponent, SignOutButtonComponent, SignUpButtonComponent, StarterGuard, StarterService, Stopwatch, StripeDialog, Subs, SubscribePlanButtonComponent, SubscriptionProvider, SubscriptionsApiService, TimezoneDropdownlist, TransactionsApiService, UrlSlugComponent, Utils, ValidationSummaryComponent, XmlFormatter, YouAgreeToOurTermsComponent, dateFormats, dateTimeFormats, formatUrl, getAppSettingsById, getAppSettingsByName, getCurrentApp, getLocalizationInjector, is, throwIfAlreadyLoaded, timeFormats, translateLoaderFactory };
11101
11137
  //# sourceMappingURL=osovitny-anatoly.mjs.map