-
Notifications
You must be signed in to change notification settings - Fork 0
/
PaymentInfo.cshtml
104 lines (92 loc) · 2.92 KB
/
PaymentInfo.cshtml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
@{
Layout = "";
}
@inject NmiPaymentSettings nmiPaymentSettings
@inject Nop.Core.Domain.Orders.OrderSettings orderSettings
@using Nixtus.Plugin.Payments.Nmi
@model Nixtus.Plugin.Payments.Nmi.Models.PaymentInfoModel
<style scoped>
td.error {
color: red;
}
</style>
<table width="100%" cellspacing="2" cellpadding="1" border="0">
<tr>
<td>
@Html.LabelFor(model => model.CardNumber, false):
</td>
<td id="ccnumber"></td>
</tr>
<tr>
<td></td>
<td class="error" id="ccnumber-error"></td>
</tr>
<tr>
<td>
@Html.LabelFor(model => model.ExpireMonth, false):
</td>
<td id="ccexp"></td>
</tr>
<tr>
<td></td>
<td class="error" id="ccexp-error"></td>
</tr>
<tr>
<td>
@Html.LabelFor(model => model.CardCode, false):
</td>
<td id="cvv"></td>
</tr>
<tr>
<td></td>
<td class="error" id="cvv-error"></td>
</tr>
</table>
<input type="hidden" name="Token" id="Token" asp-for="Token">
<script>
var onePageCheckout = @orderSettings.OnePageCheckoutEnabled.ToString().ToLower();
var formSubmitted = false;
function addScript() {
var s = document.createElement('script');
s.setAttribute('src', 'https://secure.networkmerchants.com/token/Collect.js');
s.setAttribute('data-tokenization-key', '@nmiPaymentSettings.CollectJsTokenizationKey');
s.onload = () => {
CollectJS.configure({
variant: 'inline',
callback: (response) => {
$('#@Html.IdFor(model => model.Token)').val(response.token);
if (onePageCheckout) {
PaymentInfo.save();
} else {
formSubmitted = true;
$("input.payment-info-next-step-button").click();
}
},
validationCallback: (field, status, message) => {
if (!status) {
$("#" + field + "-error").html(message);
} else {
$("#" + field + "-error").html("");
}
}
});
};
document.body.appendChild(s);
}
$(document).ready(() => {
//remove handler so we dont validate the form
$('.payment-info-next-step-button').attr('onclick', null);
addScript();
$(".payment-info-next-step-button").on('click', (event) => {
if (formSubmitted) {
// add form parameter so that the right action is hit
var input = $("<input>").attr("type", "hidden").attr("name", "nextstep").val("Next");
$("form[action='/checkout/paymentinfo']").append(input);
$("form[action='/checkout/paymentinfo']").submit();
return false;
}
CollectJS.startPaymentRequest(event);
return false;
});
});
</script>