Pero tengo una duda al momento de capturar los datos despues que el usuario realiza el pago en Paypal, como el id de la transaccion, el email, etc.
Pero me sale un error. Dejo mi codigo para que me puedan ayudar.
Este es mi formulario donde estan mis datos que seran enviados a Paypal:
Código:
Mi controlador : <form method="post" action="@ConfigurationManager.AppSettings["PayPalSubmitUrl"]"> <input type="hidden" name="upload" value="1"/> <input type="hidden" name="return" value="@ConfigurationManager.AppSettings["returnurl"]" /> <input type="hidden" name="cmd" value="_cart" /> <input type="hidden" name="business" value="@ConfigurationManager.AppSettings["PayPalUsername"]" /> <input type="hidden" name="item_name_1" value="Producto" /> <input type="hidden" name="item_number_1" value="p1" /> <input type="hidden" name="amount_1" value="2" /> <input type="hidden" name="quantity_1" value="3" /> <input type="image" src="https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif" /> </form>
Código:
La pagina donde se mostraran los datos que obtengo de Paypal:public ActionResult Success() { ViewBag.result = PDTHolder.Success(Request.QueryString.Get("tx")); return View("Success"); }
Código:
<div class="feat_prod_box_details"> <div class="contact_form"> <div class="form_subtitle">Order Information</div> <div class="form_row"> <label class="contact"><strong>Email:</strong></label> @ViewBag.result.TransactionId </div> <div class="form_row"> <label class="contact"><strong>Payment Gross:</strong></label> @ViewBag.result.GrossTotal </div> <div class="form_row"> <label class="contact"><strong>Payment Free:</strong></label> @ViewBag.result.PaymentFree </div> </div> </div>
Código:
Y me sale este error : Microsoft.CSharp.RuntimeBinder.RuntimeBinderExcept ion: No se puede realizar enlace en tiempo de ejecución en una referencia NULL.public static PDTHolder Success(string tx) { authToken = WebConfigurationManager.AppSettings["PDTToken"]; txToken = tx; query = string.Format("cmd=_notify-synch&tx={0}&at={1}",txToken, authToken); string url = WebConfigurationManager.AppSettings["PayPalSubmitUrl"]; HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url); req.Method = "POST"; req.ContentType = "application/x-www-form-urlencoded"; req.ContentLength = query.Length; StreamWriter stOut = new StreamWriter(req.GetRequestStream(),System.Text.Encoding.ASCII); stOut.Write(query); stOut.Close(); StreamReader stIn = new StreamReader(req.GetResponse().GetResponseStream()); strResponse = stIn.ReadToEnd(); stIn.Close(); if (strResponse.StartsWith("SUCCESS")) return PDTHolder.Parse(strResponse); return null; }
Agradeceria mucho si me podrian ayudar, Gracias.