@osovitny/anatoly 3.19.32 → 3.19.34

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,260 @@ 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(subscriptionProvider, newSubscriptionId, planId, addons, subtotal, promoCode, total, currency, success, error) {
5084
+ this.post('addSubscription', {
5085
+ subscriptionProvider, newSubscriptionId,
5086
+ planId, addons, subtotal, promoCode, total, currency
5087
+ }).subscribe({
5088
+ next: (data) => {
5089
+ if (success)
5090
+ success(data);
5091
+ },
5092
+ error: (e) => {
5093
+ if (error)
5094
+ error(e);
5095
+ }
5096
+ });
5097
+ }
5098
+ addFreeSubscription(planId, addons, subtotal, promoCode, total, currency, success, error) {
5099
+ this.post('addFreeSubscription', {
5100
+ planId, addons, subtotal, promoCode, total, currency
5101
+ }).subscribe({
5102
+ next: (data) => {
5103
+ if (success)
5104
+ success(data);
5105
+ },
5106
+ error: (e) => {
5107
+ if (error)
5108
+ error(e);
5109
+ }
5110
+ });
5111
+ }
5112
+ cancelSubscription(subscriptionProvider, subscriptionId, success, error) {
5113
+ this.post('cancelSubscription', { subscriptionProvider, subscriptionId }).subscribe({
5114
+ next: (data) => {
5115
+ if (success)
5116
+ success(data);
5117
+ },
5118
+ error: (e) => {
5119
+ if (error)
5120
+ error(e);
5121
+ }
5122
+ });
5123
+ }
5124
+ static { this.ɵfac = function SubscriptionsApiService_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || SubscriptionsApiService)(i0.ɵɵinject(i1.HttpClient)); }; }
5125
+ static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: SubscriptionsApiService, factory: SubscriptionsApiService.ɵfac }); }
5126
+ }
5127
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(SubscriptionsApiService, [{
5128
+ type: Injectable
5129
+ }], () => [{ type: i1.HttpClient }], null); })();
5130
+
5131
+ /*
5132
+ <file>
5133
+ Project:
5134
+ @osovitny/anatoly
5135
+
5136
+ Authors:
5137
+ Vadim Osovitny vadim.osovitny@osovitny.com
5138
+
5139
+ Created:
5140
+ 19 Jul 2025
5141
+
5142
+ Copyright (c) 2016-2025 Osovitny Inc. All rights reserved.
5143
+ </file>
5144
+ */
5145
+ //Node
5146
+ class BillingService {
5147
+ constructor(zone, appContext, apiPayments, apiSubscriptions, ns) {
5148
+ this.zone = zone;
5149
+ this.appContext = appContext;
5150
+ this.apiPayments = apiPayments;
5151
+ this.apiSubscriptions = apiSubscriptions;
5152
+ this.ns = ns;
5153
+ //paymentAdded
5154
+ this._paymentAdded = new Subject();
5155
+ this.paymentAdded$ = this._paymentAdded.asObservable();
5156
+ //paymentProgress
5157
+ this._paymentProgress = new Subject();
5158
+ this.paymentProgress$ = this._paymentProgress.asObservable();
5159
+ //subscriptionAdded
5160
+ this._subscriptionAdded = new Subject();
5161
+ this.subscriptionAdded$ = this._subscriptionAdded.asObservable();
5162
+ }
5163
+ //fires
5164
+ firePaymentAdded(isPaymentValid, paymentId) {
5165
+ this._paymentAdded.next({ isPaymentValid, paymentId });
5166
+ }
5167
+ firePaymentProgress(paymentStage, paymentInProgress, isPaymentFailed) {
5168
+ this._paymentAdded.next({ paymentStage, paymentInProgress, isPaymentFailed });
5169
+ }
5170
+ fireSubscriptionAdded(paymentInProgress, paymentFailed) {
5171
+ this._subscriptionAdded.next({ paymentInProgress, paymentFailed });
5172
+ }
5173
+ createStripeSession(amount, currency, title, description, image) {
5174
+ return this.apiPayments.createStripeSession(amount, currency, title, description, image);
5175
+ }
5176
+ createBraintreeToken() {
5177
+ return this.apiPayments.createBraintreeToken();
5178
+ }
5179
+ addPayment(paymentMethod, paidFor, subtotal, promoCode, total, currency, pmId, pmStatus, pmDetails) {
5180
+ this.zone.run(() => {
5181
+ let paidForAsString = JSON.stringify(paidFor);
5182
+ if (total == 0) {
5183
+ paymentMethod = PaymentMethod.None;
5184
+ }
5185
+ this.apiPayments.addPayment(paymentMethod, paidForAsString,
5186
+ //Amount
5187
+ subtotal, promoCode, total, currency,
5188
+ //Payment method details (PayPal/Stripe/Braintree)
5189
+ pmId, pmStatus, pmDetails, (data) => {
5190
+ if (!data || !data?.isPaymentValid) {
5191
+ this.paymentFailed(PaymentStage.External);
5192
+ return;
5193
+ }
5194
+ this.paymentSuccessful(PaymentStage.External);
5195
+ this.firePaymentAdded(data.isPaymentValid, data.paymentId);
5196
+ }, () => {
5197
+ this.paymentFailed(PaymentStage.External);
5198
+ });
5199
+ });
5200
+ }
5201
+ paymentSuccessful(stage) {
5202
+ this.setPaymentProgress(stage, false, false);
5203
+ }
5204
+ paymentFailed(stage) {
5205
+ this.setPaymentProgress(stage, false, true);
5206
+ }
5207
+ setPaymentProgress(stage, paymentInProgress, isPaymentFailed) {
5208
+ this.firePaymentProgress(stage, paymentInProgress, isPaymentFailed);
5209
+ if (!paymentInProgress && isPaymentFailed) {
5210
+ this.ns.error("Payment Failed");
5211
+ }
5212
+ }
5213
+ addSubscription(sp, newSubscriptionId, planId, addons, subtotal, promoCode, total, currency) {
5214
+ this.zone.run(() => {
5215
+ this.apiSubscriptions.addSubscription(sp, newSubscriptionId, planId, addons, subtotal, promoCode, total, currency, () => {
5216
+ this.fireSubscriptionAdded(false, false);
5217
+ this.appContext.updateCurrent();
5218
+ }, () => {
5219
+ this.fireSubscriptionAdded(false, true);
5220
+ });
5221
+ });
5222
+ }
5223
+ addFreeSubscription(planId, addons, subtotal, promoCode, total, currency) {
5224
+ this.zone.run(() => {
5225
+ this.apiSubscriptions.addFreeSubscription(planId, addons, subtotal, promoCode, total, currency, () => {
5226
+ this.fireSubscriptionAdded(false, false);
5227
+ this.appContext.updateCurrent();
5228
+ }, () => {
5229
+ this.fireSubscriptionAdded(false, true);
5230
+ });
5231
+ });
5232
+ }
5233
+ 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)); }; }
5234
+ static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: BillingService, factory: BillingService.ɵfac }); }
5235
+ }
5236
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(BillingService, [{
5237
+ type: Injectable
5238
+ }], () => [{ type: i0.NgZone }, { type: AppContextService }, { type: PaymentsApiService }, { type: SubscriptionsApiService }, { type: NotificationService }], null); })();
5239
+
5101
5240
  /*
5102
5241
  <file>
5103
5242
  Project:
@@ -5140,8 +5279,9 @@ function BraintreeDialog_Conditional_0_Template(rf, ctx) { if (rf & 1) {
5140
5279
  i0.ɵɵproperty("width", 480)("height", 560)("themeColor", ctx_r1.themeColor);
5141
5280
  } }
5142
5281
  class BraintreeDialog extends DialogBase {
5143
- constructor(ps, ns) {
5282
+ constructor(bs, ps, ns) {
5144
5283
  super();
5284
+ this.bs = bs;
5145
5285
  this.ps = ps;
5146
5286
  this.ns = ns;
5147
5287
  }
@@ -5158,7 +5298,7 @@ class BraintreeDialog extends DialogBase {
5158
5298
  const that = this;
5159
5299
  // let totalPrice = this.bs.getTotal().toString();
5160
5300
  // let currency = this.bs.currency;
5161
- this.ps.createBraintreeToken().subscribe((response) => {
5301
+ this.bs.createBraintreeToken().subscribe((response) => {
5162
5302
  if (response?.token) {
5163
5303
  dropin.create({
5164
5304
  authorization: response?.token,
@@ -5195,7 +5335,13 @@ class BraintreeDialog extends DialogBase {
5195
5335
  });
5196
5336
  }
5197
5337
  submitPayment(payload) {
5198
- this.ps.pay(this.paidFor, payload.nonce, 'COMPLETED', this.deviceData);
5338
+ //ps
5339
+ let paymentMethod = this.ps.selectedPaymentMethod;
5340
+ let subtotal = this.ps.subtotal;
5341
+ let promoCode = this.ps.promoCode;
5342
+ let total = this.ps.getTotal();
5343
+ let currency = this.ps.currency;
5344
+ this.bs.addPayment(paymentMethod, this.paidFor, subtotal, promoCode, total, currency, payload.nonce, 'COMPLETED', this.deviceData);
5199
5345
  }
5200
5346
  closeDialog() {
5201
5347
  super.close();
@@ -5224,17 +5370,17 @@ class BraintreeDialog extends DialogBase {
5224
5370
  get visible() {
5225
5371
  return this.isOpen && this.ps.getTotal() > 0;
5226
5372
  }
5227
- static { this.ɵfac = function BraintreeDialog_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || BraintreeDialog)(i0.ɵɵdirectiveInject(PaymentsService), i0.ɵɵdirectiveInject(NotificationService)); }; }
5373
+ static { this.ɵfac = function BraintreeDialog_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || BraintreeDialog)(i0.ɵɵdirectiveInject(BillingService), i0.ɵɵdirectiveInject(PaymentsService), i0.ɵɵdirectiveInject(NotificationService)); }; }
5228
5374
  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
5375
  i0.ɵɵtemplate(0, BraintreeDialog_Conditional_0_Template, 11, 3, "div", 0);
5230
5376
  } if (rf & 2) {
5231
5377
  i0.ɵɵconditional(ctx.visible ? 0 : -1);
5232
- } }, dependencies: [i2$2.DialogComponent, i2$2.DialogTitleBarComponent, i2$2.DialogActionsComponent], encapsulation: 2 }); }
5378
+ } }, dependencies: [i4$1.DialogComponent, i4$1.DialogTitleBarComponent, i4$1.DialogActionsComponent], encapsulation: 2 }); }
5233
5379
  }
5234
5380
  (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(BraintreeDialog, [{
5235
5381
  type: Component,
5236
5382
  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: [{
5383
+ }], () => [{ type: BillingService }, { type: PaymentsService }, { type: NotificationService }], { paidFor: [{
5238
5384
  type: Input
5239
5385
  }], title: [{
5240
5386
  type: Input
@@ -5243,7 +5389,7 @@ class BraintreeDialog extends DialogBase {
5243
5389
  }], image: [{
5244
5390
  type: Input
5245
5391
  }] }); })();
5246
- (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(BraintreeDialog, { className: "BraintreeDialog", filePath: "lib/billing/components/pm/braintree/braintree.component.ts", lineNumber: 33 }); })();
5392
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(BraintreeDialog, { className: "BraintreeDialog", filePath: "lib/billing/components/pm/braintree/braintree.component.ts", lineNumber: 34 }); })();
5247
5393
 
5248
5394
  /*
5249
5395
  <file>
@@ -5680,8 +5826,9 @@ function PaypalButtonComponent_Conditional_0_Template(rf, ctx) { if (rf & 1) {
5680
5826
  i0.ɵɵproperty("config", ctx_r0.payPalConfig);
5681
5827
  } }
5682
5828
  class PaypalButtonComponent extends ComponentBase {
5683
- constructor(ps) {
5829
+ constructor(bs, ps) {
5684
5830
  super();
5831
+ this.bs = bs;
5685
5832
  this.ps = ps;
5686
5833
  this.paidForTitle = 'Payment for Prodiuct';
5687
5834
  }
@@ -5693,7 +5840,7 @@ class PaypalButtonComponent extends ComponentBase {
5693
5840
  }
5694
5841
  setValues() {
5695
5842
  this.initPayPal();
5696
- this.ps.discountCodeApplied$.subscribe((data) => {
5843
+ this.ps.promoCodeApplied$.subscribe((data) => {
5697
5844
  this.initPayPal();
5698
5845
  });
5699
5846
  }
@@ -5753,34 +5900,38 @@ class PaypalButtonComponent extends ComponentBase {
5753
5900
  onApprove: (data, actions) => {
5754
5901
  return actions.order.capture().then(function (orderData) {
5755
5902
  try {
5903
+ //
5756
5904
  let payment = orderData.purchase_units[0].payments.captures[0];
5757
5905
  let paymentId = payment.id;
5758
5906
  let status = payment.status;
5759
5907
  let amount = payment.amount.value;
5760
5908
  let currencyCode = payment.amount.currency_code;
5761
5909
  let details = JSON.stringify(orderData);
5762
- that.ps.pay(that.paidFor, paymentId, status, details);
5910
+ //ps
5911
+ let paymentMethod = this.ps.selectedPaymentMethod;
5912
+ let subtotal = this.ps.subtotal;
5913
+ let promoCode = this.ps.promoCode;
5914
+ let total = this.ps.getTotal();
5915
+ let currency = this.ps.currency;
5916
+ that.bs.addPayment(paymentMethod, that.paidFor, subtotal, promoCode, total, currency, paymentId, status, details);
5763
5917
  }
5764
5918
  catch {
5765
- that.ps.paymentFailed(PaymentStage.External);
5919
+ that.bs.paymentFailed(PaymentStage.External);
5766
5920
  }
5767
5921
  });
5768
5922
  },
5769
5923
  onCancel: (data, actions) => {
5770
- that.ps.paymentInProgress = false;
5771
5924
  },
5772
5925
  onError: err => {
5773
- that.ps.paymentInProgress = false;
5774
5926
  },
5775
5927
  onClick: (data, actions) => {
5776
- that.ps.paymentInProgress = true;
5777
5928
  }
5778
5929
  };
5779
5930
  }
5780
5931
  get visible() {
5781
5932
  return this.ps.selectedPaymentMethod == PaymentMethod.PayPal && this.ps.getTotal() > 0;
5782
5933
  }
5783
- static { this.ɵfac = function PaypalButtonComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || PaypalButtonComponent)(i0.ɵɵdirectiveInject(PaymentsService)); }; }
5934
+ static { this.ɵfac = function PaypalButtonComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || PaypalButtonComponent)(i0.ɵɵdirectiveInject(BillingService), i0.ɵɵdirectiveInject(PaymentsService)); }; }
5784
5935
  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
5936
  i0.ɵɵtemplate(0, PaypalButtonComponent_Conditional_0_Template, 1, 1, "anatoly-billing-paypal-container", 0);
5786
5937
  } if (rf & 2) {
@@ -5790,125 +5941,12 @@ class PaypalButtonComponent extends ComponentBase {
5790
5941
  (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(PaypalButtonComponent, [{
5791
5942
  type: Component,
5792
5943
  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: [{
5944
+ }], () => [{ type: BillingService }, { type: PaymentsService }], { paidForTitle: [{
5794
5945
  type: Input
5795
5946
  }], paidFor: [{
5796
5947
  type: Input
5797
5948
  }] }); })();
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); })();
5949
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(PaypalButtonComponent, { className: "PaypalButtonComponent", filePath: "lib/billing/components/pm/paypal/paypal-button.component.ts", lineNumber: 44 }); })();
5912
5950
 
5913
5951
  /*
5914
5952
  <file>
@@ -5936,6 +5974,7 @@ class PaypalSubscribeButtonComponent extends ComponentBase {
5936
5974
  constructor(bs) {
5937
5975
  super();
5938
5976
  this.bs = bs;
5977
+ this.currency = 'USD';
5939
5978
  }
5940
5979
  ngOnInit() {
5941
5980
  this.setDefaults();
@@ -5982,25 +6021,25 @@ class PaypalSubscribeButtonComponent extends ComponentBase {
5982
6021
  onApprove: (data, actions) => {
5983
6022
  try {
5984
6023
  let subscriptionId = data.subscriptionID;
5985
- that.bs.addSubscription(SubscriptionProvider.PayPal, subscriptionId, this.planId, this.addons, this.price, this.totalPrice);
6024
+ that.bs.addSubscription(SubscriptionProvider.PayPal, subscriptionId, this.planId, this.addons, this.subtotal, this.promoCode, this.total, this.currency);
5986
6025
  }
5987
6026
  catch {
5988
- that.bs.fireSubscriptionChange(false, true);
6027
+ that.bs.fireSubscriptionAdded(false, true);
5989
6028
  }
5990
6029
  },
5991
6030
  onCancel: (data, actions) => {
5992
- that.bs.fireSubscriptionChange(false, true);
6031
+ that.bs.fireSubscriptionAdded(false, true);
5993
6032
  },
5994
6033
  onError: err => {
5995
- that.bs.fireSubscriptionChange(false, true);
6034
+ that.bs.fireSubscriptionAdded(false, true);
5996
6035
  },
5997
6036
  onClick: (data, actions) => {
5998
- that.bs.fireSubscriptionChange(true, false);
6037
+ that.bs.fireSubscriptionAdded(true, false);
5999
6038
  }
6000
6039
  };
6001
6040
  }
6002
6041
  static { this.ɵfac = function PaypalSubscribeButtonComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || PaypalSubscribeButtonComponent)(i0.ɵɵdirectiveInject(BillingService)); }; }
6003
- 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) {
6042
+ 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) {
6004
6043
  i0.ɵɵelement(0, "anatoly-billing-paypal-container", 0);
6005
6044
  } if (rf & 2) {
6006
6045
  i0.ɵɵproperty("config", ctx.payPalConfig);
@@ -6017,9 +6056,13 @@ class PaypalSubscribeButtonComponent extends ComponentBase {
6017
6056
  type: Input
6018
6057
  }], addons: [{
6019
6058
  type: Input
6020
- }], price: [{
6059
+ }], subtotal: [{
6021
6060
  type: Input
6022
- }], totalPrice: [{
6061
+ }], promoCode: [{
6062
+ type: Input
6063
+ }], total: [{
6064
+ type: Input
6065
+ }], currency: [{
6023
6066
  type: Input
6024
6067
  }] }); })();
6025
6068
  (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(PaypalSubscribeButtonComponent, { className: "PaypalSubscribeButtonComponent", filePath: "lib/billing/components/pm/paypal/paypal-subscribe-button.component.ts", lineNumber: 31 }); })();
@@ -6058,8 +6101,9 @@ function StripeDialog_Conditional_0_Template(rf, ctx) { if (rf & 1) {
6058
6101
  i0.ɵɵproperty("width", 1080)("height", 800)("themeColor", ctx_r1.themeColor);
6059
6102
  } }
6060
6103
  class StripeDialog extends DialogBase {
6061
- constructor(ps) {
6104
+ constructor(bs, ps) {
6062
6105
  super();
6106
+ this.bs = bs;
6063
6107
  this.ps = ps;
6064
6108
  }
6065
6109
  ngOnInit() {
@@ -6073,11 +6117,13 @@ class StripeDialog extends DialogBase {
6073
6117
  }
6074
6118
  async initializeEmbedForm() {
6075
6119
  let stripePk = AppCoreSettings.external.pm.stripe.publishableKey;
6076
- this.stripe = await loadStripe(stripePk);
6077
6120
  const that = this;
6121
+ this.stripe = await loadStripe(stripePk);
6078
6122
  this.stripeCheckout = await this.stripe.initEmbeddedCheckout({
6079
6123
  fetchClientSecret: async () => {
6080
- const response = await firstValueFrom(that.ps.createStripeSession(this.title, this.description, this.image));
6124
+ const amount = this.ps.getTotal();
6125
+ const currency = this.ps.currency;
6126
+ const response = await firstValueFrom(that.bs.createStripeSession(amount, currency, this.title, this.description, this.image));
6081
6127
  if (response) {
6082
6128
  that.sessionId = response.sessionId;
6083
6129
  return response?.sessionSecret ? response.sessionSecret : '';
@@ -6085,7 +6131,13 @@ class StripeDialog extends DialogBase {
6085
6131
  return '';
6086
6132
  },
6087
6133
  onComplete: () => {
6088
- that.ps.pay(this.paidFor, this.sessionId, 'COMPLETED', '');
6134
+ //ps
6135
+ let paymentMethod = this.ps.selectedPaymentMethod;
6136
+ let subtotal = this.ps.subtotal;
6137
+ let promoCode = this.ps.promoCode;
6138
+ let total = this.ps.getTotal();
6139
+ let currency = this.ps.currency;
6140
+ this.bs.addPayment(paymentMethod, this.paidFor, subtotal, promoCode, total, currency, this.sessionId, 'COMPLETED', '');
6089
6141
  that.onClose();
6090
6142
  }
6091
6143
  });
@@ -6103,17 +6155,17 @@ class StripeDialog extends DialogBase {
6103
6155
  get visible() {
6104
6156
  return this.isOpen && this.ps.getTotal() > 0;
6105
6157
  }
6106
- static { this.ɵfac = function StripeDialog_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || StripeDialog)(i0.ɵɵdirectiveInject(PaymentsService)); }; }
6158
+ static { this.ɵfac = function StripeDialog_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || StripeDialog)(i0.ɵɵdirectiveInject(BillingService), i0.ɵɵdirectiveInject(PaymentsService)); }; }
6107
6159
  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) {
6108
6160
  i0.ɵɵtemplate(0, StripeDialog_Conditional_0_Template, 6, 3, "div", 0);
6109
6161
  } if (rf & 2) {
6110
6162
  i0.ɵɵconditional(ctx.visible ? 0 : -1);
6111
- } }, dependencies: [i2$2.DialogComponent, i2$2.DialogTitleBarComponent], encapsulation: 2 }); }
6163
+ } }, dependencies: [i4$1.DialogComponent, i4$1.DialogTitleBarComponent], encapsulation: 2 }); }
6112
6164
  }
6113
6165
  (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(StripeDialog, [{
6114
6166
  type: Component,
6115
6167
  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" }]
6116
- }], () => [{ type: PaymentsService }], { paidFor: [{
6168
+ }], () => [{ type: BillingService }, { type: PaymentsService }], { paidFor: [{
6117
6169
  type: Input
6118
6170
  }], title: [{
6119
6171
  type: Input
@@ -6122,7 +6174,7 @@ class StripeDialog extends DialogBase {
6122
6174
  }], image: [{
6123
6175
  type: Input
6124
6176
  }] }); })();
6125
- (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(StripeDialog, { className: "StripeDialog", filePath: "lib/billing/components/pm/stripe/stripe.component.ts", lineNumber: 34 }); })();
6177
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(StripeDialog, { className: "StripeDialog", filePath: "lib/billing/components/pm/stripe/stripe.component.ts", lineNumber: 35 }); })();
6126
6178
 
6127
6179
  /*
6128
6180
  <file>
@@ -7137,7 +7189,7 @@ class CountryDropdownlist extends EditComponentBase {
7137
7189
  i0.ɵɵproperty("ngIf", ctx.isNgModelBased);
7138
7190
  i0.ɵɵadvance();
7139
7191
  i0.ɵɵproperty("ngIf", !ctx.isNgModelBased);
7140
- } }, 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 }); }
7192
+ } }, 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 }); }
7141
7193
  }
7142
7194
  (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(CountryDropdownlist, [{
7143
7195
  type: Component,
@@ -7385,7 +7437,7 @@ class ModerationStatusDropdownlist extends EnumEditComponentBase {
7385
7437
  i0.ɵɵproperty("ngIf", ctx.isNgModelBased);
7386
7438
  i0.ɵɵadvance();
7387
7439
  i0.ɵɵproperty("ngIf", !ctx.isNgModelBased);
7388
- } }, 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 }); }
7440
+ } }, 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 }); }
7389
7441
  }
7390
7442
  (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ModerationStatusDropdownlist, [{
7391
7443
  type: Component,
@@ -7464,7 +7516,7 @@ class PublishStatusDropdownlist extends EnumEditComponentBase {
7464
7516
  i0.ɵɵproperty("ngIf", ctx.isNgModelBased);
7465
7517
  i0.ɵɵadvance();
7466
7518
  i0.ɵɵproperty("ngIf", !ctx.isNgModelBased);
7467
- } }, 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 }); }
7519
+ } }, 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 }); }
7468
7520
  }
7469
7521
  (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(PublishStatusDropdownlist, [{
7470
7522
  type: Component,
@@ -7849,7 +7901,7 @@ class HtmlEditorComponent extends HtmlEditorComponentBase {
7849
7901
  i0.ɵɵproperty("ngIf", ctx.isNgModelBased);
7850
7902
  i0.ɵɵadvance();
7851
7903
  i0.ɵɵproperty("ngIf", !ctx.isNgModelBased);
7852
- } }, 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 }); }
7904
+ } }, 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 }); }
7853
7905
  }
7854
7906
  (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(HtmlEditorComponent, [{
7855
7907
  type: Component,
@@ -8920,7 +8972,7 @@ class UrlSlugComponent extends EditComponentBase {
8920
8972
  i0.ɵɵproperty("formControlName", ctx.controlName);
8921
8973
  i0.ɵɵadvance();
8922
8974
  i0.ɵɵproperty("ngIf", ctx.isGoButtonVisible);
8923
- } }, 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 }); }
8975
+ } }, 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 }); }
8924
8976
  }
8925
8977
  (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(UrlSlugComponent, [{
8926
8978
  type: Component,
@@ -9406,7 +9458,7 @@ class ContactUsDialog extends DialogBase {
9406
9458
  i0.ɵɵtemplate(0, ContactUsDialog_kendo_dialog_0_Template, 10, 2, "kendo-dialog", 1);
9407
9459
  } if (rf & 2) {
9408
9460
  i0.ɵɵproperty("ngIf", ctx.isOpen);
9409
- } }, dependencies: [i1$1.NgIf, i2$2.DialogComponent, i2$2.DialogActionsComponent, ContactUsForm], encapsulation: 2 }); }
9461
+ } }, dependencies: [i1$1.NgIf, i4$1.DialogComponent, i4$1.DialogActionsComponent, ContactUsForm], encapsulation: 2 }); }
9410
9462
  }
9411
9463
  (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ContactUsDialog, [{
9412
9464
  type: Component,
@@ -10135,8 +10187,8 @@ class AnatolyDataModule {
10135
10187
  //Billing
10136
10188
  CurrenciesApiService,
10137
10189
  CurrenciesStorageService,
10138
- DiscountCodesApiService,
10139
10190
  PaymentsApiService,
10191
+ PromoCodesApiService,
10140
10192
  SubscriptionsApiService,
10141
10193
  TransactionsApiService,
10142
10194
  //App
@@ -10154,8 +10206,8 @@ class AnatolyDataModule {
10154
10206
  //Billing
10155
10207
  CurrenciesApiService,
10156
10208
  CurrenciesStorageService,
10157
- DiscountCodesApiService,
10158
10209
  PaymentsApiService,
10210
+ PromoCodesApiService,
10159
10211
  SubscriptionsApiService,
10160
10212
  TransactionsApiService,
10161
10213
  //App
@@ -11096,5 +11148,5 @@ class AnatolyModule {
11096
11148
  * Generated bundle index. Do not edit.
11097
11149
  */
11098
11150
 
11099
- 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 };
11151
+ 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 };
11100
11152
  //# sourceMappingURL=osovitny-anatoly.mjs.map