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

时间:2012-02-26 23:02:49

标签: c# asp.net inheritance buttonclick

我一直在为ASP.Net(C#)实施DPS(http://sec.paymentexpress.com/technical_resources/ecommerce_hosted/pxpay.html)示例代码,以便为我的公司创建支付网关。我把它工作得很好,向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);
        }
    }

1 个答案:

答案 0 :(得分:0)

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

相关问题