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.