Object Reference Not Set To Instance Of Object

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
9 years ago
All,

My customer is receiving the following error:  Object Reference Not Set To Instance Of Object

http://oi44.tinypic.com/2vbo8s2.jpg

This is Nop 3.0

This error occurs on the final step of checkout.

I've seen this error for another customer and fixed it by finishing out his address properly (I had manually entered it in the database).  In that case, the state was blank.  Filling it in and re-processing the order fixed it.

But in this case, there is no state to enter.  I'm sure the problem is similar, but I don't know how to fix it.

Any ideas?

Thanks in Advance!
9 years ago
Traymond wrote:
All,

My customer is receiving the following error:  Object Reference Not Set To Instance Of Object

http://oi44.tinypic.com/2vbo8s2.jpg

This is Nop 3.0

This error occurs on the final step of checkout.

I've seen this error for another customer and fixed it by finishing out his address properly (I had manually entered it in the database).  In that case, the state was blank.  Filling it in and re-processing the order fixed it.

But in this case, there is no state to enter.  I'm sure the problem is similar, but I don't know how to fix it.

Any ideas?

Thanks in Advance!


This is normally caused by a bug in the payment method. What is the payment method you use? :)
9 years ago
wooncherk wrote:

This is normally caused by a bug in the payment method. What is the payment method you use? :)


Your right!  It does have something to do with the Payment Module.  I had a developer modify the Stripe Payment Plugin to work with 3.0.  Here is the error from the Database Log:

System.NullReferenceException: Object reference not set to an instance of an object.
   at Nop.Plugin.Payments.StripeProcessor.StripeProcessorPaymentProcessor.ProcessPayment(ProcessPaymentRequest processPaymentRequest)
   at Nop.Services.Payments.PaymentService.ProcessPayment(ProcessPaymentRequest processPaymentRequest)
   at Nop.Plugin.NopTools.PaymentDirector.PaymentDirectorPaymentService.ProcessPayment(ProcessPaymentRequest processPaymentRequest)
   at Nop.Services.Orders.OrderProcessingService.PlaceOrder(ProcessPaymentRequest processPaymentRequest)

Obviously the error is in the Payment Module...but I can't seem to find where.  Again, it appears to work in 98 % of all the cases, but I'm guessing it has something to do with the fact that there is no state (customer is in India) given.  Is it possible from the error to find the offending code?  I do have the source code.

Thanks again!
9 years ago
Traymond wrote:

This is normally caused by a bug in the payment method. What is the payment method you use? :)

Your right!  It does have something to do with the Payment Module.  I had a developer modify the Stripe Payment Plugin to work with 3.0.  Here is the error from the Database Log:

System.NullReferenceException: Object reference not set to an instance of an object.
   at Nop.Plugin.Payments.StripeProcessor.StripeProcessorPaymentProcessor.ProcessPayment(ProcessPaymentRequest processPaymentRequest)
   at Nop.Services.Payments.PaymentService.ProcessPayment(ProcessPaymentRequest processPaymentRequest)
   at Nop.Plugin.NopTools.PaymentDirector.PaymentDirectorPaymentService.ProcessPayment(ProcessPaymentRequest processPaymentRequest)
   at Nop.Services.Orders.OrderProcessingService.PlaceOrder(ProcessPaymentRequest processPaymentRequest)

Obviously the error is in the Payment Module...but I can't seem to find where.  Again, it appears to work in 98 % of all the cases, but I'm guessing it has something to do with the fact that there is no state (customer is in India) given.  Is it possible from the error to find the offending code?  I do have the source code.

Thanks again!


"Object reference not set to an instance of an object." means you are trying to access a non-existence object. Since you've stated that 'State' is causing the problem, that means the code didn't check for an EMPTY STATE before it tries to use it. Get your developer to do that check. :)
9 years ago
wooncherk wrote:

"Object reference not set to an instance of an object." means you are trying to access a non-existence object. Since you've stated that 'State' is causing the problem, that means the code didn't check for an EMPTY STATE before it tries to use it. Get your developer to do that check. :)


I suspect this is the line of code causing the issue:

myCharge.CardAddressState = customer.BillingAddress.StateProvince.Abbreviation;

I can put the check for empty State here.  My question is what value does customer.BillingAddress.StateProvince.Abbreviation generate when there is no state (actually, in the user interface, it has a value of "Other (Non US)").  Does it return an empty string "" (or '') or does it return "Nothing" or Null...etc..etc.

I am a developer myself, but not yet familiar with MVC which is why I had another modify the plugin.  But I feel I could fix this most likely.

Thanks
9 years ago
Traymond wrote:

"Object reference not set to an instance of an object." means you are trying to access a non-existence object. Since you've stated that 'State' is causing the problem, that means the code didn't check for an EMPTY STATE before it tries to use it. Get your developer to do that check. :)

I suspect this is the line of code causing the issue:

myCharge.CardAddressState = customer.BillingAddress.StateProvince.Abbreviation;

I can put the check for empty State here.  My question is what value does customer.BillingAddress.StateProvince.Abbreviation generate when there is no state (actually, in the user interface, it has a value of "Other (Non US)").  Does it return an empty string "" (or '') or does it return "Nothing" or Null...etc..etc.

I am a developer myself, but not yet familiar with MVC which is why I had another modify the plugin.  But I feel I could fix this most likely.

Thanks


If you are a developer yourself then this is a C# problem not an MVC problem. Any uninitialized reference type is default to NULL. :)
9 years ago
wooncherk wrote:

If you are a developer yourself then this is a C# problem not an MVC problem. Any uninitialized reference type is default to NULL. :)


Sorry...Figured that...I'm more vb.net than c#, so I have to ask every so often still :)

Thanks for your help.  I'll update the thread once I have fixed the solution!
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.