So I've been using the Pay Simple SDK. I'm getting this error.
in line . Can anyone know how to solve this??
var customerPayment = new NewCustomerPayment<CreditCard>
I know that Address is not Enum and I think it is the problem, but I don't know what type is that?string?int or something? I cannot modify the model because it's from the SDK. What's the best solution for this?
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();
}
Customer Model
public Address BillingAddress { get; set; }
Address Model class
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; }
}