按钮单击事件在新集成后停止

本文关键字:集成 单击 事件 新集成 按钮 | 更新日期: 2023-09-27 18:25:57

我一直在实施DPS(http://sec.paymentexpress.com/technical_resources/ecommerce_hosted/pxpay.html)ASP.Net(C#)的示例代码,为我的公司创建一个支付网关。我让它运行得很好,向Payment Express发送请求,得到回复等等,就像它应该做的那样。

然后,我尝试将它与我的系统集成。我从我的项目中添加了一些引用,给它一个基类来继承,并将"查找/添加到数据库"函数移到另一个类中。

在所有这些之后,我再次测试了它,按钮点击事件没有启动。我认为这可能与新的继承有关,所以我将页面更改为继承"page"(就像以前一样),但这并没有帮助。

"查找/添加到数据库"功能稍后会出现,所以我认为这与此无关

有人知道可能出了什么问题吗?

为了澄清,我说事件没有启动,因为我抛出了一个异常作为事件的第一行,而该异常不是抛出。不过,这个按钮似乎确实可以进行回发。

这里有一些代码:

ASPX:

<%@ Page Language="C#" AutoEventWireup="true" Codebehind="Default.aspx.cs"  
Inherits="PaymentGatewayDPS._Default" enableViewState="false" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org
/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>PxPay .Net 3.5 test page</title>
</head>
<body>
    <form id="form1" runat="server">
    <table style="width: 100%">
    <tr>
        <td>
            Amount
        </td>
        <td>
            <asp:TextBox ID="txtAmountInput" runat="server"></asp:TextBox>
        </td>
    </tr>
    <tr>
        <td>
            Currency
        </td>
        <td>
            <asp:TextBox ID="txtCurrencyInput" runat="server"></asp:TextBox>
        </td>
    </tr>
    <tr>
        <td>
            Reference
        </td>
        <td>
            <asp:TextBox ID="txtMerchantReference" runat="server"></asp:TextBox>
        </td>
    </tr>
    <tr>
        <td>
            Transaction type
        </td>
        <td>
            <asp:DropDownList ID="ddlTxnType" runat="server">
                <asp:ListItem Selected="True">Purchase</asp:ListItem>
                <asp:ListItem Value="Auth">Authorisation</asp:ListItem>
            </asp:DropDownList>
        </td>
    </tr>
    <tr>
        <td>
            &nbsp;
        </td>
        <td>
            <asp:Button ID="Button1" runat="server" Text="Submit"
OnClick="Button1_Click"/>
        </td>
    </tr>
</table>
<asp:Panel ID="Panel1" runat="server">
</asp:Panel>
<asp:Literal id="LitTest" runat="server"/>
</form>
</body>
</html>

我的C#代码的开端:

namespace PaymentGatewayDPS
{
public partial class _Default : TCInsuredQuoteBase
{

我的按钮事件:

protected void Button1_Click(object sender, EventArgs e)
    {
        throw new Exception("button clicked");
        string PxPayUserId = ConfigurationManager.AppSettings["PxPayUserId"];
        string PxPayKey = ConfigurationManager.AppSettings["PxPayKey"];
        PxPay WS = new PxPay(PxPayUserId, PxPayKey);
        RequestInput input = new RequestInput();
        input.AmountInput = txtAmountInput.Text;
        input.CurrencyInput = txtCurrencyInput.Text;
        input.MerchantReference = txtMerchantReference.Text;
        input.TxnType = ddlTxnType.Text;
        input.UrlFail = Request.Url.GetLeftPart(UriPartial.Path);
        input.UrlSuccess = Request.Url.GetLeftPart(UriPartial.Path);
        // TODO: GUID representing unique identifier for the transaction within the shopping cart (normally would be an order ID or similar)
        Guid orderId = Guid.NewGuid();
        input.TxnId = orderId.ToString();
        throw new Exception("about to Generate Request");
        RequestOutput output = WS.GenerateRequest(input);
        if (output.valid == "1")
        {
            // Redirect user to payment page
            Response.Redirect(output.Url);
        }
    }

按钮单击事件在新集成后停止

我发现了问题!这是DPS特有的东西。我已将事务ID更改为超过16个字符,请求失败。我就是看不到它的发生,这就是为什么我花了这么长时间才找到它。谢谢你的建议。