1

我正在尝试向 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");
4

1 回答 1

2

很抱歉延迟回复您,没有看到您的回复通知。在 POST 中,HPP 将不接受反逗号并在字符串中的该点截断。

您可以尝试在输出时对字符串进行 url 编码并在响应返回时进行解码吗?HPP 上自定义字段的最大长度为 255。或者您可以只对反逗号进行 url 编码。希望这适合您的需求。如果没有,请告诉我。

最好的,

肖恩·麦克多姆纳尔

Realex 支付

于 2017-07-06T16:29:21.053 回答