Getting ths error when I'm going to create a payment.. what do you think cause this?? I already checked the view and model..
Controller:
[HttpPost]
[ValidateAntiForgeryToken]
public async System.Threading.Tasks.Task<ActionResult> Create(FormCollection formCollection)
{
string username = "asa";
string apiKey = "as";
string baseUrl = "https://sandbox-api.paysimple.com";
var settings = new PaySimpleSdk.Models.PaySimpleSettings(apiKey, username, baseUrl);
var paymentService = new PaymentService(settings);
var customerPayment = new NewCustomerPayment<CreditCard>
{
Customer = new Customer
{
FirstName = formCollection["FirstName"],
LastName = formCollection["LastName"],
BillingAddress =
{
StreetAddress1 = formCollection["StreetAddress1"],
StreetAddress2 = formCollection["StreetAddress2"],
City = formCollection["City"],
StateCode = (StateCode)Enum.Parse(typeof(StateCode), formCollection["StateCode"]),
Country = (CountryCode)Enum.Parse(typeof(CountryCode), formCollection["Country"]),
ZipCode = formCollection["ZipCode"]
}
},
Account = new CreditCard
{
CreditCardNumber = formCollection["CreditCardNumber"],
ExpirationDate = formCollection["ExpirationDate"],
Issuer = (Issuer)Enum.Parse(typeof(Issuer), formCollection["Issuer"])
},
Payment = new Payment
{
Amount = int.Parse(formCollection["Amount"]),
Cvv = formCollection["Ccv"]
}
};
var newCustomerPayment = await paymentService.CreateNewCustomerPaymentAsync(customerPayment);
return View();
}
My Model from SDK
Customer
[JsonProperty("FirstName")]
public string FirstName { get; set; }
[JsonProperty("LastName")]
public string LastName { get; set; }
[JsonProperty("BillingAddress")]
public Address BillingAddress { get; set; }
Address that link in Customer Billing Address
[JsonProperty("StreetAddress1")]
public string StreetAddress1 { get; set; }
[JsonProperty("StreetAddress2")]
public string StreetAddress2 { get; set; }
[JsonProperty("City")]
public string City { get; set; }
[JsonProperty("StateCode"), JsonConverter(typeof(TypeEnumConverter<StateCode, BiLookup<StateCode, string>>))]
public StateCode? StateCode { get; set; }
[JsonProperty("ZipCode")]
public string ZipCode { get; set; }
[JsonProperty("Country"), JsonConverter(typeof(TypeEnumConverter<CountryCode, BiLookup<CountryCode, string>>))]
public CountryCode? Country { get; set; }
Model of Account Credit Card
[JsonProperty("CreditCardNumber")]
public string CreditCardNumber { get; set; }
[JsonProperty("ExpirationDate")]
public string ExpirationDate { get; set; }
[JsonProperty("Issuer")]
Model for payment
[JsonProperty("Amount")]
public decimal Amount { get; set; }
[JsonProperty("CVV")]
public string Cvv { get; set; }
My View
@model WebApplication16.Model.ParentModel
@{
ViewBag.Title = "Create";
Layout = "~/Views/Shared/_Layout.cshtml";
}
Create
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="form-horizontal">
<h4>ParentModel</h4>
<hr />
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<div class="form-group">
<div class="form-group">
@Html.LabelFor(model => model.Customer.FirstName, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Customer.FirstName, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Customer.FirstName, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Customer.LastName, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Customer.LastName, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Customer.LastName, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Customer.BillingAddress.StreetAddress1, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Customer.BillingAddress.StreetAddress1, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Customer.BillingAddress.StreetAddress1, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Customer.BillingAddress.StreetAddress2, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Customer.BillingAddress.StreetAddress2, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Customer.BillingAddress.StreetAddress2, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Customer.BillingAddress.City, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Customer.BillingAddress.City, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Customer.BillingAddress.City, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Customer.BillingAddress.StateCode, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Customer.BillingAddress.StateCode, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Customer.BillingAddress.StateCode, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Customer.BillingAddress.Country, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Customer.BillingAddress.Country, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Customer.BillingAddress.Country, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Customer.BillingAddress.ZipCode, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Customer.BillingAddress.ZipCode, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Customer.BillingAddress.ZipCode, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.CreditCard.CreditCardNumber, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.CreditCard.CreditCardNumber, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.CreditCard.CreditCardNumber, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.CreditCard.ExpirationDate, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.CreditCard.ExpirationDate, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.CreditCard.ExpirationDate, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.CreditCard.Issuer, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.CreditCard.Issuer, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.CreditCard.Issuer, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Payment.Amount, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Payment.Amount, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Payment.Amount, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Payment.Cvv, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Payment.Cvv, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Payment.Cvv, "", new { @class = "text-danger" })
</div>
</div>
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Create" class="btn btn-default" />
</div>
</div>
</div>
}
<div>
@Html.ActionLink("Back to List", "Index")
</div>