Help on new Payment Method - nullException

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
13 years ago
I am new to NopCommerce and have been trying to create a new payment gateway.

I simply replicated PayInStore payment method and renamed it to NewPayment to have a baseline which I will edit later on. However doing so, I still received a null Exception:

Value cannot be null.
Parameter name: type
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.ArgumentNullException: Value cannot be null.
Parameter name: type

Source Error:

Line 533:            if (paymentMethod == null)
Line 534:                return decimal.Zero;
Line 535:            var iPaymentMethod = Activator.CreateInstance(Type.GetType(paymentMethod.ClassName)) as IPaymentMethod;
Line 536:            
Line 537:            decimal result = iPaymentMethod.GetAdditionalHandlingFee();


Source File: C:\Users\ritchieanxa\Documents\Visual Studio 2010\Projects\nopCommerce_1.90_Source\Libraries\Nop.BusinessLogic\Payment\PaymentService.cs    Line: 535

Stack Trace:

[ArgumentNullException: Value cannot be null.
Parameter name: type]
   System.Activator.CreateInstance(Type type, Boolean nonPublic) +9643414
   System.Activator.CreateInstance(Type type) +6
   NopSolutions.NopCommerce.BusinessLogic.Payment.PaymentService.GetAdditionalHandlingFee(Int32 paymentMethodId) in C:\Users\ritchieanxa\Documents\Visual Studio 2010\Projects\nopCommerce_1.90_Source\Libraries\Nop.BusinessLogic\Payment\PaymentService.cs:535
   NopSolutions.NopCommerce.Web.Modules.CheckoutPaymentMethodControl.FormatPaymentMethodInfo(PaymentMethod paymentMethod) in C:\Users\ritchieanxa\Documents\Visual Studio 2010\Projects\nopCommerce_1.90_Source\NopCommerceStore\Modules\CheckoutPaymentMethod.ascx.cs:50
   ASP.modules_checkoutpaymentmethod_ascx.__DataBind__control4(Object sender, EventArgs e) in c:\Users\ritchieanxa\Documents\Visual Studio 2010\Projects\nopCommerce_1.90_Source\NopCommerceStore\Modules\CheckoutPaymentMethod.ascx:20
   System.Web.UI.Control.OnDataBinding(EventArgs e) +91
   System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +92
   System.Web.UI.Control.DataBind() +15
   System.Web.UI.Control.DataBindChildren() +201
   System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +101
   System.Web.UI.Control.DataBind() +15
   System.Web.UI.WebControls.DataList.CreateItem(Int32 itemIndex, ListItemType itemType, Boolean dataBind, Object dataItem) +137
   System.Web.UI.WebControls.DataList.CreateControlHierarchy(Boolean useDataSource) +488
   System.Web.UI.WebControls.BaseDataList.OnDataBinding(EventArgs e) +64
   System.Web.UI.WebControls.BaseDataList.DataBind() +55
   NopSolutions.NopCommerce.Web.Modules.CheckoutPaymentMethodControl.BindData() in C:\Users\ritchieanxa\Documents\Visual Studio 2010\Projects\nopCommerce_1.90_Source\NopCommerceStore\Modules\CheckoutPaymentMethod.ascx.cs:309
   NopSolutions.NopCommerce.Web.CheckoutPaymentMethodPage.Page_Load(Object sender, EventArgs e) in C:\Users\ritchieanxa\Documents\Visual Studio 2010\Projects\nopCommerce_1.90_Source\NopCommerceStore\CheckoutPaymentMethod.aspx.cs:60
   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) +91
   NopSolutions.NopCommerce.Web.BaseNopFrontendPage.OnLoad(EventArgs e) in C:\Users\ritchieanxa\Documents\Visual Studio 2010\Projects\nopCommerce_1.90_Source\NopCommerceStore\Controls\BaseNopFrontendPage.cs:147
   System.Web.UI.Control.LoadRecursive() +74
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2207

Here is what I did:
1) Created NewPayment template, PaymentModule.ascx, PaymentModule.ascx.cs
2) Under Administration > Payment, I created NewPayment folder with ConfigurePaymentMethod.ascx and ConfigurePaymentMethod.ascx.cs
3) Under Payment class folder I created Nop.Payment.NewPayment with NewPaymentProcessor.cs and AssemblyInfo.cs

Would appreciate any help you can give me.

Thank you in advance!
13 years ago
Hiya have you read all the other posts that tell you how to do this ?
A
13 years ago
Yes I have read all the posts but unfortunately it is still returning a NullException.
13 years ago
I have actually followed everything in this thread but I'm still getting an error:
https://www.nopcommerce.com/boards/t/2891/how-to-code-my-own-payment-method.aspx
13 years ago
The same error occurred upon installing NBePay: https://www.nopcommerce.com/p/157/nbepay-payment-module-malaysia.aspx
13 years ago
greenapple wrote:
I have actually followed everything in this thread but I'm still getting an error:
https://www.nopcommerce.com/boards/t/2891/how-to-code-my-own-payment-method.aspx


1. Seems that you missed step 8 described in this thread ("In the NopCommerceStore project, add reference to the new MyCustomPayment project.")
2. You could also type a wrong 'Class name' field on the "Payment Methods" page (admin area)
13 years ago
I actually did all of this on the admin area.

Configuration template path: Payment\NBePay\ConfigurePaymentMethod.ascx
User template path: ~\Templates\Payment\NBePay\PaymentModule.ascx
Class name: NopSolutions.NopCommerce.Payment.Methods.NBePay.NBePayPaymentProcessor, Nop.Payment.NBePay

The null exception occurs when I make the payment method visible.

On another note, I just found out that NBePay supports nopCommerce 1.80 wherein I am using 1.90. Could this be the problem? That being said, even if I simply PayInStore payment method which should work for 1.90, I still get the same error.

Help please...
13 years ago
Are you sure that you added 'Nop.Payment.NBePay' assembly as a reference to 'NopCommerceStore' project?

IPaymentMethod interface is the same in 1.80 and 1.90, so no code changes are required. Did you recompile the solution?
13 years ago
Yes to both. I even recompiled the 'Nop.Payment.NBePay' class individually.
13 years ago
Upload your solution somewhere and share a link here. I'll have a look
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.