此致
我正在开发一个基于paypalstandard的插件付款方式,只有我有问题,它应该通过POST方法发送付款细节(网关是pagosonline)然后最后一步是通过POST方法发送此信息并重定向到pagosonline的网关结束支付过程,问题是paypalstandar重定向与GET方法中的变量,我需要用POST方法,就像你在那种情况下做的那样?,我试图用NameValueCollection做到这一点()和webclient()但显然这是用ajax或类似的东西完成的,我需要重定向到网关。
for finalize我把处理器类中的代码postprocesspayment放在处理器类(C#)中。
public void PostProcessPayment(PostProcessPaymentRequest postProcessPaymentRequest)
{
var key = _paypalStandardPaymentSettings.EncryptKey;
var idus = _paypalStandardPaymentSettings.IdUsuario;
var refe = postProcessPaymentRequest.Order.OrderGuid;
var valor = Math.Round(postProcessPaymentRequest.Order.OrderTotal, 2);
var mone = "COP";
var firma_plana = key + "~" + idus + "~" + refe + "~" + valor + "~" + mone;
MD5 md5 = MD5CryptoServiceProvider.Create();
ASCIIEncoding encoding = new ASCIIEncoding();
byte[] stream = null;
StringBuilder sb = new StringBuilder();
stream = md5.ComputeHash(encoding.GetBytes(firma_plana));
for (int i = 0; i < stream.Length; i++) sb.AppendFormat("{0:x2}", stream[i]);
var firma_md5 = sb.ToString();
var webClient = new WebClient();
var form = new NameValueCollection();
form.Add("usuarioId", idus);
form.Add("descripcion", _paypalStandardPaymentSettings.Descripcion);
form.Add("refVenta", refe.ToString());
form.Add("valor", valor.ToString("0.00", CultureInfo.InvariantCulture));
form.Add("baseDevolucionIva", "0");
form.Add("iva", "0");
form.Add("moneda", "COP");
form.Add("firma", firma_md5);
webClient.UploadValues(GetPaypalUrl(), form);
}
感谢。
答案 0 :(得分:2)
UploadValues有一个重载使用方法:
webClient.UploadValues(GetPaypalUrl(), "POST", form);