0

我一直在为 ASP.Net (C#) 实施 DPS (http://sec.paymentexpress.com/technical_resources/ecommerce_hosted/pxpay.html) 示例代码,以为我的公司创建支付网关。我让它工作正常,向 Payment Express 发送请求,获得响应等,就像它应该做的那样。

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

毕竟,我再次对其进行了测试,并且按钮单击事件没有触发。我认为这可能与新继承有关,所以我将页面更改为继承“页面”(就像以前一样),但这并没有帮助。

“查找/添加到数据库”功能稍后会出现,所以我认为这与它没有任何关系。

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

为了澄清,我说事件没有触发,因为我在事件的第一行抛出了一个异常,并且没有抛出异常。不过,该按钮似乎确实进行了回发。

这是一些代码:

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);
        }
    }
4

1 回答 1

0

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

于 2012-02-28T03:48:05.063 回答