如何处理paypal电子支票

时间:2015-07-27 08:23:46

标签: c# paypal paypal-ipn payment-gateway paypal-sandbox

我无法在应用程序付款成功页面上处理通过PayPal echeque进行的付款。

如何处理PayPal echeque响应?我们正在使用以下代码来处理回复。

try
    {
            LOgfile lg = new LOgfile();
            string strLive = System.Configuration.ConfigurationManager.AppSettings["PaypalreturnURL"].ToString();
            HttpWebRequest req = (HttpWebRequest)WebRequest.Create(strLive);

            //Set values for the request back
            req.Method = "POST";
            req.ContentType = "application/x-www-form-urlencoded";
            byte[] param = Request.BinaryRead(HttpContext.Current.Request.ContentLength);
            string strRequest = Encoding.ASCII.GetString(param);
            strRequest += "&cmd=_notify-validate";

            req.ContentLength = strRequest.Length;


            StreamWriter streamOut = new StreamWriter(req.GetRequestStream(), System.Text.Encoding.ASCII);
            streamOut.Write(strRequest);
            streamOut.Close();
            StreamReader streamIn = new StreamReader(req.GetResponse().GetResponseStream());
            string strResponse = streamIn.ReadToEnd();
            streamIn.Close();
            NameValueCollection vale = HttpUtility.ParseQueryString(strRequest);


            if (strResponse == "VERIFIED")
            {
                trnsid = vale["txn_id"].ToString();
                string valecust = vale["custom"].ToString();
                string[] arycust = valecust.Split(',');

                if (!IsPostBack)
                {
                    if (arycust.Length > 0)
                    {
                       //Do something
                    }
                }
            }
        }
        catch (Exception exd)
        {
            senderrormail(exd);
        }

即使您可以通过PayPal提供NVP响应,也会有很大的帮助。

1 个答案:

答案 0 :(得分:1)

您有几种不同的选择。

您可以阻止eCheck付款:
How to block payments in PayPal

您可以设置即时付款通知并创建一个可从PayPal获取交易详情的监听器。详细信息可以包括eCheck的payment_type。您还可以通过PayPal通知您交易状态的变化。状态更改通知将告知您何时清除eCheck并且资金位于您的PayPal帐户中。

Setting up Instant Payment Notifications
IPN setup within PayPal
How to create a Listener
Payment Notification Variables
IPN Simulator
Event Notifications with Express Checkout

相关问题