我知道Cybersource在这里不是很熟悉,但我真的遇到了一些问题,也许有人可以帮助我。
我试过Cybersource 支持中心,但显然他们不支持测试帐户。
我有以下代码,我试图在其中执行对 Cybersource 的发布请求:
private async void Confirm_Payment(object sender, EventArgs e)
{
var randomGuid = Guid.NewGuid().ToString();
var currentDateTime = GetUTCDateTime();
var referenceNumber = "1594706148080";
using (var client = new HttpClient())
{
using (var content = new MultipartFormDataContent())
{
var values = new Dictionary<string, string>
{
{"access_key", "ACCESS_KEY"},
{"profile_id", "PROFILE_ID"},
{"transaction_uuid", randomGuid},
{"signed_field_names", "access_key,profile_id,transaction_uuid,signed_field_names,unsigned_field_names,signed_date_time,locale,transaction_type,reference_number,amount,currency"},
{"unsigned_field_names", ""},
{"signed_date_time", currentDateTime},
{"locale", "en"},
{"transaction_type", "authorization"},
{"reference_number", referenceNumber},
{"amount", "100.00"},
{"currency", "USD"},
{"submit", "Submit"}
};
var signature = Security.Sign(values);
foreach (var keyValuePair in values)
{
content.Add(new StringContent(keyValuePair.Value), keyValuePair.Key);
}
content.Add(new StringContent(signature), "signature");
var requestUri = "https://testsecureacceptance.cybersource.com/pay";
var result = await client.PostAsync(requestUri, content);
if (result.IsSuccessStatusCode)
{
var resp = await result.Content.ReadAsStringAsync();
await Navigation.PushAsync(new WebScreen(requestUri));
}
}
}
}
result.IsSuccessStatusCode
是200 OK
,但每当我await result.Content.ReadAsStringAsync();
得到一个会话超时页面
请注意,.NET 中的相同代码运行良好:
<form id="payment_confirmation" action="https://testsecureacceptance.cybersource.com/pay" method="post">
<fieldset id="confirmation">
<legend>Review Payment Details</legend>
<div>
<%
foreach (var key in Request.Form.AllKeys)
{
Response.Write("<div>");
Response.Write("<span class=\"fieldName\">" + key + ":</span><span class=\"fieldValue\">" + Request.Params[key] + "</span>");
Response.Write("</div>");
}
%>
</div>
</fieldset>
<%
IDictionary<string, string> parameters = new Dictionary<string, string>();
foreach (var key in Request.Form.AllKeys)
{
Response.Write("<input type=\"hidden\" id=\"" + key + "\" name=\"" + key + "\" value=\"" + Request.Params[key] + "\"/>\n");
parameters.Add(key, Request.Params[key]);
}
Response.Write("<input type=\"hidden\" id=\"signature\" name=\"signature\" value=\"" + secureacceptance.Security.Sign(parameters) + "\"/>\n");
%>
<input type="submit" id="submit" value="Confirm" />
</form>
我试图采用相同的代码并执行它,Xamarin Forms
但它没有用。
我认为问题在于我们应该添加特定的标头以让Cybersource 网关不会出现会话超时问题。有谁知道可能是什么问题?