我正在尝试向realex发送自定义字段,以便在成功响应时使用。有问题的字段是json数组。
[{"InvoiceId":7,"AmountPaid":180,"SucessfulPayment":false}]
我遇到的问题是在响应时数组被截断为[{
。我有这个工作通过base 64编码数组但感觉它有点沉重,宁愿发送原始的json。我还担心字段长度可能会有字符限制,这会很快被吃掉。如果对长度没有限制,我可能会去64岁。
按要求编码。
传入请求对象的JSON数组
[{"InvoiceId":7,"AmountPaid":180,"SucessfulPayment":false}]
realex响应返回
[{
代码:
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="RealexRedirectTestPay.aspx.cs"
Inherits="SmartClubOnline.RedirectTest" %>
<!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></title>
</head>
<body onload="document.form.submit();">
<div class="content">
<form name="form"
action="https://hpp.sandbox.realexpayments.com/pay" method="post">
<asp:Literal ID="MERCHANT_ID" runat="server" />
<asp:Literal ID="SECRET_ID" runat="server" />
<asp:Literal ID="CLUB_NAME" runat="server" />
<asp:Literal ID="ORDER_ID" runat="server" />
<asp:Literal ID="CURRENCY_ID" runat="server" />
<asp:Literal ID="CURRENCY" runat="server" />
<asp:Literal ID="AMOUNT" runat="server" />
<asp:Literal ID="TIMESTAMP" runat="server" />
<asp:Literal ID="MEMBER_ID" runat="server" />
<asp:Literal ID="MEMBER_USERNAME" runat="server" />
<asp:Literal ID="MEMBER_EMAIL" runat="server" />
<asp:Literal ID="INVOICE_ID" runat="server" />
<asp:Literal ID="MEMBERPURSEID" runat="server" />
<asp:Literal ID="SHA1HASH" runat="server" />
<asp:Literal ID="TempOrderNumber" runat="server" />
<asp:Literal ID="PromoRow" runat="server" />
<asp:Literal ID="DELAYEDSETTLEMENTON" runat="server" />
<asp:Literal ID="CREDITCARD_SHG_AMT" runat="server" />
<asp:Literal ID="DEBITCARD_SHG_AMT" runat="server" />
<asp:Literal ID="AUTO_SETTLE_FLAG" runat="server" />
<asp:Literal ID="MERCHANT_RESPONSE_URL" runat="server" />
<!--<input type="hidden" name="AUTO_SETTLE_FLAG" value="1" />-->
<h3>
Redirecting you to our Payment Provider</h3>
<p>
You are being securely redirected to our payment provider...Please Wait...</p>
<!-- uncomment if you want the user to click a button to continue. Also remove the onload function in the Body tag -->
<!-- <p><input type="submit" name="submit" value="continue to payment provider" /></p> -->
</form>
</div>
</body>
</html>
服务器端请求:
MERCHANT_ID.Text = "<input type=\"hidden\" name=\"MERCHANT_ID\"
value=\"" + merchantID + "\" />";
SECRET_ID.Text = "<input type=\"hidden\" name=\"SECRET_ID\"
value=\"" + sharedSecret + "\" />";
CLUB_NAME.Text = "<input type=\"hidden\" name=\"CLUB_NAME\"
value=\"" + CLUBNAME + "\" />";
ORDER_ID.Text = "<input type=\"hidden\" name=\"ORDER_ID\"
value=\"" + orderID + "\" />";
CURRENCY.Text = "<input type=\"hidden\" name=\"CURRENCY\"
value=\"" + currencyCode + "\" />";
CURRENCY_ID.Text = "<input type=\"hidden\" name=\"CURRENCY_ID\"
value=\"" + currencyCode + "\" />";
AMOUNT.Text = "<input type=\"hidden\" name=\"AMOUNT\" value=\""
+ amount + "\" />";
TIMESTAMP.Text = "<input type=\"hidden\" name=\"TIMESTAMP\"
value=\"" + timestamp + "\" />";
MEMBER_ID.Text = "<input type=\"hidden\" name=\"MEMBER_ID\"
value=\"" + MEMBERID + "\" />";
MEMBER_USERNAME.Text = "<input type=\"hidden\"
name=\"MEMBER_USERNAME\" value=\"" + MEMBERUSERNAME + "\" />";
MEMBER_EMAIL.Text = "<input type=\"hidden\"
name=\"MEMBER_EMAIL\" value=\"" + MEMBEREMAIL + "\" />";
INVOICE_ID.Text = "<input type=\"hidden\" name=\"INVOICE_ID\"
value=\"" + INVOICEID + "\" />";
MEMBERPURSEID.Text = "<input type=\"hidden\"
name=\"MEMBERPURSEID\" value=\"" + "0" + "\" />";
SHA1HASH.Text = "<input type=\"hidden\" name=\"SHA1HASH\"
value=\"" + hash + "\" />";
AUTO_SETTLE_FLAG.Text = "<input type=\"hidden\"
name=\"AUTO_SETTLE_FLAG\" value=\"" + AUTOSETTLEFLAG + "\" />";
DELAYEDSETTLEMENTON.Text = "<input type=\"hidden\"
name=\"DELAYEDSETTLEMENTON\" value=\"" + DELAYEDSETTLEFLAG + "\" />";
CREDITCARD_SHG_AMT.Text = "<input type=\"hidden\"
name=\"CREDITCARD_SHG_AMT\" value=\"" + CREDITCARD_SHG + "\" />";
DEBITCARD_SHG_AMT.Text = "<input type=\"hidden\"
name=\"DEBITCARD_SHG_AMT\" value=\"" + DEBITCARD_SHG + "\" />";
MERCHANT_RESPONSE_URL.Text = "<input type=\"hidden\"
name=\"MERCHANT_RESPONSE_URL\" value=\"" + _realexResponseURL + "\" />";
realex响应中的代码失败:
if (Request.Form["INVOICE_ID"] != null)
INVOICEID = Request.Form["INVOICE_ID"].ToString();
else
StaticOps.AddErrorToLog("FORM.INVOICE_ID : ", "VALUE NULL",
"RealexResponse");
答案 0 :(得分:2)
对于延迟回复您而道歉,没有看到您的回复通知。在POST中,HPP将不接受引号并在字符串中的那一点截断。
你可以尝试在出路时对字符串进行url编码,并在响应回来时进行解码吗? HPP上自定义字段的最大长度为255.或者您只需对引号进行url编码即可。希望这符合您的需求。如果没有,请告诉我。
最佳,
SeánMacDomhnall
Realex付款