Payment Plugin for Payfort

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
7 years ago
I've copied the return_url from another plugin.

remotePostHelper.Add("return_url", _webHelper.GetStoreLocation(false) + "Plugins/Payfort/Return");

Sending the return_url as a POST parameter.

Below is the response posted in the URL after redirect by the payment gateway.

http://localhost:15536/Plugins/Payfort/Return?access_code=pkPPdXKvnHyopk6vjtes&card_number=400555******0001&status=13&eci=ECOMMERCE&fort_id=1461148426967&response_code=13666&customer_email=pramilgawande%40gmail.com&customer_name=Aja&customer_ip=103.230.222.194&currency=QAR&merchant_reference=20&amount=131500&response_message=Transaction+declined&command=PURCHASE&payment_option=VISA&language=en&expiry_date=1705&signature=dcd312d05da20fd99d7aec8ece79af99eb7b1f1115b31d68ad770333927dbbf0&merchant_identifier=GYkGcyUM

The above link shows the message Page not found.

Please direct me on how to process the response.

Regards.
7 years ago
Hello,

I'm stuck with the Payment Gateway Integration of Payfort.

Integration type is Redirect type.

So far I've successfully redirected the user to the payment gateway along with the necessary information.

The problem is when the transaction is processed the user is redirected to the store and I'm getting confused in how to handle the response.

Payfort is sending the response as POST parameter on our given link which we need to submit in the settings of Payfort.

My question is which link should be used for getting the POST response...???

Currently I was using the URL: http://mydomain.com/Plugins/Payfort/Return
I was referring the CCAvenue Plugin for development.

Another question is how to handle the response...???

Please give me some hint or clue on how to finish the plugin.

Regards.

Pramil Gawande
+91 7755902019
[email protected]
7 years ago
[email protected] wrote:
...


Hi, Paypal standard is also redirecting after transaction. May be that will help you? It is redirecting on the order details page after transaction.
7 years ago
what kind of response they give after after redirecting to your site?
7 years ago
anik1991 wrote:
what kind of response they give after after redirecting to your site?


After redirection I get a POST response on a URL which I need to save in the settings of Payfort.

I was using the URL: http://mydomain.com/Plugins/Payfort/Return

CCAvenue is also using the same URL for getting the response so I used that. But it's not working for me in Payfort.

Regards.
7 years ago
SuperNopCommerce wrote:
...

Hi, Paypal standard is also redirecting after transaction. May be that will help you? It is redirecting on the order details page after transaction.


I need to give Payfort the URL on which I should receive the POST response from their server.

I've given the URL : http://mydomain.com/Plugins/Payfort/Return

CCAvenue Plugin is also handling the response received on the same URL.

Please advice on how to handle the response.

I've checked the Paypal Standard Plugin. They are using a different route for handling the response. They're using PDTHandler. I'm also going to try the same for handling the response.

Regards.
7 years ago
Yes please try to redirect like Paypal Standard. They uses PDTHandler but you can refer same logic for this as well.
7 years ago
SuperNopCommerce wrote:
Yes please try to redirect like Paypal Standard. They uses PDTHandler but you can refer same logic for this as well.


When I try to handle the response and redirect user to order completed page I get a Page not found error.

I'm doing something wrong.

I'll share the controller file and the Route configuration in the next comment. Can you please help me on that....???
7 years ago
Sure, please post it here.
7 years ago
SuperNopCommerce wrote:
Sure, please post it here.



PaymentPayfortController.cs


[ValidateInput(false)]
        public ActionResult Return(FormCollection form)
        {
            var processor = _paymentService.LoadPaymentMethodBySystemName("Payments.Payfort") as PayfortPaymentProcessor;
            if (processor == null || !processor.IsPaymentMethodActive(_paymentSettings) || !processor.PluginDescriptor.Installed)
                throw new NopException("Payfort module cannot be loaded");

            var myUtility = new PayfortHelper();
            string access_code, amount, command, currency, customer_email, language, languageUpper, merchant_identifier,
                merchant_reference, request_phrase, checksum, signature, response_message, orderId,card_number,customer_ip,
                customer_name,eci,fort_id,payment_option,response_code,status;

            if (String.IsNullOrWhiteSpace(_payfortPaymentSettings.AccessCode))
                throw new NopException("Payfort Access Code is not set");


            

            access_code = Request["access_code"];
            amount = Request["amount"];
            command = Request["command"];
            currency = Request["currency"];
            customer_email = Request["customer_email"];
            language = Request["language"];
            languageUpper = language.ToUpper();
            merchant_identifier = Request["merchant_identifier"];
            merchant_reference = Request["merchant_reference"];
            request_phrase = Request["request_phrase"];
            signature = Request["signature"];
            response_message = Request["response_message"];
            orderId = Request["merchant_reference"];
            card_number=Request["card_number"];
            customer_ip=Request["customer_ip"];
            customer_name=Request["customer_name"];
            eci=Request["eci"];
            fort_id=Request["fort_id"];
            payment_option=Request["payment_option"];
            response_code = Request["response_code"];
            status = Request["status"];

            string response_phrase = _payfortPaymentSettings.SHAResponsePhrase;
            


            //getChecksum(string access_code, string amount, string command, string currency, string customer_email, string language, string merchant_identifier, string merchant_reference, string request_phrase)
            checksum = myUtility.verifySignature(access_code, amount,card_number,command,currency,customer_email,customer_ip,customer_name,eci,fort_id,language,merchant_identifier,merchant_reference,payment_option,response_code,response_message,status,response_phrase);

            if (checksum == signature)
            {

       if(response_message == "Success")
       {
                /*
                    Here you need to put in the routines for a successful
                     transaction such as sending an email to customer,
                     setting database status, informing logistics etc etc
                */


                var order = _orderService.GetOrderById(Convert.ToInt32(orderId));
                if (_orderProcessingService.CanMarkOrderAsPaid(order))
                {
                    _orderProcessingService.MarkOrderAsPaid(order);
                }

                //Thank you for shopping with us. Your credit card has been charged and your transaction is successful
                return RedirectToRoute("CheckoutCompleted", new { orderId = order.Id});
        }
        
        else
        {
          /*
                    Here you need to put in the routines for a failed
                    transaction such as sending an email to customer
                    setting database status etc etc
                */


               return RedirectToAction("Index", "Home", new { area = "" });
        
        }

            }
            
            
            else
            {
                /*
                    Here you need to simply ignore this and dont need
                    to perform any operation in this condition
                */


                return Content("Security Error. Illegal access detected");
            }

        }
    }
}





RouteProvider.cs



//Return
            routes.MapRoute("Plugin.Payments.Payfort.Return",
                 "Plugins/PaymentPayfort/Return",
                 new { controller = "PaymentPayfort", action = "Return" },
                 new[] { "Nop.Plugin.Payments.Payfort.Controllers" }
            );




You can check the POST responses which I received on the below URL:

URL: http://requestb.in/11cy7ru1?inspect

Below are the Payfort settings which are pre-configured on their system:

Host to Host URL(This is where the POST response is sent by Payfort): http://u2basket.com/Plugins/Payfort/Return

Redirection URL: http://u2basket.com/Plugins/Payfort/Return

Notification URL: http://u2basket.com/Plugins/Payfort/Return

Please tell me if you need any more information.

Please help me out on this.

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