Skip to content

Commit f0b0813

Browse files
committed
RE1-T112 PR#324 fixes
1 parent 92b257a commit f0b0813

2 files changed

Lines changed: 29 additions & 13 deletions

File tree

Web/Resgrid.Web/Areas/User/Views/Subscription/Index.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -731,7 +731,7 @@
731731
{ tier: 0, marginalUserSlots: 5, costPerUser: 200.0 },
732732
{ tier: 1, marginalUserSlots: 100, costPerUser: 20.0 },
733733
{ tier: 2, marginalUserSlots: 1000, costPerUser: 15.0 },
734-
{ tier: 3, marginalUserSlots: 1000, costPerUser: 10.0 },
734+
{ tier: 3, marginalUserSlots: 5000, costPerUser: 10.0 },
735735
{ tier: 4, marginalUserSlots: 999999999, costPerUser: 5.0 },
736736
];
737737

Web/Resgrid.Web/Areas/User/Views/Subscription/SelectRegistrationPlan.cshtml

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,14 @@
9999

100100
<div class="price-box">
101101
<div class="price-slider">
102-
<h4 class="great">Entities</h4>
103-
<span style="color: #7f8c8d; font-size: 13px;">Users or Units sold in packs of 10</span>
102+
<h4 class="great"><label for="entity-slider">Entities</label></h4>
103+
<span id="entity-desc" style="color: #7f8c8d; font-size: 13px;">Users or Units sold in packs of 10</span>
104104
<div style="padding: 10px 0;">
105-
<input type="range" id="entity-slider" class="entity-range" min="20" max="2000" step="10" value="20">
105+
<input type="range" id="entity-slider" class="entity-range" min="20" max="2000" step="10" value="20" aria-describedby="entity-desc">
106106
</div>
107107
<div class="text-center" style="padding-top: 5px;">
108-
<input id="amount-input" type="number" min="20" max="2000" step="10" value="20" /> <span>Entities</span>
108+
<label for="amount-input" class="sr-only">Entity count</label>
109+
<input id="amount-input" type="number" min="20" max="2000" step="10" value="20" aria-describedby="entity-desc" /> <span>Entities</span>
109110
</div>
110111
</div>
111112

@@ -115,15 +116,15 @@
115116
<span class="price-label">Monthly ($):</span>
116117
</div>
117118
<div class="col-sm-6 text-right">
118-
<span class="price-display" id="monthly-label">0</span><span class="price-cents">.00</span>
119+
<span class="price-display" id="monthly-label">0.00</span>
119120
</div>
120121
</div>
121122
<div class="row" style="padding: 10px 0;">
122123
<div class="col-sm-6">
123124
<span class="price-label">Yearly ($):</span>
124125
</div>
125126
<div class="col-sm-6 text-right">
126-
<span class="price-display" id="yearly-label">0</span><span class="price-cents">.00</span>
127+
<span class="price-display" id="yearly-label">0.00</span>
127128
</div>
128129
</div>
129130
<hr class="style">
@@ -194,9 +195,15 @@
194195
}).done(function (data) {
195196
if (data && data.SessionId) {
196197
stripe.redirectToCheckout({ sessionId: data.SessionId }).then(function (result) {
197-
swal({ title: "Purchase Error", text: "Error redirecting to Stripe: " + result.error.message, icon: "error", buttons: true, dangerMode: false });
198+
if (result.error) {
199+
swal({ title: "Purchase Error", text: "Error redirecting to Stripe: " + result.error.message, icon: "error", buttons: true, dangerMode: false });
200+
}
198201
});
202+
} else {
203+
swal({ title: "Checkout Error", text: "Unable to create a checkout session. Please try again.", icon: "error", buttons: true, dangerMode: false });
199204
}
205+
}).fail(function () {
206+
swal({ title: "Connection Error", text: "Unable to reach the server. Please check your connection and try again.", icon: "error", buttons: true, dangerMode: false });
200207
});
201208
} else {
202209
swal({ title: "Cannot Purchase", text: "Please select more than 10 entities to purchase a plan.", icon: "warning", buttons: true, dangerMode: false });
@@ -220,6 +227,11 @@
220227
return;
221228
}
222229
230+
if (!data.PriceId) {
231+
swal({ title: "Checkout Error", text: "Unable to create a checkout session. Please try again.", icon: "error", buttons: true, dangerMode: false });
232+
return;
233+
}
234+
223235
var checkoutSettings = {
224236
settings: { successUrl: resgrid.absoluteBaseUrl + '/User/Subscription/PaddleProcessing?planId=' + id },
225237
items: [{ priceId: data.PriceId, quantity: packs }]
@@ -230,7 +242,11 @@
230242
}
231243
232244
Paddle.Checkout.open(checkoutSettings);
245+
} else {
246+
swal({ title: "Checkout Error", text: "Unable to create a checkout session. Please try again.", icon: "error", buttons: true, dangerMode: false });
233247
}
248+
}).fail(function () {
249+
swal({ title: "Connection Error", text: "Unable to reach the server. Please check your connection and try again.", icon: "error", buttons: true, dangerMode: false });
234250
});
235251
} else {
236252
swal({ title: "Cannot Purchase", text: "Please select more than 10 entities to purchase a plan.", icon: "warning", buttons: true, dangerMode: false });
@@ -250,7 +266,7 @@
250266
{ marginalUserSlots: 5, costPerUser: 200.0 },
251267
{ marginalUserSlots: 100, costPerUser: 20.0 },
252268
{ marginalUserSlots: 1000, costPerUser: 15.0 },
253-
{ marginalUserSlots: 1000, costPerUser: 10.0 },
269+
{ marginalUserSlots: 5000, costPerUser: 10.0 },
254270
{ marginalUserSlots: 999999999, costPerUser: 5.0 }
255271
];
256272
@@ -276,13 +292,13 @@
276292
var amount = parseInt(document.getElementById('amount-input').value) || 0;
277293
278294
if (amount > 10) {
279-
document.getElementById('monthly-label').textContent = calculateCostFromUsers(amount, true);
280-
document.getElementById('yearly-label').textContent = calculateCostFromUsers(amount, false);
295+
document.getElementById('monthly-label').textContent = calculateCostFromUsers(amount, true).toFixed(2);
296+
document.getElementById('yearly-label').textContent = calculateCostFromUsers(amount, false).toFixed(2);
281297
document.getElementById('buyYearlyButton').style.display = '';
282298
document.getElementById('buyMonthlyButton').style.display = '';
283299
} else {
284-
document.getElementById('monthly-label').textContent = '0';
285-
document.getElementById('yearly-label').textContent = '0';
300+
document.getElementById('monthly-label').textContent = '0.00';
301+
document.getElementById('yearly-label').textContent = '0.00';
286302
document.getElementById('buyYearlyButton').style.display = 'none';
287303
document.getElementById('buyMonthlyButton').style.display = 'none';
288304
}

0 commit comments

Comments
 (0)