I am try to integrate SagePayMvc.dll
into a ASP.NET Web API project which requires ControllerContext.RequestContext
to be passed in order to form the Notification Url.
Currently I am experiencing some difficulties in achieving this, I need to pass the ControllerContext.RequestContext
from this web api controller:
public class PaymentStartController : ApiController
{
private PaymentRepository paymentRepository = new PaymentRepository();
private SagePayHelper sagePayHelper = new SagePayHelper();
public Order MakePaymentInitial(Payment payment)
{
Order order = new Order();
order = sagePayHelper.MakePayment(payment, context);
paymentRepository.InsertVendorTXCode(order.VendorTxCode);
paymentRepository.InsertInitialPaymentDetails(order, payment);
return order;
}
}
I have tried to add a public ControllerContext controllerContext = new ControllerContext()
below the SagePayHelper instantiation and then subsequently added var context = controllerContext.RequestContext
, the problem with this none of the methods inside RequestContext
are instantiated either so when SagePayMvc arrives at the point of building the Notification Url which is done inside an IUrlResolver
interface an error is thrown.
Is there a way of mocking up ControllerContext.RequestContext
, I have previously used RhinoMocks or would it be more prudent to revert to the way I previously implemented SagePayMvc down in the forms project (the forms project is an MVC 4 application that serializes and sends the form data to the web api).
Any advise would be much appreciated.