Question

Regards,

I'm developing a plugin payment method based on the paypalstandard, only I have a problem, It should send payment details by POST method (the gateway is pagosonline) then the last step is to send this information by POST method and redirect to the gateway of pagosonline to end the payment process, the problem is that paypalstandar redirect with the varibles in GET method and I need to do it with POST method, as you would in that case?, I'm trying to do it with NameValueCollection() and webclient() but apparently this is done with ajax or something similar and I need to redirect to the gateway.

for finalize I put the code that I have in the method postprocesspayment in the processor class (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);
    }

thanks.

Was it helpful?

Solution

UploadValues has an overload to use a method:

webClient.UploadValues(GetPaypalUrl(), "POST", form);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top