|
265 | 265 | @if (Model.Plan.Frequency == (int)PlanFrequency.Yearly) |
266 | 266 | { |
267 | 267 | <span> |
268 | | - @Model.Plan.Cost.ToString("C", Cultures.UnitedStates)<small>/@localizer["Year"]</small> |
| 268 | + @currencySymbol@Model.Plan.Cost.ToString("N2")<small>/@localizer["Year"]</small> |
269 | 269 | </span> |
270 | 270 | } |
271 | 271 | else |
272 | 272 | { |
273 | 273 | <span> |
274 | | - @Model.Plan.Cost.ToString("C", Cultures.UnitedStates)<small>/@localizer["month"]</small> |
| 274 | + @currencySymbol@Model.Plan.Cost.ToString("N2")<small>/@localizer["month"]</small> |
275 | 275 | </span> |
276 | 276 | } |
277 | 277 | </h3> |
|
527 | 527 |
|
528 | 528 | function stripeCheckout(id) { |
529 | 529 | const amount = slider == 1 ? val : $("#amount").val(); |
| 530 | + const minAmount = IS_EU ? 10 : 20; |
530 | 531 |
|
531 | | - if (amount && amount > 10) { |
532 | | - const packs = (amount / 10) - 1; // First 10 users are free. |
| 532 | + if (amount && amount >= minAmount && (!IS_EU ? amount > 10 : true)) { |
| 533 | + const packs = IS_EU ? (amount / 10) : (amount / 10) - 1; |
533 | 534 |
|
534 | 535 | $.ajax({ |
535 | 536 | url: resgrid.absoluteBaseUrl + '/User/Subscription/GetStripeSession?id=' + id + '&count=' + packs, |
536 | 537 | contentType: 'application/json', |
537 | 538 | type: 'GET' |
538 | 539 | }).done(function (data) { |
539 | | - if (data) { |
540 | | - if (data.SessionId) { |
541 | | - stripe.redirectToCheckout({ |
542 | | - sessionId: data.SessionId |
543 | | - }).then(function (result) { |
544 | | - // If `redirectToCheckout` fails due to a browser or network |
545 | | - // error, display the localized error message to your customer |
546 | | - // using `result.error.message`. |
547 | | -
|
548 | | - swal({ |
549 | | - title: "Purchase Error", |
550 | | - text: "Error redirecting to Stripe for checkout. Stripe error: " + result.error.message, |
551 | | - icon: "error", |
552 | | - buttons: true, |
553 | | - dangerMode: false |
554 | | - }); |
555 | | - }); |
556 | | - } |
| 540 | + if (data && data.SessionId) { |
| 541 | + stripe.redirectToCheckout({ |
| 542 | + sessionId: data.SessionId |
| 543 | + }).then(function (result) { |
| 544 | + if (result.error) { |
| 545 | + swal({ title: "Purchase Error", text: "Error redirecting to Stripe: " + result.error.message, icon: "error", buttons: true, dangerMode: false }); |
| 546 | + } |
| 547 | + }); |
| 548 | + } else { |
| 549 | + swal({ title: "Checkout Error", text: "Unable to create a checkout session. Please try again.", icon: "error", buttons: true, dangerMode: false }); |
557 | 550 | } |
| 551 | + }).fail(function () { |
| 552 | + swal({ title: "Connection Error", text: "Unable to reach the server. Please check your connection and try again.", icon: "error", buttons: true, dangerMode: false }); |
558 | 553 | }); |
559 | 554 | } else { |
560 | | - swal({ |
561 | | - title: "Cannot Purchase", |
562 | | - text: "Resgrid includes 10 entities for free for all departments. Please select a entity count greater then 10 to purchase.", |
563 | | - icon: "warning", |
564 | | - buttons: true, |
565 | | - dangerMode: false |
566 | | - }); |
| 555 | + swal({ title: "Cannot Purchase", text: "Please select more entities to purchase a plan.", icon: "warning", buttons: true, dangerMode: false }); |
567 | 556 | } |
568 | 557 | } |
569 | 558 |
|
|
589 | 578 |
|
590 | 579 | function paddleCheckout(id) { |
591 | 580 | const amount = slider == 1 ? val : $("#amount").val(); |
| 581 | + const minAmount = IS_EU ? 10 : 20; |
592 | 582 |
|
593 | | - if (amount && amount > 10) { |
594 | | - const packs = (amount / 10) - 1; |
| 583 | + if (amount && amount >= minAmount && (!IS_EU ? amount > 10 : true)) { |
| 584 | + const packs = IS_EU ? (amount / 10) : (amount / 10) - 1; |
595 | 585 |
|
596 | 586 | $.ajax({ |
597 | 587 | url: resgrid.absoluteBaseUrl + '/User/Subscription/GetPaddleCheckout?id=' + id + '&count=' + packs, |
|
600 | 590 | }).done(function (data) { |
601 | 591 | if (data) { |
602 | 592 | if (data.HasActiveSub) { |
603 | | - swal({ |
604 | | - title: "Active Subscription", |
605 | | - text: "You already have an active subscription. Please manage your existing subscription instead.", |
606 | | - icon: "warning", |
607 | | - buttons: true, |
608 | | - dangerMode: false |
609 | | - }); |
| 593 | + swal({ title: "Active Subscription", text: "You already have an active subscription. Please manage your existing subscription instead.", icon: "warning", buttons: true, dangerMode: false }); |
| 594 | + return; |
| 595 | + } |
| 596 | +
|
| 597 | + if (!data.PriceId) { |
| 598 | + swal({ title: "Checkout Error", text: "Unable to create a checkout session. Please try again.", icon: "error", buttons: true, dangerMode: false }); |
610 | 599 | return; |
611 | 600 | } |
612 | 601 |
|
613 | 602 | var checkoutSettings = { |
614 | | - settings: { |
615 | | - successUrl: resgrid.absoluteBaseUrl + '/User/Subscription/PaddleProcessing?planId=' + id |
616 | | - }, |
617 | | - items: [{ |
618 | | - priceId: data.PriceId, |
619 | | - quantity: packs |
620 | | - }] |
| 603 | + settings: { successUrl: resgrid.absoluteBaseUrl + '/User/Subscription/PaddleProcessing?planId=' + id }, |
| 604 | + items: [{ priceId: data.PriceId, quantity: packs }] |
621 | 605 | }; |
622 | 606 |
|
623 | 607 | if (data.CustomerId) { |
624 | 608 | checkoutSettings.customer = { id: data.CustomerId }; |
625 | 609 | } |
626 | 610 |
|
627 | 611 | Paddle.Checkout.open(checkoutSettings); |
| 612 | + } else { |
| 613 | + swal({ title: "Checkout Error", text: "Unable to create a checkout session. Please try again.", icon: "error", buttons: true, dangerMode: false }); |
628 | 614 | } |
| 615 | + }).fail(function () { |
| 616 | + swal({ title: "Connection Error", text: "Unable to reach the server. Please check your connection and try again.", icon: "error", buttons: true, dangerMode: false }); |
629 | 617 | }); |
630 | 618 | } else { |
631 | | - swal({ |
632 | | - title: "Cannot Purchase", |
633 | | - text: "Resgrid includes 10 entities for free for all departments. Please select a entity count greater then 10 to purchase.", |
634 | | - icon: "warning", |
635 | | - buttons: true, |
636 | | - dangerMode: false |
637 | | - }); |
| 619 | + swal({ title: "Cannot Purchase", text: "Please select more entities to purchase a plan.", icon: "warning", buttons: true, dangerMode: false }); |
638 | 620 | } |
639 | 621 | } |
640 | 622 |
|
|
0 commit comments