2

ASP.netでPayPalを使用しており、サンドボックスでテストしたところすべてが正しかったのですが、ライブパーツを使用すると、次のエラーが発生します。

この支払いは完了できず、アカウントに請求されていません。詳細については、販売者にお問い合わせください。現在、PayPalアカウントを使用してお支払いを処理することはできません。販売者のウェブサイトに戻り、別の支払い方法(利用可能な場合)を使用してみてください。

これは私のwebconfigです

 <add key="token" value="*************************"/>
  <add key="paypalemail" value="*************@gmail.com"/>
  <add key="PayPalSubmitUrl" value="https://www.paypal.com/cgi-bin/webscr"/>
  <add key="FailedURL" value="http://www.stockholmsbygg.net/Failed.aspx"/>
  <add key="SuccessURL" value="http://www.stockholmsbygg.net/FindOpenRequests.aspx"/>
  <add key="Notification" value="http://www.stockholmsbygg.net/Notification.aspx"/>

ペイパルにリダイレクトします

   public static string RedirectToPaypal(string invoiceNumber, string requestId, string userId, string customId, string itemName, string amount)
        {

            string redirecturl = "";
            redirecturl += "https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=" + ConfigurationManager.AppSettings["paypalemail"].ToString();
            redirecturl += "&first_name=" + userId;
            redirecturl += "&item_name=" + itemName;
            redirecturl += "&amount=5.00";
            redirecturl += "&quantity=1";
            redirecturl += "&currency=SEK";
            redirecturl += "&invoice=" + invoiceNumber;
            redirecturl += "&custom=" + requestId;
            redirecturl += "&on0=" + HttpContext.Current.Request.UserHostAddress;
            redirecturl += "&return=" + ConfigurationManager.AppSettings["SuccessURL"].ToString() + "?Type=ShowDetail";
            redirecturl += "&cancel_return=" + ConfigurationManager.AppSettings["FailedURL"].ToString();
            redirecturl += "&notify_url=" + ConfigurationManager.AppSettings["Notification"].ToString();
            return redirecturl;
        }

そしてこれは私がpaypalから私の住所に戻った後に私がチェックするすべてです

if (Request.QueryString["cm"] != null)
                        {

                             const string authToken = "*********************************";
                             string txToken = Request.QueryString["tx"];
                             string query = "cmd=_notify-synch&tx=" + txToken + "&at=" + authToken;

                             //const string strSandbox = "https://www.sandbox.paypal.com/cgi-bin/webscr";
                           string strSandbox = "https://www.paypal.com/cgi-bin/webscr";
                             var req = (HttpWebRequest)WebRequest.Create(strSandbox);

                            req.Method = "POST";
                            req.ContentType = "application/x-www-form-urlencoded";
                             req.ContentLength = query.Length;


                             var streamOut = new StreamWriter(req.GetRequestStream(), System.Text.Encoding.ASCII);
                           streamOut.Write(query);
                           streamOut.Close();
                           var streamIn = new StreamReader(req.GetResponse().GetResponseStream());
                           string strResponse = streamIn.ReadToEnd();
                             streamIn.Close();

                             var results = new Dictionary<string, string>();
                             if (strResponse != "")
                             {
                                 var reader = new StringReader(strResponse);
                                 string line = reader.ReadLine();

                                 if (line == "SUCCESS")
                                 {

                                     while ((line = reader.ReadLine()) != null)
                                     {
                                         results.Add(line.Split('=')[0], line.Split('=')[1]);

                                     }
                                     var userId = Convert.ToInt64(Session["UserID"]);
                                     var item = Convert.ToInt64(Request.QueryString["cm"]);
                                     context = new entities();
                                     var existUser = context.Payments.Where(u => u.UserID == userId).ToList();
                                     var existItem = existUser.Where(i => i.RequestID == item).ToList();
                                     var paypalInvoice = results["invoice"];
                                     var txn_id = results["txn_id"];
                                     var sameInvoice =
                                         existItem.Where(i => i.invoice== paypalInvoice).FirstOrDefault();
                                     if (sameInvoice != null)
                                     {
                                         var currentAmount = Request.QueryString["amt"];
                                         var dbAmount = Convert.ToDecimal(sameInvoice.Amount).ToString();
                                         var currentIp = HttpContext.Current.Request.UserHostAddress;

                                         if (dbAmount != null)
                                         {
                                             if (currentAmount == dbAmount)
                                             {

                                                 if (currentIp == sameInvoice.IP)
                                                 {

                                                     sameInvoice.Status = true;
                                                     sameInvoice.PaypalTX = txn_id;
                                                     pnlSearch.Visible = false;
                                                     pnlShowDetail.Visible = true;
                                                     ShowDetail(Request.QueryString["cm"], true);
                                                     btnBack.Visible = false;
                                                     PrivateDetail.Visible = true;
                                                     interested.Visible = false;
                                                     context.SaveChanges();
                                                 }

                                             }
                                         }


                                     }

                                 }
                                 else if (line == "FAIL")
                                 {
                                     // Log for manual investigation
                                     Response.Write("Unable to retrive transaction detail");
                                 }
                             }
                             else
                             {
                                //unknown error
                                 Response.Write("ERROR");
                             }
                         }

何が問題ですか?また、最初にテストしたときにお金を払いましたが、何も起こりませんでした。請求書のステータスはまだfalseですが、支払いを済ませてからtrueになっているはずです。

4

1 に答える 1

1

この機能は100%エラーですRedirectToPaypal()

ペイパルへのリダイレクトはありません。(リダイレクト)postではなく、投稿パラメーターを使用してそのアドレスに のみあります。get

そして、これは論理的です。なぜなら、そのすべての機密データを URL に配置すると、すべてのデータで URL を保持する中間のエーテル プロキシであるすべての人に公開されるからです。

私にとって、投稿ではなくそのデータでリダイレクトを行うと、投稿データがないため、PayPal はアカウントについて何も見つかりません。そのため、そのエラーが発生します。

于 2012-09-30T15:33:02.197 に答える