Realex HPP 请求-自定义字段

Realex HPP request -custom field

我正在尝试向 realex 发送一个自定义字段,以便在成功响应时使用。有问题的字段是一个 json 数组。

[{"InvoiceId":7,"AmountPaid":180,"SucessfulPayment":false}]

我遇到的问题是响应数组被截断为 [{。我通过对数组进行 base 64 编码来实现这一点,但感觉它有点重,宁愿发送原始 json。我还担心字段长度可能会有字符限制,这会很快被吃掉。如果没有长度限制,我可能会使用 base 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");

很抱歉延迟回复您,没有看到您的回复通知。在 POST 中,HPP 不会接受字符串中那个点的引号和截断。

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

最佳,

肖恩·麦克多姆纳尔

Realex 支付