沙盒重定向破坏会议 [英] sand box redirection destroys sessions

查看:215
本文介绍了沙盒重定向破坏会议的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么当我重定向用户从我的本地PayPal的沙盒(https://www.sandbox.paypal.com),然后返回到.aspx页面中(successful.aspx)后发生,它的损失会

why it happen when i redirect user to PAYPAL's sandbox (https://www.sandbox.paypal.com) from my localhost then after returning to .aspx page (successful.aspx), it losses session,

例如。 SESSION [tempUser],它适用于everypage但不Successful.aspx页面上,则返回null,我对这个工作的错误2周,但没有取得任何进展,
我尝试不同的浏览器,甚至是不同的系统,改变了code一下,但没有任何帮助,它一直1个月+后几种形式几个职位,没有在返回帮助甚至饼干有相同的问题,空,我以前的帖子。

e.g. SESSION["tempUser"], it works on everypage but not on Successful.aspx page, it returns null, i am working on this error for 2 weeks, but no progress, i tried different browsers, even different system, changed code a bit but nothing helped, its been 1month+ and after several posts on several forms , nothing helped even cookies have same problem, null upon return , my prior post.

重定向页面code:

<body>
    <form id="form1" runat="server">
<div>
 <h4> Congrats <b> <%# Session["tempSubAdminName"]%>  </b>, Your basic informaton has been submitted , For full activation you need to pay via paypal. Please click the PayPal icon given below. </h4>
</div>
<div>
 <asp:HyperLink ID="homeBtnImage" runat="server" ImageUrl="~/btnPayPal.gif"
      NavigateUrl= "https://www.sandbox.paypal.com/us/cgi-bin/webscr?cmd=_xclick&business=smile2_1355775057_biz@yahoo.com&item_name=MemberShip&amount=20&currency=USD&return=http://127.0.0.1:57135/Online%20Recruitment%20System-Final/paymentSuccessful.aspx?emailAdmin='1234' &cancel_return=https://www.google.com/" >PayPal</asp:HyperLink>
</div>
<h6>Or if you don't have paypal account, click <asp:HyperLink ID="paypalSite" runat="server"
    NavigateUrl="https://www.sandbox.paypal.com/" >here</asp:HyperLink> </h6>
</form>


返回到了这个年龄,如果成功

Return to this age if successful

</head>
 <body>
   <form id="form1" runat="server">
   <div>
     <h5> Dear <%# Session["tempSubAdmin"] %>, You have successfully registered ,   Please wait for the approval by admin. </h5>
</div>
</form>

推荐答案

我解释我已实施的方式。它可能会发生变化人到人

I am explaining the way i have implemented. it may vary person to person.


  1. 首先,你必须创建开发商的PayPal API 的帐户。帐户。

  2. 然后创建两个测试账号,一个用于客户端,另一个用于企业(商家)。

  3. 的web.config 文件中声明这些值。

  1. First you have to create an account on developer paypal api. account.
  2. Then create two test accounts, one for client and another for business(merchant).
  3. Declare these values in the web.config file.

 <appSettings>    
    <!--these keys are for Paypal-->
    <add key="paypalURL" value="https://www.sandbox.paypal.com" />
    <add key="paypalAccount" value="arshad_Mer_biz@gmail.com" />
    <add key="websiteUrl" value="http://www.yourstie.com" />
  </appSettings>


  • 现在,您必须设置贝宝HTML varaible因此,细节宝变量

    按照code ++写在 button_click 事件

    write following code in the button_click event

    string redirectUrl = ConfigurationManager.AppSettings["paypalURL"]+"/cgi-bin/webscr?cmd=_xclick";
    string sellersEmail = "&business=";
    string buyersEmail = "&email=";
    string productName = "&item_name=";
    string amount = "&amount=";
    string shippingOption = "&no_shipping=";
    string noteOpton = "&no_note=";
    string returnUrl = "&return=";
    string cancelUrl = "&cancel_return=";
    string rmOption = "&rm=";
    string notifyUrl = "&notify_url=";
    string custom = "&custom=";
    
    // Merchant account
    sellersEmail += ConfigurationManager.AppSettings["paypalAccount"];
    
    //calling a method that will return current user email id.
    buyersEmail += GeneralClass.GetUserEmail();
    
    //optional value if you want to carry
    custom += GeneralClass.GetUseriD();
    
    productName += lblProdeutName.Text;
    amount +=lblAmount.Text ;
    
    shippingOption += "1";                      //1 means no shipping option;
    noteOpton += "1";                           //1 means no note option;
    rmOption += "1";                            
    
    returnUrl +=ConfigurationManager.AppSettings["websiteUrl"]+"/PaypalThankYou.aspx";
    cancelUrl +=ConfigurationManager.AppSettings["websiteUrl"] + "/PaypalCancel.aspx";
    notifyUrl += ConfigurationManager.AppSettings["websiteUrl"] + "/PaypalNotifyUrl.aspx";
    
    redirectUrl += sellersEmail + buyersEmail + productName + amount + shippingOption +    noteOpton + returnUrl + cancelUrl + notifyUrl + rmOption + custom;
    Response.Redirect(redirectUrl);
    


  • 取消页: - 如果用户取消交易,从paypal.it适用于本地主机也

    谢谢页:付款后,PayPal将重定向到页面

    通知网址:有时它被称为IPN(即时付款通知)。在这里,您将获得来自PayPal的价值的地方。它只能托管页上。 它不会在本地主机工作

    Cancel page:- if user cancel the transaction from paypal.it works for localhost also.
    Thank you page: after payment, paypal will redirect to the page.
    Notify url: sometime its called IPN(Instant Payment notification). This is the place where you will get the value from paypal. it only works on hosted page. it will not work on localhost

    code为 Notifyurl

    添加这些命名空间

     using System.Net;
     using System.IO;
     using System.Text;
     using System.Collections.Specialized;
    

    的Page_Load

      protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
             //Post back to either sandbox or live
            string strURL =ConfigurationManager.AppSettings["paypalURL"]+ "/cgi-bin/webscr";
    
            HttpWebRequest req = (HttpWebRequest)WebRequest.Create(strURL);
    
            //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);
            string strResponse_copy = strRequest;  //Save a copy of the initial info sent by PayPal
            strRequest += "&cmd=_notify-validate";
            req.ContentLength = strRequest.Length;
    
            //for proxy
            //WebProxy proxy = new WebProxy(new Uri("http://url:port#"));
            //req.Proxy = proxy;
            //Send the request to PayPal and get the response
    
            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();
    
            if (strResponse == "VERIFIED")
            {
                //check the payment_status is Completed
                //check that txn_id has not been previously processed
                //check that receiver_email is your Primary PayPal email
                //check that payment_amount/payment_currency are correct
                //process payment
                // pull the values passed on the initial message from PayPal
    
                NameValueCollection these_argies = HttpUtility.ParseQueryString(strResponse_copy);
    
                string pay_stat = these_argies["payment_status"];
    
                //.
                //.  more args as needed look at the list from paypal IPN doc
                //.
    
    
                if (pay_stat.Equals("Completed"))
                {
                //inserting the database
                    int intUserID;
                    int.TryParse(these_argies["custom"],out intUserID);
                    objUserEntity.UserID=intUserID;
                    objPapalPayment.strTransactionID = these_argies["txn_id"];
                    objPapalPayment.dblPaymentAmount = Convert.ToDouble(these_argies["payment_gross"]);
                    objPapalPayment.strBuyerMail = these_argies["payer_email"];
                    objPapalPayment.dtmDateAppliedOn = DateTime.Now;
                    objPapalPayment.blnIsGlobalAdvertisement = true;
                    objSubscription.blnIsPaid = false;
                    objSubscription.blnSubscriptionWithHeld = true;
                    objUserFunction.AddPaypalPayment(objUserEntity, objPapalPayment, objSubscription, enmSubscriptionType.Global);                         
                }
    
    
                // more checks needed here specially your account number and related stuff
            }
            else if (strResponse == "INVALID")
            {
                //log for manual investigation
            }
            else
            {
                //log response/ipn data for manual investigation
            }
            }
        }
    

    那么你将如何在本地主机调试使用 RM 值= 2?;并粘贴在三江源页面的Page_Load事件同样code。它会工作。

    Then how will you debug on the localhost? use rm value =2; and paste the same code in the thankyou page's page_load event. it will work.

    有关更多详细信息:
    http://www.$c$cproject.com/Articles/42894/Introduction-to-PayPal-for-C-ASP-NET-developers

    <一href=\"https://cms.paypal.com/es/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_html_Appx_websitestandard_htmlvariables\"相对=nofollow>宝变量及其用法

    希望,它会帮助你。

    For further details : http://www.codeproject.com/Articles/42894/Introduction-to-PayPal-for-C-ASP-NET-developers
    Paypal variables and its usage
    Hope , it will help you.

    这篇关于沙盒重定向破坏会议的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆