Я пытаюсь добавить очень простую стену оплаты мудреца на моей веб-странице, и когда я импортирую скрипт, кажется, что он не вызывает сценарий js. Я новичок в asp.net и не могу понять, как выполнить блок сценариев, im используя код позади, а также в С#. Это мой очень простой код asp.net для обработки транзакций.
<%@ Page Language="C#" Inherits="MG_CreditCard_Authenticator_1.Default" %>
<!DOCTYPE html>
<html>
<head runat="server">
<title>Default</title>
</head>
<body>
<form id="form1" runat="server" >
<div id="topLevel" runat="server" margin="100px">
<asp:Label id="InvoiceLable" runat="server" Text="Invoice" />
<asp:TextBox id="InvoiceTextBox" runat="server" TextMode="Password" />
</div>
<div id="secondTopLevel" runat="server" >
<asp:Label id="DateLabel" runat="server" Text="Date"/>
<asp:TextBox id="DateTextBox" runat="server"/>
</div>
<div id="thirdTopLevel" runat="server">
<asp:Button id="button1" runat="server" Text="Finish" OnClick="button1Clicked" />
</div>
<div id="form2" runat="server">
<asp:TextBox id="postInflow" runat="server" Height="200px" Width="400px" ReadOnly="true" TextMode="MultiLine" />
<asp:Button id="genRecipt" runat="server" Text="Generate" OnClick="ACHauth" />
<script type="text/javascript" src="https://www.sagepayments.net/pay/1.0.2/js/pay.min.js"></script>
<!-- <script language="javascript"src='<%=ResolveUrl("PaymentHandler.js")%>' type='text/javascript'</script>
-->
</div>
</form>
</body>
</html>
И этот мой код на С# за кодом
using System;
using System.Web;
using System.Web.UI;
namespace MG_CreditCard_Authenticator_1
{
public partial class Default : System.Web.UI.Page
{
String invoiceNumber = "Invoice Number";
//String Date = "";
//String outputData = "";
//int buttonclicks = 0;
public void button1Clicked(object sender, EventArgs args)
{
button1.Text = "Done";
invoiceNumber = InvoiceTextBox.Text;
InvoiceLable.Text = "Invoice Number";
postInflow.Text = "Displaying info for Invoice Number: "+InvoiceTextBox.Text+" made on "+DateTextBox.Text;
Page.ClientScript.RegisterClientScriptInclude("Registration", ResolveUrl("/Users/ShashankMurthy/Projects/MG_CreditCard_Authenticator_1.03/MG_CreditCard_Authenticator_1.03/PaymentHandler.js"));
}
public void GetValue(String key){
var appConfig = System.IO.File.ReadAllText(key);
}
public void ACHauth(object sender, EventArgs args){
}
}
}
Я пробовал все решения, которые я мог найти в Интернете, но функция javascript не вызывается.
Файл Javascript, который я создал для скрипта
<script type="text/javascript">
PayJS(['PayJS/UI'], // loading the UI module...
function($UI) { // ... and assigning it to a variable
$UI.Initialize({
elementId: "paymentButton",
// identifiers (no keys!):
clientId: "myClientId", // https://developer.sagepayments.com/user/register
merchantId: "999999999997",
// auth, covered later:
authKey: "ABCD==",
salt: "DEFG==",
// config:
requestType: "payment", // or "vault" to tokenize a card for later
amount: "1.00",
orderNumber: "Invoice12345",
// convenience:
addFakeData: true,
});
});
</script>
Обновлен код asp.net
<%@ Page Language="C#" Inherits="MG_CreditCard_Authenticator_1.Default" %>
<!DOCTYPE html>
<html>
<head runat="server">
<title>Default</title>
</head>
<body>
<form id="form1" runat="server" >
<div id="topLevel" runat="server" margin="100px">
<asp:Label id="InvoiceLable" runat="server" Text="Invoice" />
<asp:TextBox id="InvoiceTextBox" runat="server" TextMode="Password" />
</div>
<div id="secondTopLevel" runat="server" >
<asp:Label id="DateLabel" runat="server" Text="Date"/>
<asp:TextBox id="DateTextBox" runat="server"/>
</div>
<div id="thirdTopLevel" runat="server">
<asp:Button id="button1" runat="server" Text="Finish" OnClick="button1Clicked" />
</div>
<div id="form2" runat="server">
<asp:TextBox id="postInflow" runat="server" Height="200px" Width="400px" ReadOnly="true" TextMode="MultiLine" />
<script type="text/javascript" src="https://www.sagepayments.net/pay/1.0.2/js/pay.min.js"></script>
<button id="paymentButton">
Click
</button>
<script type="text/javascript">
PayJS(['PayJS/UI'], // loading the UI module...
function($UI) { // ... and assigning it to a variable
$UI.Initialize({
elementId: "paymentButton",
// identifiers (no keys!):
clientId: "myClientId", // https://developer.sagepayments.com/user/register
merchantId: "999999999997",
// auth, covered later:
authKey: "ABCD==",
salt: "DEFG==",
// config:
requestType: "payment", // or "vault" to tokenize a card for later
amount: "1.00",
orderNumber: "Invoice12345",
// convenience:
addFakeData: true,
});
});
</script>
</div>
</form>
</body>
</html>
Я не думаю, что вы хотите, чтобы кнопки ASP делали сообщения обратно в код. Вы можете увидеть здесь https://jsfiddle.net/ax67cpjt/, что я просто добавил ваш скрипт и кнопку с id paymentButton
и он отлично работает.