public ActionResult AddCardDetail(CardDetail obj)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    xml = "<payment><account-type>credit-card</account-type><credit-card><number>" + obj.cardNumber + "</number><card-type>" + obj.cardType + "</card-type><verification-value>" + obj.verificationValue + "</verification-value><month>" + obj.month + "</month><year>" + obj.year + "</year><first-name>" + obj.firstName + "</first-name><last-name>" + obj.lastName + "</last-name></credit-card></payment>";
                    site = ConfigurationManager.AppSettings["apiUrl"].ToString();
                    url = string.Format("https://subs.pinpayments.com/api/v4/{0}/invoices/", site);
                    string statuscode = Payment(url + obj.token + "/pay.xml", xml, "PUT", obj.token);
                    switch (statuscode)
                    {
                        case "404":
                            ModelState.AddModelError("PaymentError", "Token is invalid please try again");
                            ViewBag.year = DBCommon.BindYear();
                            ViewBag.month = DBCommon.BindMonth();
                            return View();
                            break;
                        case "422":
                            ModelState.AddModelError("PaymentError", "Please enter correct detail");
                            ViewBag.year = DBCommon.BindYear();
                            ViewBag.month = DBCommon.BindMonth();
                            return View();
                            break;
                        case "403":
                            ModelState.AddModelError("PaymentError", "Invoice is already closed");
                            ViewBag.year = DBCommon.BindYear();
                            ViewBag.month = DBCommon.BindMonth();
                            return View();
                            break;
                        case "503":
                            ModelState.AddModelError("PaymentError", "Timeout has been expired");
                            ViewBag.year = DBCommon.BindYear();
                            ViewBag.month = DBCommon.BindMonth();
                            return View();
                            break;

                    }
                    if (statuscode == "404" || statuscode == "422" || statuscode == "422" || statuscode == "403")
                    {
                        ModelState.AddModelError("PaymentError", "");
                    }
                    return View("PaymentSuccess");
                }

                catch (WebException ex)
                {
                    return View("PaymentFail");
                }

            }
            else
            {
                return View("PaymentSuccess", obj);
            }
        }
 public ActionResult AddCardDetail(string firstName, string lastName, string token)
 {
     if (ModelState.IsValid)
     {
         CardDetail obj = new CardDetail();
         obj.token = token;
         obj.firstName = firstName;
         obj.lastName = lastName;
         ViewBag.year = DBCommon.BindYear();
         ViewBag.month = DBCommon.BindMonth();
         return View();
     }
     else
     {
         return View();
     }
 }
 public ActionResult CreateSubscriber(SiteSubscriber obj)
 {
     if (ModelState.IsValid)
     {
         Guid guid = new Guid();
         Random rnmd = new Random();
         PinPaymentsDbEntities db = new PinPaymentsDbEntities();
         if (ModelState.IsValid)
         {
             tblCustomer obtbl = new tblCustomer();
             CustomerModel model = new CustomerModel();
             int cutomerid = model.AddCustomer(obj);
             xml = "<subscriber><customer-id>" + cutomerid + "</customer-id><screen-name>" + obj.FirstName + obj.LastName + "</screen-name></subscriber>";
             site = ConfigurationManager.AppSettings["apiUrl"].ToString();
             url = string.Format("https://subs.pinpayments.com/api/v4/{0}/subscribers.xml", site);
             CreateSubscriberApi(url, xml, "Post");
             CardDetail obj1 = new CardDetail();
             obj1.token = GenrateInvoice(obj.SubscriptionId, cutomerid.ToString(), obj.FirstName, obj.Email);
             obj1.firstName = obj.FirstName;
             obj1.lastName = obj.LastName;
             ViewBag.year = DBCommon.BindYear();
             ViewBag.month = DBCommon.BindMonth();
             return RedirectToAction("AddCardDetail", obj1);
         }
         return View("CreateSubscriber");
     }
     else
     {
         return View(obj);
     }
 }