0

トライアル用のペイパル用のサンドボックスアカウントを持っていますaspxpage:sampleprocess.aspx

Merchant A / cでは 、支払いが完了すると、ページはhttp://www.Hostsite.com/member/samplepaypal.aspxにリダイレクトされます。

samplepaypal.aspx.csページの読み込み:

protected void Page_Load(object sender, EventArgs e)
    {
        //string tx = Request.QueryString["tx"];
        //Post back to either sandbox or live
        string strSandbox = "https://www.sandbox.paypal.com/cgi-bin/webscr";
        string strLive = "https://www.paypal.com/cgi-bin/webscr";
        HttpWebRequest req = (HttpWebRequest)WebRequest.Create(strSandbox);

        //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;

        //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")
        {
            lblmsg.Text = "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
        }
        else if (strResponse == "INVALID")
        {
            lblmsg.Text = "Not Verified";
            //log for manual investigation
        }
        else
        {
            lblmsg.Text = "IPN Logged";
            //log response/ipn data for manual investigation
        }
    }

ここで、「INVALID」という結果が得られます。何が間違っているplzはエラーを修正します。ペイパルからhttp://www.Hostsite.com/member/samplepaypal.aspxページに投稿して戻った後、次のように表示されます。

http://111.111.111.111/member/samplepaypal.aspx?tx=8L903541KW5338647&st=Pending&amt=100.00&cc=USD&**cm=&item_number=&**sig=QRmNHFf5%2fAH3io9Tn2kj%2fuicu3gpAuMew701OvazfkCdN3jSR5tmFoX3OUPbQlZGoj2PY7vI%2fP1dH84g1CEzSG9NhjnLbjuAFFHyENVsBjKb1dVvK1nZe3FJfElZt11qPfggMOPu8%2bUhDwHekJvNAcXkjLQV01vAjN1y%2fZs1rJw%3d

これらのcmとitem_numberは何ですか?空白です!「有効な」応答を取得するために何をすべきか。

感謝するのを手伝ってください..!

4

1 に答える 1

1

検証のためのポストバックの使用:

通知の検証に共有シークレットを使用できない場合は、代わりにPayPalへのポストバックを使用できます。ポストバックには、PayPalによってサーバーに投稿されたIPNで受け取る変数と値がまったく同じである必要があり、それらは同じ順序である必要があります。

ポストバックの構築

PayPalへのポストバックを作成するには、次のガイドラインを使用してください。

  1. ポストバックはhttps://www.paypal.com/cgi-bin/webscrに送信する必要があります。注:検証用のポストバックを含め、SSLなしでIPNを実装できますが、PayPalではそうしないことをお勧めします。

  2. ポストバックには、値が_notify-validateの変数cmdが含まれている必要があります。cmd= _notify-validate

  3. ポストバックには、PayPalからIPNで受け取る変数と値がまったく同じである必要があり、それらは同じ順序である必要があります。

ポストバックへのPayPal応答の処理PayPalは、応答の本文にVERIFIEDまたはINVALIDという1つの単語を使用してポストバックに応答します。VERIFIEDポストバック応答を受信したら、IPN内のデータに対して次のチェックを実行します。

  1. payment_statusが完了していることを確認します。

  2. Payment_statusが完了した場合は、txn_idを前に処理したPayPalトランザクションと照合して、重複していないことを確認します。

  3. Receiver_emailがPayPalアカウントに登録されているメールアドレスであることを確認してください。

  4. Check that the price, carried in mc_gross, and the currency, carried in mc_currency, are correct for the item, carried in item_name or item_number. After you complete the above checks, notification validation is complete. You can update your database with the information provided, and you can initiate other appropriate automated back-end processing.

于 2012-09-10T12:43:00.923 に答える