我想从服务器端(ASP.NET/C#)发布此表单:
<FORM action="https://login:password@payment.architrade.com/cgi-adm/refund.cgi" method=POST>
<input type="hidden" name="merchant" value="12345678">
<input type="hidden" name="transact" value="11111111">
<input type="hidden" name="amount" value="2000">
<input type="hidden" name="currency" value="208">
<input type="hidden" name="orderid" value="11223344">
<input type="hidden" name="md5key" value="cfcd208495d565ef66e7dff9f98764da">
<input type="hidden" name="textreply" value="yes">
</FORM>
我正在尝试使用 WebClient.UploadValues。我的代码是
private void PostRefundRequest(Mediachase.Commerce.Orders.Payment payment)
{
WebClient webClient = new WebClient();
NameValueCollection refundRequest = new NameValueCollection();
PaymentMethodDto dibs = PaymentManager.GetPaymentMethodBySystemName("DIBS", SiteContext.Current.LanguageName);
string merchant = GetParameterByName(dibs, DIBSPaymentGateway.UserParameter).Value;
PurchaseOrder po = payment.Parent.Parent as PurchaseOrder;
string orderid = po.TrackingNumber;
string transact = payment.TransactionID;
string amount = (payment.Amount * 100).ToString();
refundRequest.Add("merchant", merchant);
refundRequest.Add("transact", transact);
refundRequest.Add("amount", amount );
refundRequest.Add("currency", payment.Parent.Parent.BillingCurrency);
refundRequest.Add("orderid", orderid);
string md5 = GetMD5KeyRefund(merchant, orderid, transact, amount);
refundRequest.Add("md5key", md5);
refundRequest.Add("textreply", "yes");
byte[] responseArray = webClient.UploadValues("https://<mylogin>:<mypassword>@payment.architrade.com/cgi-adm/refund.cgi", refundRequest);
}
我尝试调试,一切似乎都正确,但 API 返回 HTTP 401(未经授权)。我关心的是:WebClient.UploadValues 是否支持 API 的 url(包括用户名/密码)
谢谢你。