PayPal IPN Handler Exception Error

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
15 年 前
I am getting the following exception error with relation to PayPalIPNHandler.aspx:


Message:  
Exception of type 'System.Web.HttpUnhandledException' was thrown.

Exception:
System.Web.HttpUnhandledException: Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary. at System.ThrowHelper.ThrowKeyNotFoundException() at System.Collections.Generic.Dictionary`2.get_Item(TKey key) at NopSolutions.NopCommerce.Web.PaypalIPNHandlerPage.Page_Load(Object sender, EventArgs e) in F:\Own\NopCommerce\Solution\Solution\NopCommerceStore\PaypalIPNHandler.aspx.cs:line 55 at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) at System.Web.UI.Control.OnLoad(EventArgs e) at NopSolutions.NopCommerce.Web.BaseNopPage.OnLoad(EventArgs e) in F:\Own\NopCommerce\Solution\Solution\NopCommerceStore\Controls\BaseNopPage.cs:line 109 at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) --- End of inner exception stack trace --- at System.Web.UI.Page.HandleError(Exception e) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest() at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) at System.Web.UI.Page.ProcessRequest(HttpContext context) at ASP.paypalipnhandler_aspx.ProcessRequest(HttpContext context) at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)  


Any ideas on what is causing this error.
15 年 前
Any help on this.

I think that this is occuring because customers have left PayPal and cancelled without paying.  Can anyone shed some light on this.

It seems to occur when the customer has clicked to pay with PayPal, but changed their minds once redirected to PayPal.
15 年 前
This is the Server error that is being thrown when navigating to PayPayIPNHandler.aspx


Description:
An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details:
System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.

Stack Trace:
[KeyNotFoundException: The given key was not present in the dictionary.]
   System.ThrowHelper.ThrowKeyNotFoundException() +28
   System.Collections.Generic.Dictionary`2.get_Item(TKey key) +7455996
   NopSolutions.NopCommerce.Web.PaypalIPNHandlerPage.Page_Load(Object sender, EventArgs e) in F:\Own\NopCommerce\Solution\Solution\NopCommerceStore\PaypalIPNHandler.aspx.cs:100
   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
   System.Web.UI.Control.OnLoad(EventArgs e) +99
   NopSolutions.NopCommerce.Web.BaseNopPage.OnLoad(EventArgs e) in F:\Own\NopCommerce\Solution\Solution\NopCommerceStore\Controls\BaseNopPage.cs:109
   System.Web.UI.Control.LoadRecursive() +50
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627
15 年 前
What version of nopCommerce are you using? From the exceptions, it looks like version 1.40.

The error shouldn't occur in version 1.50 because PaypalIPNHandler.aspx.cs now uses a different way to access the dictionary values (via Dictionary.TryGetValue() and try/catch) instead of direct access to the dictionary values via the key (the exception is thrown because the key doesn't exist in the dictionary).

.
15 年 前
We are using version 1.4

Is there any way to fix it?
15 年 前
Zathus wrote:
We are using version 1.4

Is there any way to fix it?


You could update to version 1.50. However, if you have to stay with version 1.40, you can fix this by editing file: PaypalIPNHandler.aspx.cs and recompiling the solution.

Change lines 54-55 from:

    decimal total = decimal.Parse(values["mc_gross"], new CultureInfo("en-US"));
    string orderNumber = values["custom"];

to:
 
    decimal total = decimal.Zero;
    try
    {
        total = decimal.Parse(values["mc_gross"], new CultureInfo("en-US"));
    }
    catch { }
    string orderNumber = string.Empty;
    values.TryGetValue("custom", out orderNumber);


And change line 100 (now line 106 with above changes) from:

    string orderNumber = values["custom"];

to:

    string orderNumber = string.Empty;
    values.TryGetValue("custom", out orderNumber);


This is for nopCommerce 1.40 and you will need to recompile the solution. I don't use PayPal so I can only verify part of the fix (the part at line 106) by opening the page PaypalIPNHandler.aspx on a web server (without an order from PayPal).

.
15 年 前
I have rebuilt the solution.  Which files do I need to replace?  I know that I need to replace the PayPalIPNHandler.aspx.cs file.  Are there any others?
15 年 前
Zathus wrote:
I have rebuilt the solution.  Which files do I need to replace?  I know that I need to replace the PayPalIPNHandler.aspx.cs file.  Are there any others?


You don't need any .cs files on your server, just upload the new NopCommerceStore.dll to the bin/ folder (backup the existing NopCommerceStore.dll file first ->rename existing NopCommerceStore.dll to NopCommerceStore.dll.old).

.
15 年 前
Thanks for that mb.

I have tested accessing the url and that now works.  I will now need to see if I get any more messages from PayPal about the IPN Handler.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.