You can do this with a custom model binder:
public class NotificationModelBinder : DefaultModelBinder
{
public override object BindModel(ControllerContext controllerContext,
ModelBindingContext bindingContext)
{
var model = this.CreateModel(controllerContext,
bindingContext, bindingContext.ModelType);
bindingContext.ModelMetadata.Model = model;
var formValue = bindingContext.ValueProvider
.GetValue(this.FormField).AttemptedValue;
var target = model.GetType().GetProperty(this.FieldToBindTo);
target.SetValue(model, formValue);
// Let the default model binder take care of the rest
return base.BindModel(controllerContext, bindingContext);
}
private readonly string FieldToBindTo = "_3DSecureStatus";
private readonly string FormField = "3DSecureStatus";
}
I've not added an error handling, as this scenario dealing with just 1 string is trivial. Other than the actual value of the string not being something you'd expect, the only other error (well, exception in this case) you could get would be if the target property couldn't be found on your model, but obviously that's a simple fix, too.
Edit: Actually, you could also get an exception for formValue
if the field cannot be found on the form, but again, as this is a 3rd party payment system, I'd be inclined to say that wouldn't change either.
You'd use this like so:
[HttpPost]
public ActionResult Index([ModelBinder(typeof(NotificationModelBinder))]NotificationModel model)
{
// do stuff
}