Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


These support forums are now closed for new topics and comments.
Please head on over to http://eureka.ucommerce.net/ for support.

  • Adrian Blake 10 posts 40 karma points
    Dec 06, 2013 @ 17:52
    Adrian Blake
    0

    Custom payment service - Payments.cshtml CreatePayment null reference exception

    Hello, I desperately seek help with adding a custom payment service to UCommerce. It seem to see my DLL fine with Payments.cshtml script, my entry Payments.config entry is as follows:

    <!-- Moneris (Canada) --> <component id="Moneris" service="UCommerce.Transactions.Payments.IPaymentMethodService, UCommerce" type="uCommerceMoneris.MonerisPurchase, uCommerceMoneris" />

    However during checkout when i choose the only payment method available that is setup (Moneris, my custom service I added to the backend). I get this error:

    Error Loading Razor Script (file: uCommerce Payment) Object reference not set to an instance of an object.    at uCommerceMoneris.MonerisPurchase.CreatePayment(PaymentRequest request)
      at UCommerce.Transactions.TransactionLibraryInternal.CreatePayment(Int32 paymentMethodId, Decimal amount, Boolean requestPayment, Boolean overwriteExisting)
      at Castle.Proxies.TransactionLibraryInternalProxy.CreatePayment_callback(Int32 paymentMethodId, Decimal amount, Boolean requestPayment, Boolean overwriteExisting)
      at Castle.Proxies.Invocations.TransactionLibraryInternal_CreatePayment.InvokeMethodOnTarget()
      at Castle.DynamicProxy.AbstractInvocation.Proceed()
      at UCommerce.Infrastructure.Interceptor.ExceptionLoggingInterceptor.Intercept(IInvocation invocation)
      at Castle.DynamicProxy.AbstractInvocation.Proceed()
      at Castle.Proxies.TransactionLibraryInternalProxy.CreatePayment(Int32 paymentMethodId, Decimal amount, Boolean requestPayment, Boolean overwriteExisting)
      at UCommerce.Api.TransactionLibrary.CreatePayment(Int32 paymentMethodId, Decimal amount, Boolean requestPayment, Boolean overwriteExisting)
      at ASP._Page_macroScripts_uCommerce_Payment_cshtml.Execute() in d:\Virtuals\cybertekssystems_com\ktfloral_ca\Web\MacroScripts\uCommerce\Payment.cshtml:line 15
      at System.Web.WebPages.WebPageBase.ExecutePageHierarchy()
      at System.Web.WebPages.WebPage.ExecutePageHierarchy(IEnumerable`1 executors)
      at System.Web.WebPages.WebPage.ExecutePageHierarchy()
      at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage)
      at umbraco.MacroEngines.RazorMacroEngine.ExecuteRazor(MacroModel macro, INode currentPage)
      at umbraco.MacroEngines.RazorMacroEngine.Execute(MacroModel macro, INode currentPage)

    Error loading MacroEngine script (file: uCommerce/Payment.cshtml, Type: ''
    Object reference not set to an instance of an object.
      at uCommerceMoneris.MonerisPurchase.CreatePayment(PaymentRequest request)
      at UCommerce.Transactions.TransactionLibraryInternal.CreatePayment(Int32 paymentMethodId, Decimal amount, Boolean requestPayment, Boolean overwriteExisting)
      at Castle.Proxies.TransactionLibraryInternalProxy.CreatePayment_callback(Int32 paymentMethodId, Decimal amount, Boolean requestPayment, Boolean overwriteExisting)
      at Castle.Proxies.Invocations.TransactionLibraryInternal_CreatePayment.InvokeMethodOnTarget()
      at Castle.DynamicProxy.AbstractInvocation.Proceed()
      at UCommerce.Infrastructure.Interceptor.ExceptionLoggingInterceptor.Intercept(IInvocation invocation)
      at Castle.DynamicProxy.AbstractInvocation.Proceed()
      at Castle.Proxies.TransactionLibraryInternalProxy.CreatePayment(Int32 paymentMethodId, Decimal amount, Boolean requestPayment, Boolean overwriteExisting)
      at UCommerce.Api.TransactionLibrary.CreatePayment(Int32 paymentMethodId, Decimal amount, Boolean requestPayment, Boolean overwriteExisting)
      at ASP._Page_macroScripts_uCommerce_Payment_cshtml.Execute() in d:\Virtuals\cybertekssystems_com\ktfloral_ca\Web\MacroScripts\uCommerce\Payment.cshtml:line 15
      at System.Web.WebPages.WebPageBase.ExecutePageHierarchy()
      at System.Web.WebPages.WebPage.ExecutePageHierarchy(IEnumerable`1 executors)
      at System.Web.WebPages.WebPage.ExecutePageHierarchy()
      at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage)
      at umbraco.MacroEngines.RazorMacroEngine.ExecuteRazor(MacroModel macro, INode currentPage)
      at umbraco.MacroEngines.RazorMacroEngine.Execute(MacroModel macro, INode currentPage)
      at umbraco.macro.loadMacroScript(MacroModel macro)
      at umbraco.macro.renderMacro(Hashtable pageElements, Int32 pageId)

    This is my DLL with the class which implements IPaymentFactory, IPaymentMethodService for the service:

    namespace uCommerceMoneris

    {

        public class MonerisPurchase : IPaymentFactory, IPaymentMethodService

        {

            public string Name { get; set; }

            ///

            /// Creates a new payment fully initialized

            ///

            ///

            ///

            public Payment CreatePayment(PaymentRequest request)

            {

                PurchaseOrder order = request.PurchaseOrder;

                var payment = new Payment

                {

                    TransactionId = Guid.NewGuid().ToString(),

                    PaymentMethodName = request.Payment.PaymentMethodName,

                    Created = DateTime.Now,

                    Fee = CalculatePaymentFee(request).Value,

                    FeePercentage = request.PaymentMethod.FeePercent,

                    Amount = request.Amount.Value

                };

                return payment;

            }

     

    Does annyone have any ideas what's going on here? I've seen similar issues and tried everything I've found in the forums to no avail. Version info: Umbraco 6.1.6 and uCommerce 4.0.3.13287


    Thanks!

  • Jesper Nielsen 141 posts 498 karma points
    Dec 09, 2013 @ 13:00
    Jesper Nielsen
    0

    Hi Adrian,

    I am guessing a little bit, since you havent specifed exactly which line throws the exception. I am guessing it is
    "PaymentMethodName = request.Payment.PaymentMethodName".

    It looks like you are trying to access the payment you are currently in the process of creating. The request does not have a payment yet.

    Instead you should get the payment method from the payment request object. It has a PaymentMethod property.

    Something like "PaymentMethodName = request.PaymentMethod,Name"?

    Kind regards,

    Jesper

  • Adrian Blake 10 posts 40 karma points
    Dec 09, 2013 @ 17:40
    Adrian Blake
    0

    I don't know how to get the line number, could you please tell me where would it say that? It seems that no matter what CreatePayment will never work even if it is just Console.WriteLine("test") for debugging purpoes I tried that and still had problems.

  • Jesper Nielsen 141 posts 498 karma points
    Dec 10, 2013 @ 13:02
    Jesper Nielsen
    0

    Hi Adrian,

    If the assembly was build in "debug" target, the exception should contain line number information, if you deploy the ".pdb" file along with the assembly to the bin folder.

    If you are using Visual Studio, you can try and debug the application.

    1. In the menu: Debug -> Attach to Process
    2. Select the process "w3wp.exe"
    3. Set at break point in the first line in your method
    4. Generate the payment.

    Kind regards,

    Jesper

Please Sign in or register to post replies

Write your reply to:

Draft