New Payment Plugin - Redirect

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
12 years ago
Hi Guys

Ok so I am attempting to develop my own redirect payment plugin for www.mygate.co.za
I'm fairly new to MVC so excuse me if i'm way off base!

I have followed the guide and used the paypalstandard plugin for 2.30, but I've gotten a little stuck.

What i have so far is I am posting the data to the mygate website in the PostProcessPayment function and I give them the return url below.

HttpUtility.UrlEncode(_webHelper.GetStoreLocation(false) + "Plugins/PaymenMyGateVirtual/MyGateResultHandler")

MyGateResultHandler is a function in my controller. (See below)

Firstly, would the below work for a successful transaction, and then secondly what do i need to do when the transaction fails. I can't figure it out from the paypal standard one.

What must I route to and how do I present the error messages to the user.



[ValidateInput(false)]
        public ActionResult MyGateResultHandler(FormCollection form)
        {
            int result = Convert.ToInt32(Request["_RESULT"]);
            string errorCode = Request["_ERROR_CODE"];
            string stringerrorSource = Request["_ERROR_SOURCE"];
            string errorMessage = Request["_ERROR_MESSAGE"];
            string errorDetail = Request["_ERROR_DETAIL"];
            int OrderID =  Convert.ToInt32(Request["VARIABLE1"]);
            Order order = _orderService.GetOrderById(OrderID);

            //Success
            if (result == 0)
            {
                
                _orderProcessingService.MarkOrderAsPaid(order);
                _orderService.UpdateOrder(order);
                return RedirectToRoute("CheckoutCompleted");
            }
            //Success with warnings
            else if (result > 0)
            {
              
                _orderProcessingService.MarkOrderAsPaid(order);
                _orderService.UpdateOrder(order);
                return RedirectToRoute("CheckoutCompleted");
            }
            //Failure
            else
            {
                //?????
                return RedirectToRoute("????");
          
  }

        }
12 years ago
any help??
12 years ago
If I were doing this I would do  the following. In the ActionResult for the return result, I would build a model, I always build a model. The model would contain the errorcode, presuming there was one. In my view, I would have a section that output the error and a retry link. In my controller if error was greater that 0 I would do a ModelState.AddError(property,message) or something of the sort. Now depending on what the error was would stem from some step in the checkout. So in  this returnresult model you may have some logic to assess the error and set a RetryLink depending on where the error occured (billing address, shipping address, card number etc). Depending on this, I would do a redirect result to  the controller action that handled the data where the error originated, and let the process continue as if it were their first pass through. If you has say all the cart info, the billing address and the shipping address was where the failure occured, you may need to rebuild the model that is used for shipping address and pass to your redirect result. The basic idea is you have some info about the customer that is not correct, you need to
1. Interpret where the error occurred
2. Redirect the user to the controller that handles the area of input that caused the error.

In Nop you have a session variable for the ProcessPaymentRequest object that is passed to all payment methods. If there is an error you can consume this session variable to rebuild the model pertaining to the point where the user input caused the error, and have them re-populate the values and pass through the workflow no different than if it was the first time through, so show an error, provide some reason why the error occured, and a link to the controller action so that they may correct the issue. After the redirect, they should be in the exact place they were before the error occured "fix your data and move along"
12 years ago
Thanks, that helped a lot.. finally got it working :)
12 years ago
Thanks for writing the MyGate Payment  module.
I was wondering if you could help me.
I have upgraded a client's shopping cart to nopCommerce 2.4 and used your module for MyGate.
It works, but as soon as the price is above 1000, it ads a comma as a thousands sepperator and MyGate complains about the comma :(
I tried formatting settings in nopCommerce - no luck.
The site is at Afrihost so I cannot play with the locale settings of the webserver.
I looked in your source code and saw the line 108
post.Add("txtPrice", postProcessPaymentRequest.Order.OrderTotal.ToString("N2"));
but I dont know how to setup the projet to recompile and it looks as if I dont have all the files.

I saw more than 70 downloads of your plugin and was wondering how others overcome this problem.
12 years ago
Update....
I missed some source files because WinRAR did not extract them all. I used WinZIP and I got all the files and could recompile the code.
In the meantime Brad has adapted the module to work with v 2.5 and it does not produce the comma on some hosts anymore.
Hope this helps if some-one gets stuck.
12 years ago
I have just upgraded from 2.3 to 2.5.  (mygate plugin worked perfectly on v2.3) I installed the latest mygate plugin and am having some problems.
The transaction works all the way through with mygate and gets to the point where you click on the link to return to the main website.  Then it fails with the following message:

We're sorry, an internal error occurred that prevents the request to complete.

Our supporting staff has been notified with this error and will address this issue shortly. We profusely apologize for the inconvenience and for any damage this may cause. You might want to try the same action at later time.

This is the URL that it tries to point to without success.
http://www.m1store.co.za/errorpage.htm?aspxerrorpath=/Plugins/PaymentMyGateVirtual/PaymentResult

Also, the order is still showing as pending instead of paid, so its obviously isnt getting the results back either.

Can anyone help?  Its urgent... :)

The log shows the following:

Short message:

Object reference not set to an instance of an object.



Full message:

System.NullReferenceException: Object reference not set to an instance of an object. at Nop.Plugin.Payments.MyGateVirtual.Controllers.PaymentMyGateVirtualController.MyGateResultHandler(FormCollection form) at lambda_method(Closure , ControllerBase , Object[] ) at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass15.<InvokeActionMethodWithFilters>b__12() at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass15.<>c__DisplayClass17.<InvokeActionMethodWithFilters>b__14() at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters) at System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) at System.Web.Mvc.Controller.ExecuteCore() at System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) at System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) at System.Web.Mvc.MvcHandler.<>c__DisplayClass6.<>c__DisplayClassb.<BeginProcessRequest>b__5() at System.Web.Mvc.Async.AsyncResultWrapper.<>c__DisplayClass1.<MakeVoidDelegate>b__0() at System.Web.Mvc.Async.AsyncResultWrapper.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.End() at System.Web.Mvc.MvcHandler.<>c__DisplayClasse.<EndProcessRequest>b__d() at System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0(Action f) at System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action) at System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) at System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
12 years ago
I just had a simular problem.

Brad built some nice debugging in the code.
It logs the return variables in the backend Log as "Information"
by looking at the variables MyGate returned I could see what was my problem.
Also look for the error in the Log that was logged when the return-page bombed out.
12 years ago
Oops, you did look at the Log.
Ask MyGate Support (Ryan helped me) if they recieved the txttransactionid .
12 years ago
I think the core of the problem is this line:

The TXTNEWTRANSACTIONID parameter to the dataDecryption function is required but was not passed in.]</faultstring> <detail> <ns1:stackTrace xmlns:ns1="http://xml.apache.org/axis/">coldfusion.xml.rpc.CFCInvocationException: [coldfusion.runtime.MissingArgumentException : The TXTNEWTRANSACTIONID parameter to the dataDecryption function is required but was not passed in.] at coldfusion.xml.rpc.CFComponentSkeleton.__createCFCInvocationException(CFComponentSkeleton.java:723)

Any ideas?
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.