会社の支払いゲートウェイを作成するために、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>
</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);
}
}