So I've been using the Pay Simple SDK. I'm getting this error. Does anyone know how to solve this?
var customerPayment = new NewCustomerPayment<CreditCard>
So my model is in the Pay Simple SDK. This is for Payment Transaction.
Controller code:
[HttpPost]
[ValidateAntiForgeryToken]
public async System.Threading.Tasks.Task<ActionResult> Create(FormCollection formCollection) {
string username = "jnjk";
string apiKey = "khkh";
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 = (Address)Enum.Parse(typeof(Address), formCollection["BillingAddress"])
},
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();
}
Model from sdk
This is The Billing Address in the Customer Model..
public Address BillingAddress { get; set; }
This is for Address
public class Address : IValidatable
{
public Address();
public string City { get; set; }
public CountryCode? Country { get; set; }
public StateCode? StateCode { get; set; }
public string StreetAddress1 { get; set; }
public string StreetAddress2 { get; set; }
public string ZipCode { get; set; }
}
Are you sure Address
and Issuer
are enums? They sound like classes to me. Enum.Parse(Type enumType, string value)
throws an exception if enumType
is not an enum-type.