JeremySkinner / SagePayMvc

ASP.NET MVC Integration for SagePay
Apache License 2.0
31 stars 31 forks source link

5006 : Unable to redirect to Vendors web site. #21

Closed kirushan closed 5 years ago

kirushan commented 8 years ago

Hi,

I have followed you SagePayMvc Project. I have configured the Notification URL as well. 5006 : Unable to redirect to Vendors web site. gets thrown after trying to authorize.. Could you please guide me with this.

My web Config.....


<sagePay>
  <!-- The public-facing hostname that SagePay can use to contact the site -->
  <add key="NotificationHostName" value="xxxxxxxxx" />
  <!-- The protocol defaults to http, but you can override that to https with the following setting -->
   <add key="Protocol" value="http" /> 
  <!-- Your notification controller -->
  <add key="NotificationController" value="PaymentResponse" />
  <!-- Your notification action. These three settings together are used to build the notification URL -->
  <!-- EG: http://my.external.hostname/PaymentResponse/Notify -->
  <add key="NotificationAction" value="Notify" />
  <!-- Action names for URLS that the user will be directed to after payment either succeeds or fails -->
  <!-- The URL is constructed from the notificationHostName and NotificationController. -->
  <!-- Eg: http://my.external.hostname/PaymentResponse/Success -->
  <add key="SuccessAction" value="Success" />
  <add key="FailedAction" value="Failed" />

  <!-- VAT multiplier. Currently at 20% -->
  <add key="VatMultiplier" value="1" />
  <!-- Name of vendor. You will need to change this -->
  <add key="VendorName" value="xxxxxxx" />
  <!-- Simulator, Test or Live -->
  <add key="Mode" value="Test" />
</sagePay>

My Payment Response Controller as Follows....

 public class PaymentResponseController : Controller
    {
        IOrderRepository _orderRepository;

        public PaymentResponseController(IOrderRepository orderRepository)
        {
            _orderRepository = orderRepository;
        }

        public ActionResult Notify(SagePayResponse response)
        {
            // SagePay should have sent back the order ID
            if (string.IsNullOrEmpty(response.VendorTxCode))
            {
                return new ErrorResult();
            }

            // Get the order out of our "database"
            var order = _orderRepository.GetById(response.VendorTxCode);

            // IF there was no matching order, send a TransactionNotfound error
            if (order == null)
            {
                return new TransactionNotFoundResult(response.VendorTxCode);
            }

            // Check if the signature is valid.
            // Note that we need to look up the vendor name from our configuration.
            if (!response.IsSignatureValid(order.SecurityKey, SagePayMvc.Configuration.Current.VendorName))
            {
                return new InvalidSignatureResult(response.VendorTxCode);
            }

            // All good - tell SagePay it's safe to charge the customer.
            return new ValidOrderResult(order.VendorTxCode, response);
        }

        public ActionResult Failed(string vendorTxCode)
        {
            return View();
        }

        public ActionResult Success(string vendorTxCode)
        {
            return View();
        }
    }
JeremySkinner commented 8 years ago

Is your NotificationHostname set correctly? Have you done a trace using fiddler to see the what value you're sending back for success/failure urls?

On Monday, 25 July 2016, kirushan notifications@github.com wrote:

Hi,

I have followed you SagePayMvc Project. I have configured the Notification URL as well. 5006 : Unable to redirect to Vendors web site. gets thrown after trying to authorize.. Could you please guide me with this.

My web Config.....

My Payment Response Controller as Follows....

public class PaymentResponseController : Controller { IOrderRepository _orderRepository;

    public PaymentResponseController(IOrderRepository orderRepository)
    {
        _orderRepository = orderRepository;
    }

    public ActionResult Notify(SagePayResponse response)
    {
        // SagePay should have sent back the order ID
        if (string.IsNullOrEmpty(response.VendorTxCode))
        {
            return new ErrorResult();
        }

        // Get the order out of our "database"
        var order = _orderRepository.GetById(response.VendorTxCode);

        // IF there was no matching order, send a TransactionNotfound error
        if (order == null)
        {
            return new TransactionNotFoundResult(response.VendorTxCode);
        }

        // Check if the signature is valid.
        // Note that we need to look up the vendor name from our configuration.
        if (!response.IsSignatureValid(order.SecurityKey, SagePayMvc.Configuration.Current.VendorName))
        {
            return new InvalidSignatureResult(response.VendorTxCode);
        }

        // All good - tell SagePay it's safe to charge the customer.
        return new ValidOrderResult(order.VendorTxCode, response);
    }

    public ActionResult Failed(string vendorTxCode)
    {
        return View();
    }

    public ActionResult Success(string vendorTxCode)
    {
        return View();
    }
}

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/JeremySkinner/SagePayMvc/issues/21, or mute the thread https://github.com/notifications/unsubscribe-auth/AAFgEvz11x7TnUnAEuVZMzSuu6ee3IuZks5qZJcbgaJpZM4JUAl8 .

kirushan commented 8 years ago

My URL goes as ubtfront.azurewebsites.net.... I haven't tested using fiddler.. I will check on it and get back to you.

<sagePay>
  <!-- The public-facing hostname that SagePay can use to contact the site -->
  <add key="NotificationHostName" value="**ubtfront.azurewebsites.net**" />
  <!-- The protocol defaults to http, but you can override that to https with the following setting -->
   <add key="Protocol" value="http" /> 
  <!-- Your notification controller -->
  <add key="NotificationController" value="PaymentResponse" />
  <!-- Your notification action. These three settings together are used to build the notification URL -->
  <!-- EG: http://my.external.hostname/PaymentResponse/Notify -->
  <add key="NotificationAction" value="Notify" />
  <!-- Action names for URLS that the user will be directed to after payment either succeeds or fails -->
  <!-- The URL is constructed from the notificationHostName and NotificationController. -->
  <!-- Eg: http://my.external.hostname/PaymentResponse/Success -->
  <add key="SuccessAction" value="Success" />
  <add key="FailedAction" value="Failed" />

  <!-- VAT multiplier. Currently at 20% -->
  <add key="VatMultiplier" value="1" />
  <!-- Name of vendor. You will need to change this -->
  <add key="VendorName" value="xxxxxxx" />
  <!-- Simulator, Test or Live -->
  <add key="Mode" value="Test" />
</sagePay>