1

HomeController/Index.cshtml ページは次のとおりです。

<div id="paypalDiv">

        <form id="paypalForm" action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
            <fieldset>
                <p class="inline-small-label" style="padding-top: 7px;">
                    <label for="device-id"><span>User ID</span></label></p>

                <input id="custom" class="full-width" type="text" name="custom" value="">
                <input class="full-width" type="hidden" name="business" value="sampath-facilitator@inexisconsulting.com">
                <input type="hidden" name="cmd" value="_xclick">
                <input type="hidden" name="item_name" value="credits">
                <input type="hidden" name="item_number" value="40">
                <input type="hidden" name="amount" value="2.95">
                <input type="hidden" name="no_shipping" value="1">
                <input type="hidden" name="return" value="http://localhost:13769">
                <input type="hidden" name="notify_url" value="https://localhost:13769/Home/Ipn">
                <button class="btn btn-primary submit-button" type="submit">Pay with PayPal</button>
            </fieldset>

        </form>
    </div>

HomeController/Ipn アクション方法は以下の通り

public ActionResult Ipn()
{
    // Receive IPN request from PayPal and parse all the variables returned
    var formVals = new Dictionary<string, string>();

    formVals.Add("cmd", "_notify-validate");

    // if you want to use the PayPal sandbox change this from false to true
    string response = GetPayPalResponse(formVals, false);

    if (response == "VERIFIED")
    {
        string transactionID = Request["txn_id"];
        string sAmountPaid = Request["mc_gross"];
        string deviceID = Request["custom"];

        //validate the order
        Decimal amountPaid = 0;
        Decimal.TryParse(sAmountPaid, out amountPaid);

        if (sAmountPaid == "2.95")
        {
            // take the information returned and store this into a subscription table
            // this is where you would update your database with the details of the tran

            return View();

        }
        else
        {
            // let fail - this is the IPN so there is no viewer
            // you may want to log something here
        }
    }

    return View();
}

私の質問は、支払いが完了した後でも、上記の Ipn アクション メソッドが起動していません。デバッグできません。どうすればよいですか?

4

2 に答える 2

6

私の記憶が正しければ、IPN はトランザクション後いつでも発生する可能性のある非同期呼び出しです (通常は「即時」ですが、それほど多くない場合もあります)。しかし、これは にアクセスできない PayPal からのものですhttp://localhost。IPN をテストするには、誰でもアクセスできる実際のインターネット サイトに展開する必要があります。IPN で働いてから数年が経ちましたが、それが私の一般的な経験でした。アプリケーションでログを設定し、公開してから、テスト トランザクションを実行します。

編集:

また、WAN IPアドレス(ローカルではない)を与え、ルーターのポートを開き、代わりにそのIPアドレスを使用できると思います(IIS Expressでリモート接続を有効にする必要がある場合があることに注意してください-IIS Expressが外部要求を有効にするを参照してください):

<input type="hidden" name="notify_url" value="https://97.25.43.21:13769/Home/Ipn">
于 2013-07-28T23:39:29.680 に答える