2012-02-26 26 views
0

我一直在實施DPS(http://sec.paymentexpress.com/technical_resources/ecommerce_hosted/pxpay.html)ASP.Net(C#)的示例代碼來創建支付網關我的公司。我工作得很好,向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); 
     } 
    } 
+0

你不能嘗試調試你的代碼,看看它是否會拋出聲明? – DotNetUser 2012-02-27 00:26:10

+0

看,那裏有一個問題。我正在使用MonoDevelop和我們的代碼組織方式,調試不起作用。這是一個真正的痛苦。這就是我使用異常的原因。 – 2012-02-27 00:29:46

+0

您是否在aspx標記中將AutoEventWireup設置爲true? – DotNetUser 2012-02-27 00:36:24

回答

0

我找到了問題!這是DPS特有的東西。我已將事務ID更改爲長於16個字符的內容,並且請求失敗。我只是看不到它發生,這就是爲什麼它花了我很長時間才發現。謝謝你的建議。