/// <summary> /// Reload UserWallet via Credit Card /// </summary> /// <param name="context">DBContext of Model to be used</param> /// <param name="userId">Owner of wallet to be reloaded. Wallet to be used is the one with currency the same as the user's current country.</param> /// <param name="transaction">CreditCardReloadTransaction filled up with the ff properties filled up: Amount, Currency, Date</param> /// <param name="cardInfo">Credit Card information</param> /// <returns></returns> public RespCreateWalletLoad ReloadWalletViaCreditCard(IPTV2Entities context, System.Guid userId, CreditCardReloadTransaction transaction, CreditCardInfo cardInfo) { RespCreateWalletLoad result = null; try { GomsException validationResult = UserValidation(context, userId); if (!(validationResult is GomsSuccess)) { throw validationResult; } var user = context.Users.Find(userId); var wallet = user.UserWallets.FirstOrDefault(w => w.IsActive); if (wallet == null) { throw new GomsInvalidWalletException(); } // Validate Wallet validationResult = WalletValidation(context, user, wallet.WalletId); if (!(validationResult is GomsSuccess)) { throw validationResult; } result = ReloadWalletViaCreditCard(context, wallet, transaction, cardInfo); } catch (GomsException e) { result = new RespCreateWalletLoad { IsSuccess = false, StatusCode = e.StatusCode, StatusMessage = e.StatusMessage }; } return result; }
/// <summary> /// Reload UserWallet via Credit Card /// </summary> /// <param name="context">DBContext of Model to be used</param> /// <param name="wallet">UserWallet to be loaded</param> /// <param name="transaction">CreditCardReloadTransaction filled up with the ff properties filled up: Amount, Date</param> /// <param name="cardInfo">Credit Card information</param> /// <returns></returns> public RespCreateWalletLoad ReloadWalletViaCreditCard(IPTV2Entities context, UserWallet wallet, CreditCardReloadTransaction transaction, CreditCardInfo cardInfo) { RespCreateWalletLoad result = null; InitializeServiceClient(); try { // validate credit card information cardInfo.Validate(); if (!cardInfo.IsValid) { throw new GomsInvalidCreditCardException(); } // validate user GomsException validationResult = UserValidation(context, wallet.UserId); if (!(validationResult is GomsSuccess)) { throw validationResult; } var user = context.Users.Find(wallet.UserId); // validate the wallet validationResult = WalletValidation(context, user, wallet.WalletId); if (!(validationResult is GomsSuccess)) { throw validationResult; } // validate transaction if (transaction == null) { throw new GomsInvalidTransactionException(); } else { if ((transaction.Amount <= 0) || (transaction.Date == null)) throw new GomsInvalidTransactionException(); } // prepare request // set transaction wallet user.Transactions.Add(transaction); transaction.UserWallet = wallet; transaction.Currency = wallet.Currency; var req = new ReqCreateWalletLoad { UID = ServiceUserId, PWD = ServicePassword, Email = user.EMail, CustomerId = (int)user.GomsCustomerId, ServiceId = (int)user.GomsServiceId, SubsidiaryId = (int)user.GomsSubsidiaryId, WalletId = (int)transaction.UserWallet.GomsWalletId, OrderType = 1, // PhoenixId = transaction.TransactionId, PhoenixId = (int)(DateTime.Now.Ticks - int.MaxValue), LoadAmountLocalCurrency = (double)transaction.Amount, //CurrencyId = (int)context.Currencies.Find(user.Country.CurrencyCode).GomsId CCName = cardInfo.Name, CCNumber = cardInfo.Number, CCSecurityCode = cardInfo.CardSecurityCode, CCExpiry = cardInfo.ExpiryDate, CCPostalCode = cardInfo.PostalCode, CCStreet = cardInfo.StreetAddress }; var paymentMethod = context.GomsPaymentMethods.FirstOrDefault(p => (p.GomsSubsidiaryId == user.GomsSubsidiaryId) && (p.Name == cardInfo.CardTypeString)); if (paymentMethod == null) { throw new GomsCreditCardTypeInvalidException(); } req.PaymentMethod = paymentMethod.PaymentMethodId; var log = new GomsLogs() { email = user.EMail, phoenixid = req.PhoenixId }; try { var startTime = DateTime.Now; result = _serviceClient.CreateWalletLoad(req); var endTime = DateTime.Now; var timeDifference = endTime - startTime; if (result.IsSuccess) { transaction.Reference = result.TransactionId.ToString(); transaction.GomsTransactionId = result.TransactionId; transaction.GomsTransactionDate = DateTime.Now; transaction.UserWallet.Balance += transaction.Amount; transaction.UserWallet.LastUpdated = DateTime.Now; context.SaveChanges(); log.gomstransactionid = result.TransactionId; log.message = String.Format("{0} - {1}", result.IsSuccess, result.StatusMessage); log.transactionid = transaction.TransactionId; log.transactiondate = transaction.GomsTransactionDate.Value.ToString("yyyy-MM-dd hh:mm:ss"); } } catch (Exception e) { log.message = e.Message; LogToGigya("glogs", log); throw new GomsServiceCallException(e.Message); } finally { LogToGigya("glogs", log); } } catch (GomsException e) { result = new RespCreateWalletLoad { IsSuccess = false, StatusCode = e.StatusCode, StatusMessage = e.StatusMessage }; } return (result); }
public ActionResult _CreditCard(FormCollection fc) { Response.ContentType = "application/json"; var ReturnCode = new TransactionReturnType() { StatusCode = (int)ErrorCodes.UnknownError, StatusMessage = MyUtility.getErrorMessage(ErrorCodes.UnknownError) }; try { if (String.IsNullOrEmpty(fc["id"])) return Json(ReturnCode, JsonRequestBehavior.AllowGet); if (!Request.IsAjaxRequest()) { ReturnCode.StatusCode = (int)ErrorCodes.IsInvalidRequest; ReturnCode.StatusMessage = "Your request is invalid."; return Json(ReturnCode, JsonRequestBehavior.AllowGet); } if (!GlobalConfig.IsCreditCardPaymentModeEnabled) { ReturnCode.StatusCode = (int)PaymentError.CREDIT_CARD_PAYMENT_IS_DISABLED; ReturnCode.StatusMessage = "Credit card payment is currenty disabled."; return Json(ReturnCode, JsonRequestBehavior.AllowGet); } if (User.Identity.IsAuthenticated) { int? id = Convert.ToInt32(fc["id"]); //Get ID DateTime registDt = DateTime.Now; var context = new IPTV2Entities(); System.Guid userId = new System.Guid(User.Identity.Name); User user = context.Users.FirstOrDefault(u => u.UserId == userId); Product product = context.Products.FirstOrDefault(p => p.ProductId == id); if (product == null) { ReturnCode.StatusCode = (int)ErrorCodes.ProductIsNull; ReturnCode.StatusMessage = MyUtility.getErrorMessage(ErrorCodes.ProductIsNull); return Json(ReturnCode, JsonRequestBehavior.AllowGet); } if (product.StatusId != GlobalConfig.Visible) { ReturnCode.StatusCode = (int)ErrorCodes.ProductIsNotPurchaseable; ReturnCode.StatusMessage = MyUtility.getErrorMessage(ErrorCodes.ProductIsNotPurchaseable); return Json(ReturnCode, JsonRequestBehavior.AllowGet); } if (!product.IsForSale) { ReturnCode.StatusCode = (int)ErrorCodes.ProductIsNotPurchaseable; ReturnCode.StatusMessage = MyUtility.getErrorMessage(ErrorCodes.ProductIsNotPurchaseable); return Json(ReturnCode, JsonRequestBehavior.AllowGet); } SubscriptionProductType subscriptionType = ContextHelper.GetProductType(product); string productName = product.Name; Offering offering = context.Offerings.FirstOrDefault(o => o.OfferingId == GlobalConfig.offeringId); if (user != null) { if (offering != null) { if (user.HasPendingGomsChangeCountryTransaction(offering)) { ReturnCode.StatusCode = (int)ErrorCodes.HasPendingChangeCountryTransaction; ReturnCode.StatusMessage = "We are processing your recent change in location. Please try again after a few minutes."; return Json(ReturnCode, JsonRequestBehavior.AllowGet); } if (user.HasExceededMaximumPaymentTransactionsForTheDay(GlobalConfig.paymentTransactionMaximumThreshold, registDt)) { ReturnCode.StatusCode = (int)ErrorCodes.MaximumTransactionsExceeded; ReturnCode.StatusMessage = String.Format("You have exceeded the maximum number of transactions ({0}) allowed per day. Please try again later.", GlobalConfig.paymentTransactionMaximumThreshold); return Json(ReturnCode, JsonRequestBehavior.AllowGet); } } if (GlobalConfig.IsRecurringBillingEnabled) { var checkIfEnrolled = CheckIfUserIsEnrolledToSameRecurringProductGroup(context, offering, user, product); if (checkIfEnrolled.value) { ReturnCode.StatusCode = (int)ErrorCodes.IsCurrentlyEnrolledInRecurringBilling; ReturnCode.StatusMessage = "You are currently automatically renewing a similar subscription product through credit card."; return Json(ReturnCode, JsonRequestBehavior.AllowGet); } } /**************** CHECK FOR WISHLISTING, PRODUCT RESTRICTION **********************/ User recipient = null; //Get Recipient string wid = fc["wid"]; if (!String.IsNullOrEmpty(wid)) { GSArray gsarray = GigyaMethods.GetWishlistDetails(wid); if (gsarray != null) { JObject o = JObject.Parse(gsarray.GetObject(0).ToJsonString()); System.Guid recipientUserId = new System.Guid(o["UID_s"].ToString()); recipient = context.Users.FirstOrDefault(u => u.UserId == recipientUserId); //ViewBag.RecipientEmail = recipient.EMail; if (recipient != null) ReturnCode.Recipient = String.Format("{0} {1}", recipient.FirstName, recipient.LastName); } if (subscriptionType == SubscriptionProductType.Package) { //Check if user has a current subscription if (!IsProductGiftable(context, product, recipient == null ? user.UserId : recipient.UserId)) { string CurrentProductName = ContextHelper.GetCurrentSubscribeProduct(context, product, recipient == null ? user.UserId : recipient.UserId, offering); ReturnCode.StatusMessage = String.Format("Sorry! You are already subscribed to {0}. You can no longer purchase {1}.", CurrentProductName, productName); if (recipient != null) { if (recipient.UserId != user.UserId) // same user ReturnCode.StatusMessage = String.Format("Sorry! {0} {1} is already subscribed to {2}. You can no longer gift {3}.", recipient.FirstName, recipient.LastName, CurrentProductName, productName); } ReturnCode.StatusCode = (int)ErrorCodes.ProductIsNotPurchaseable; return Json(ReturnCode, JsonRequestBehavior.AllowGet); } } } if (subscriptionType == SubscriptionProductType.Package) { if (!IsProductRestricted(context, product, recipient == null ? user.UserId : recipient.UserId)) { //string productName = ContextHelper.GetProductName(context, product); ReturnCode.StatusMessage = String.Format("Sorry! The ({0}) subscription is not available in your country.", productName); if (recipient != null) { if (recipient.UserId != user.UserId) // same user ReturnCode.StatusMessage = String.Format("Sorry! The ({0}) subscription is not available in the country where {1} {2} is. You are not allowed to send this gift.", productName, recipient.FirstName, recipient.LastName); } ReturnCode.StatusCode = (int)ErrorCodes.ProductIsNotAllowedInCountry; return Json(ReturnCode, JsonRequestBehavior.AllowGet); } if (String.IsNullOrEmpty(wid)) { if (!IsProductPurchaseable(context, product, recipient == null ? user.UserId : recipient.UserId)) { string CurrentProductName = ContextHelper.GetCurrentSubscribeProduct(context, product, recipient == null ? user.UserId : recipient.UserId, offering); ReturnCode.StatusMessage = String.Format("Sorry! You are already subscribed to {0}. You can no longer purchase {1}.", CurrentProductName, productName); if (recipient != null) { if (recipient.UserId != user.UserId) // same user ReturnCode.StatusMessage = String.Format("Sorry! {0} {1} is already subscribed to {2}. You can no longer gift {3}.", recipient.FirstName, recipient.LastName, CurrentProductName, productName); } ReturnCode.StatusCode = (int)ErrorCodes.ProductIsNotPurchaseable; return Json(ReturnCode, JsonRequestBehavior.AllowGet); } } } /**************** END OF CHECK FOR WISHLISTING, PRODUCT RESTRICTION ***************/ int? cpid = null; if (!String.IsNullOrEmpty(fc["cpid"])) Convert.ToInt32(fc["cpid"]); int cctype = Convert.ToInt32(fc["CreditCard"]); string name = fc["cardholdername"]; string cardnumber = fc["cardnumber"]; string securitycode = fc["securitycode"]; string expirymonth = fc["ExpiryMonth"]; string expiryyear = fc["ExpiryYear"]; string address = fc["address"]; string city = fc["city"]; string zip = fc["zip"]; var recur = fc["recur"]; CreditCardInfo info = new CreditCardInfo() { CardType = (IPTV2_Model.CreditCardType)cctype, Name = name, Number = cardnumber, CardSecurityCode = securitycode, ExpiryMonth = Convert.ToInt32(expirymonth), ExpiryYear = Convert.ToInt32(expiryyear), PostalCode = zip, StreetAddress = String.Format("{0}{1}", address, String.IsNullOrEmpty(city) ? "" : (", " + city)) }; ErrorResponse response; if (!String.IsNullOrEmpty(recur)) { if (recur.ToLowerInvariant().Contains("on")) response = PaymentHelper.PayViaCreditCardWithRecurringBilling(context, userId, info, product.ProductId, subscriptionType, recipient == null ? userId : recipient.UserId, cpid); else response = PaymentHelper.PayViaCreditCard2(context, userId, info, product.ProductId, subscriptionType, recipient == null ? userId : recipient.UserId, cpid); } else response = PaymentHelper.PayViaCreditCard2(context, userId, info, product.ProductId, subscriptionType, recipient == null ? userId : recipient.UserId, cpid); string ErrorMessage = String.Empty; switch (response.Code) { case (int)ErrorCodes.IsProductIdInvalidPpc: ErrorMessage = "Please use proper card for this product."; break; case (int)ErrorCodes.IsReloadPpc: ErrorMessage = "Card is invalid. Type is for reloading wallet."; break; case (int)ErrorCodes.IsInvalidCombinationPpc: ErrorMessage = "Invalid serial/pin combination."; break; case (int)ErrorCodes.IsExpiredPpc: ErrorMessage = "Prepaid card is expired."; break; case (int)ErrorCodes.IsInvalidPpc: ErrorMessage = "Serial does not exist."; break; case (int)ErrorCodes.IsUsedPpc: ErrorMessage = "Ppc is already used."; break; case (int)ErrorCodes.IsNotValidInCountryPpc: ErrorMessage = "Ppc not valid in your country."; break; case (int)ErrorCodes.CreditCardHasExpired: ErrorMessage = "Your credit card has already expired."; break; case (int)ErrorCodes.IsNotValidAmountPpc: ErrorMessage = "Ppc credits not enough to buy this product."; break; case (int)ErrorCodes.Success: { if (!String.IsNullOrEmpty(wid)) { GigyaMethods.DeleteWishlist(wid); // Delete from Wishlist SendGiftShareToSocialNetwork(product, recipient); ReceiveGiftShareToSocialNetwork(product, recipient, user); } ErrorMessage = "Credit card payment successful."; //To be used in the Thank You page //TempData["Product"] = product; TempData["PaymentMode"] = "CREDITCARD"; TempData["StatusMessage"] = ErrorMessage; //TempData["Transaction"] = user.Transactions.Last(); ReturnCode.WId = wid; ReturnCode.HtmlUri = "/Payment/Confirmation"; if (!String.IsNullOrEmpty(Request.QueryString["ReturnUrl"])) ReturnCode.HtmlUri = String.Format("{0}{1}", ReturnCode.HtmlUri, String.Format("?ReturnUrl={0}", Request.QueryString["ReturnUrl"])); if (!String.IsNullOrEmpty(response.CCEnrollmentStatusMessage)) { ReturnCode.CCStatusMessage = "Auto-renewal was not successful. Please contact Customer Support."; TempData["StatusMessage"] = String.Format("{0} {1}", ErrorMessage, ReturnCode.CCStatusMessage); } break; } default: ErrorMessage = response.Message; break; } ReturnCode.StatusCode = response.Code; ReturnCode.StatusMessage = ErrorMessage; } } else { ReturnCode.StatusCode = (int)ErrorCodes.NotAuthenticated; ReturnCode.StatusMessage = "Your session has expired. Please login again."; } } catch (Exception e) { MyUtility.LogException(e); ReturnCode.StatusCode = (int)ErrorCodes.UnknownError; ReturnCode.StatusMessage = e.Message; } return Json(ReturnCode, JsonRequestBehavior.AllowGet); }
public RespValidateCreditCard ValidateCreditCard(IPTV2Entities context, System.Guid userId, CreditCardPaymentTransaction transaction, CreditCardInfo cardInfo, int FreeTrialConvertedDays) { RespValidateCreditCard result = null; InitializeServiceClient(); try { // validate credit card information cardInfo.Validate(); if (!cardInfo.IsValid) { throw new GomsInvalidCreditCardException(); } // Validate User GomsException validationResult = UserValidation(context, userId); if (!(validationResult is GomsSuccess)) { throw validationResult; } var user = context.Users.Find(userId); if (transaction == null) { throw new GomsInvalidTransactionException(); } else { // check purchase items if ((transaction.Purchase == null) || (transaction.Purchase.PurchaseItems.Count() <= 0)) { throw new GomsInvalidTransactionException(); } } var paymentMethod = context.GomsPaymentMethods.FirstOrDefault(p => (p.GomsSubsidiaryId == user.GomsSubsidiaryId) && (p.Name == cardInfo.CardTypeString)); if (paymentMethod == null) { throw new GomsCreditCardTypeInvalidException(); } var req = new ReqValidateCreditCard { UID = ServiceUserId, PWD = ServicePassword, Email = user.EMail, CustomerId = (int)user.GomsCustomerId, ServiceId = (int)user.GomsServiceId, SubsidiaryId = (int)user.GomsSubsidiaryId, OrderType = 2, PhoenixId = (int)(DateTime.Now.Ticks - int.MaxValue), CurrencyId = (int)context.Currencies.Find(user.Country.CurrencyCode).GomsId, CCName = cardInfo.Name, CCNumber = cardInfo.Number, CCSecurityCode = cardInfo.CardSecurityCode, CCExpiry = cardInfo.ExpiryDate, CCPostalCode = cardInfo.PostalCode, CCStreet = cardInfo.StreetAddress, PaymentMethod = paymentMethod.PaymentMethodId, CCType = GetGomsCreditCardType(cardInfo.CardType), }; // build order items OrderItem[] oi = new OrderItem[transaction.Purchase.PurchaseItems.Count()]; int i = 0; foreach (var item in transaction.Purchase.PurchaseItems) { // look for user's entitlment of purchased product Entitlement userEntitlement = Entitlement.GetUserProductEntitlement(context, userId, item.ProductId); DateTime startDate = DateTime.Now; if (userEntitlement != null) startDate = userEntitlement.EndDate > DateTime.Now ? userEntitlement.EndDate : DateTime.Now; var newEndDate = getEntitlementEndDate(item.SubscriptionProduct.Duration, item.SubscriptionProduct.DurationType, startDate); /**** EARLY BIRD ****/ if (FreeTrialConvertedDays > 0) newEndDate = newEndDate.AddDays(FreeTrialConvertedDays); oi[i] = new OrderItem { ItemId = (int)item.SubscriptionProduct.GomsProductId, Quantity = (int)item.SubscriptionProduct.GomsProductQuantity, AmountLocalCurrency = (double)item.Price, EndDate = newEndDate.ToString("MM/dd/yyyy"), StartDate = startDate.ToString("MM/dd/yyyy"), }; if (item.RecipientUserId != userId) { req.OrderType = 3; User recipient = context.Users.Find(item.RecipientUserId); if (recipient == null) { throw new GomsInvalidRecipientException(); } if (!recipient.IsGomsRegistered) { //var registerResult = RegisterUser(context, item.RecipientUserId); var registerResult = RegisterUser2(context, item.RecipientUserId); if (!registerResult.IsSuccess) { throw new GomsRegisterUserException(registerResult.StatusMessage); } } req.Recipient = (int)recipient.GomsCustomerId; req.RecipientServiceId = (int)recipient.GomsServiceId; } i++; } req.OrderItems = oi; var log = new GomsLogs() { email = user.EMail, phoenixid = req.PhoenixId }; try { // _serviceClient.InnerChannel.OperationTimeout = TimeSpan.FromMinutes(5); var startTime = DateTime.Now; result = _serviceClient.ValidateCreditCard(req); var endTime = DateTime.Now; var timeDifference = endTime - startTime; if (result.IsSuccess) { transaction.Reference += "-" + result.TransactionId.ToString(); transaction.GomsTransactionId = result.TransactionId; transaction.GomsTransactionDate = DateTime.Now; user.Transactions.Add(transaction); log.transactionid = transaction.TransactionId; log.transactiondate = transaction.GomsTransactionDate.Value.ToString("yyyy-MM-dd hh:mm:ss"); } else { log.transactionid = 0; log.transactiondate = String.Empty; //log.message = String.Format("{0} - {1}", result.IsSuccess, result.StatusMessage); } log.message = String.Format("{0} - {1}", result.IsSuccess, result.StatusMessage); log.statuscode = result.StatusCode; log.statusmessage = result.StatusMessage; log.issuccess = result.IsSuccess; log.gomstransactionid = result.TransactionId; } catch (Exception e) { log.message = e.Message; LogToGigya("glogs", log); throw new GomsServiceCallException(e.Message); } finally { LogToGigya("glogs", log); } } catch (GomsException e) { result = new RespValidateCreditCard { IsSuccess = false, StatusCode = e.StatusCode, StatusMessage = e.StatusMessage }; } return (result); }
public static bool EnrollCreditCard(IPTV2Entities context, Offering offering, User user, DateTime registDt, CreditCardInfo info) { var retVal = false; if (GlobalConfig.IsRecurringBillingEnabled) { var CreditCardHash = MyUtility.GetSHA1(info.Number); if (user.CreditCards.Count(c => c.CreditCardHash == CreditCardHash && c.StatusId == GlobalConfig.Visible && c.OfferingId == offering.OfferingId) > 0) { // there is an active credit card attached to user } else { var paymentMethod = context.GomsPaymentMethods.FirstOrDefault(p => (p.GomsSubsidiaryId == user.GomsSubsidiaryId) && (p.Name == info.CardTypeString)); if (paymentMethod != null) { var creditCard = new IPTV2_Model.CreditCard() { CreditCardHash = CreditCardHash, StatusId = GlobalConfig.Visible, User = user, Offering = offering, LastDigits = info.Number.Right(4), CreatedOn = registDt, UpdatedOn = registDt, GomsPaymentMethod = paymentMethod, CardType = info.CardType.ToString().Replace("_", " ").ToUpper() }; context.CreditCards.Add(creditCard); if (context.SaveChanges() > 0) retVal = true; } } } return retVal; }
public static ErrorResponse PayViaCreditCardWithRecurringBilling_ValidateOnly(IPTV2Entities context, System.Guid userId, CreditCardInfo info, int productId, SubscriptionProductType subscriptionType, System.Guid recipientUserId, int? cpId, int? freeProductId) { ErrorResponse resp = new ErrorResponse(); try { int regularProductId = productId; if (freeProductId != null) productId = (int)freeProductId; bool isExtension = false; bool isGift = false; if (userId != recipientUserId) isGift = true; //email metadata string packageName = String.Empty; DateTime endDt = DateTime.Now; string ProductNameBought = String.Empty; DateTime registDt = DateTime.Now; User user = context.Users.FirstOrDefault(u => u.UserId == userId); User recipient = context.Users.FirstOrDefault(u => u.UserId == recipientUserId); //UserWallet wallet = user.UserWallets.FirstOrDefault(w => w.Currency == MyUtility.GetCurrencyOrDefault(user.CountryCode)); Offering offering = context.Offerings.FirstOrDefault(o => o.OfferingId == GlobalConfig.offeringId); Product product = context.Products.FirstOrDefault(p => p.ProductId == productId); ProductPrice priceOfProduct = product.ProductPrices.FirstOrDefault(p => p.CurrencyCode == MyUtility.GetCurrencyOrDefault(user.CountryCode)); if (priceOfProduct == null) priceOfProduct = product.ProductPrices.FirstOrDefault(p => p.CurrencyCode == GlobalConfig.DefaultCurrency); if (info == null) { } if (String.IsNullOrEmpty(info.Number)) { } if (String.IsNullOrEmpty(info.CardSecurityCode)) { } if (String.IsNullOrEmpty(info.Name)) { } if (String.IsNullOrEmpty(info.StreetAddress)) { } if (String.IsNullOrEmpty(info.PostalCode)) { } DateTime expiryDate = new DateTime(info.ExpiryYear, info.ExpiryMonth, 1); DateTime currentDate = new DateTime(registDt.Year, registDt.Month, 1); if (currentDate > expiryDate) { resp.Code = (int)ErrorCodes.IsElapsedExpiryDate; resp.Message = "Please check expiry date."; return resp; } //Check if this is an upgrade if (cpId != null && cpId != 0) { bool isUpgradeSuccess = Upgrade(context, userId, product, recipientUserId, cpId); } /***************************** Check for Early Bird Promo *******************************/ bool IsEarlyBird = false; int FreeTrialConvertedDays = 0; Product earlyBirdProduct = null; ProductPrice earlyBirdPriceOfProduct = null; //REMOVE THIS LINE ON RELEASE OF EARLY BIRD. //if (false) if (GlobalConfig.IsEarlyBirdEnabled) { if (user.IsFirstTimeSubscriber(offering, true, MyUtility.StringToIntList(GlobalConfig.FreeTrialPackageIds), context)) { FreeTrialConvertedDays = GetConvertedDaysFromFreeTrial(user); earlyBirdProduct = context.Products.FirstOrDefault(p => p.ProductId == GlobalConfig.FreeTrialEarlyBirdProductId); earlyBirdPriceOfProduct = earlyBirdProduct.ProductPrices.FirstOrDefault(p => p.CurrencyCode == GlobalConfig.TrialCurrency); Purchase earlyBirdPurchase = CreatePurchase(registDt, "Free Trial Early Bird Promo"); user.Purchases.Add(earlyBirdPurchase); PurchaseItem earlyBirdItem = CreatePurchaseItem(recipientUserId, earlyBirdProduct, earlyBirdPriceOfProduct); DateTime earlyBirdEndDate = registDt.AddDays(FreeTrialConvertedDays); EntitlementRequest earlyBirdRequest = CreateEntitlementRequest(registDt, earlyBirdEndDate, earlyBirdProduct, String.Format("EBP-{0}-{1}", "CC", info.CardTypeString.Replace('_', ' ')), String.Format("EBP-{0}", info.CardTypeString.Replace('_', ' ')), registDt); PackageSubscriptionProduct earlyBirdSubscription = (PackageSubscriptionProduct)earlyBirdProduct; var earlyBirdPackage = earlyBirdSubscription.Packages.First(); PackageEntitlement EarlyBirdEntitlement = CreatePackageEntitlement(earlyBirdRequest, earlyBirdSubscription, earlyBirdPackage, registDt); earlyBirdItem.EntitlementRequest = earlyBirdRequest; earlyBirdPurchase.PurchaseItems.Add(earlyBirdItem); recipient.EntitlementRequests.Add(earlyBirdRequest); EarlyBirdEntitlement.EndDate = earlyBirdEndDate; EarlyBirdEntitlement.LatestEntitlementRequest = earlyBirdRequest; recipient.PackageEntitlements.Add(EarlyBirdEntitlement); CreditCardPaymentTransaction earlyBirdTransaction = new CreditCardPaymentTransaction() { Amount = earlyBirdPriceOfProduct.Amount, Currency = earlyBirdPriceOfProduct.CurrencyCode, Reference = String.Format("EBP-{0}", info.CardType.ToString().Replace("_", " ").ToUpper()), Date = registDt, Purchase = earlyBirdPurchase, OfferingId = GlobalConfig.offeringId, StatusId = GlobalConfig.Visible }; earlyBirdPurchase.PaymentTransaction.Add(earlyBirdTransaction); user.Transactions.Add(earlyBirdTransaction); IsEarlyBird = true; } } /************************************ END OF EARLY BIRD PROMO *************************************/ Purchase purchase = CreatePurchase(registDt, userId != recipientUserId ? "Gift via Credit Card" : "Payment via Credit Card"); user.Purchases.Add(purchase); PurchaseItem item = CreatePurchaseItem(recipientUserId, product, priceOfProduct); purchase.PurchaseItems.Add(item); CreditCardPaymentTransaction transaction = new CreditCardPaymentTransaction() { Amount = priceOfProduct.Amount, Currency = priceOfProduct.CurrencyCode, Reference = info.CardType.ToString().Replace("_", " "), Date = registDt, Purchase = purchase, OfferingId = GlobalConfig.offeringId, StatusId = GlobalConfig.Visible }; var gomsService = new GomsTfcTv(); /*** EARLY BIRD ***/ //var response = gomsService.CreateOrderViaCreditCardWithRecurringBilling(context, userId, transaction, info); var response = gomsService.ValidateCreditCard(context, userId, transaction, info, FreeTrialConvertedDays); if (response.IsSuccess) { //transaction.Reference += "-" + response.TransactionId.ToString(); //user.Transactions.Add(transaction); item.SubscriptionProduct = (SubscriptionProduct)product; switch (subscriptionType) { case SubscriptionProductType.Show: ShowSubscriptionProduct show_subscription = (ShowSubscriptionProduct)product; ProductNameBought = show_subscription.Description; /*** JAN 09 2012****/ bool isApplicableForEarlyBird = false; if (IsEarlyBird) { var AlaCarteSubscriptionType = MyUtility.StringToIntList(GlobalConfig.FreeTrialAlaCarteSubscriptionTypes); if (show_subscription.ALaCarteSubscriptionTypeId != null) if (AlaCarteSubscriptionType.Contains((int)show_subscription.ALaCarteSubscriptionTypeId)) isApplicableForEarlyBird = true; } foreach (var show in show_subscription.Categories) { ShowEntitlement currentShow = recipient.ShowEntitlements.FirstOrDefault(s => s.CategoryId == show.CategoryId); DateTime endDate = registDt; EntitlementRequest request = CreateEntitlementRequest(registDt, endDate, product, String.Format("{0}-{1}", "CC", info.CardTypeString.Replace('_', ' ')), response.TransactionId.ToString(), registDt); if (currentShow != null) { if (currentShow.EndDate > request.StartDate) request.StartDate = currentShow.EndDate; currentShow.EndDate = MyUtility.getEntitlementEndDate(show_subscription.Duration, show_subscription.DurationType, ((currentShow.EndDate > registDt) ? currentShow.EndDate : registDt)); /** JAN 09 2012 **/ if (IsEarlyBird && isApplicableForEarlyBird) { currentShow.EndDate = currentShow.EndDate.AddDays(FreeTrialConvertedDays); } endDate = currentShow.EndDate; currentShow.LatestEntitlementRequest = request; request.EndDate = endDate; endDt = endDate; isExtension = true; } else { ShowEntitlement entitlement = CreateShowEntitlement(request, show_subscription, show, registDt); request.EndDate = entitlement.EndDate; /** JAN 09 2012 **/ if (IsEarlyBird && isApplicableForEarlyBird) { entitlement.EndDate = entitlement.EndDate.AddDays(FreeTrialConvertedDays); request.EndDate = request.EndDate.AddDays(FreeTrialConvertedDays); } recipient.ShowEntitlements.Add(entitlement); endDt = entitlement.EndDate; } recipient.EntitlementRequests.Add(request); item.EntitlementRequest = request; //UPDATED: November 22, 2012 } break; case SubscriptionProductType.Package: if (product is PackageSubscriptionProduct) { PackageSubscriptionProduct subscription = (PackageSubscriptionProduct)product; foreach (var package in subscription.Packages) { packageName = package.Package.Description; ProductNameBought = packageName; PackageEntitlement currentPackage = recipient.PackageEntitlements.FirstOrDefault(p => p.PackageId == package.PackageId); DateTime endDate = registDt; EntitlementRequest request = CreateEntitlementRequest(registDt, endDate, product, String.Format("{0}-{1}", "CC", info.CardTypeString.Replace('_', ' ')), response.TransactionId.ToString(), registDt); if (currentPackage != null) { if (currentPackage.EndDate > request.StartDate) request.StartDate = currentPackage.EndDate; currentPackage.EndDate = MyUtility.getEntitlementEndDate(subscription.Duration, subscription.DurationType, ((currentPackage.EndDate > registDt) ? currentPackage.EndDate : registDt)); /** JAN 03 2012 **/ if (IsEarlyBird) { currentPackage.EndDate = currentPackage.EndDate.AddDays(FreeTrialConvertedDays); } endDate = currentPackage.EndDate; currentPackage.LatestEntitlementRequest = request; request.EndDate = endDate; endDt = endDate; isExtension = true; } else { PackageEntitlement entitlement = CreatePackageEntitlement(request, subscription, package, registDt); request.EndDate = entitlement.EndDate; /** JAN 03 2012 **/ if (IsEarlyBird) { entitlement.EndDate = entitlement.EndDate.AddDays(FreeTrialConvertedDays); request.EndDate = request.EndDate.AddDays(FreeTrialConvertedDays); } recipient.PackageEntitlements.Add(entitlement); endDt = entitlement.EndDate; } recipient.EntitlementRequests.Add(request); item.EntitlementRequest = request; //UPDATED: November 22, 2012 } } break; case SubscriptionProductType.Episode: EpisodeSubscriptionProduct ep_subscription = (EpisodeSubscriptionProduct)product; foreach (var episode in ep_subscription.Episodes) { EpisodeEntitlement currentEpisode = recipient.EpisodeEntitlements.FirstOrDefault(e => e.EpisodeId == episode.EpisodeId); DateTime endDate = registDt; EntitlementRequest request = CreateEntitlementRequest(registDt, endDate, product, String.Format("{0}-{1}", "CC", info.CardTypeString.Replace('_', ' ')), response.TransactionId.ToString(), registDt); if (currentEpisode != null) { if (currentEpisode.EndDate > request.StartDate) request.StartDate = currentEpisode.EndDate; currentEpisode.EndDate = MyUtility.getEntitlementEndDate(ep_subscription.Duration, ep_subscription.DurationType, ((currentEpisode.EndDate > registDt) ? currentEpisode.EndDate : registDt)); endDate = currentEpisode.EndDate; currentEpisode.LatestEntitlementRequest = request; request.EndDate = endDate; endDt = endDate; isExtension = true; } else { EpisodeEntitlement entitlement = CreateEpisodeEntitlement(request, ep_subscription, episode, registDt); request.EndDate = entitlement.EndDate; recipient.EpisodeEntitlements.Add(entitlement); endDt = entitlement.EndDate; } recipient.EntitlementRequests.Add(request); item.EntitlementRequest = request; //UPDATED: November 22, 2012 } break; } if (context.SaveChanges() > 0) { if (response.IsSuccess) { EnrollCreditCard(context, offering, user, registDt, info); if (freeProductId != null) { var regularProduct = context.Products.FirstOrDefault(p => p.ProductId == regularProductId); if (regularProduct != null) AddToRecurringBilling(context, regularProduct, offering, user, registDt, info); else AddToRecurringBilling(context, product, offering, user, registDt, info); PaymentHelper.logUserPromo(context, userId, GlobalConfig.Xoom2PromoId); } else AddToRecurringBilling(context, product, offering, user, registDt, info); } else { //Check if there's a currently enrolled recurring then add //if (user.HasActiveRecurringProducts(offering)) //{ // AddToRecurringBilling(context, product, offering, user, registDt, info); // response.IsCCEnrollmentSuccess = true; //} //Check if there is an enrolled credit card //Commented out. if cc enrollment fails, everything fails. //if (HasEnrolledCreditCard(offering, user)) // AddToRecurringBilling(context, product, offering, user, registDt, info); } //SendConfirmationEmails(user, recipient, transaction, ProductNameBought, product, endDt, registDt, "Credit Card", isGift, isExtension, true, (DateTime)endDt.AddDays(-4).Date); SendConfirmationEmails(user, recipient, transaction, ProductNameBought, product, endDt, registDt, "Credit Card", isGift, isExtension, response.IsSuccess, (DateTime)endDt.AddDays(-4).Date); resp.Code = (int)ErrorCodes.Success; resp.Message = "Successful"; resp.transaction = transaction; resp.product = product; resp.price = priceOfProduct; resp.ProductType = subscriptionType == SubscriptionProductType.Package ? "Subscription" : "Retail"; if (!response.IsSuccess) { resp.Message = String.Format("{0}. {1}", resp.Message, response.StatusMessage); resp.CCEnrollmentStatusMessage = "CC Enrollment Error"; } return resp; } resp.Code = (int)ErrorCodes.EntityUpdateError; resp.Message = "Entity Update Error"; return resp; } resp.Code = Convert.ToInt32(response.StatusCode); resp.Message = response.StatusMessage; if (!response.IsSuccess) { //Include CCenrollment status message in case enrolment fails. resp.CCEnrollmentStatusMessage = response.StatusMessage; } return resp; } catch (Exception) { //Debug.WriteLine(e.InnerException); throw; } }
public ActionResult _CreditCard(int? id, string wid, int? cpid, FormCollection fc) { Dictionary<string, object> collection = new Dictionary<string, object>(); DateTime registDt = DateTime.Now; try { if (id == null) return PartialView("PaymentTemplates/_BuyErrorPartial"); string errorMessage = MyUtility.getErrorMessage(ErrorCodes.UnknownError); collection = MyUtility.setError(ErrorCodes.UnknownError); if (User.Identity.IsAuthenticated) { var context = new IPTV2Entities(); System.Guid userId = new System.Guid(User.Identity.Name); User user = context.Users.FirstOrDefault(u => u.UserId == userId); Product product = context.Products.FirstOrDefault(p => p.ProductId == id); if (product == null) { collection = MyUtility.setError(ErrorCodes.ProductIsNull); return Content(MyUtility.buildJson(collection), "application/json"); } if (!product.IsForSale) { collection = MyUtility.setError(ErrorCodes.ProductIsNotPurchaseable); return Content(MyUtility.buildJson(collection), "application/json"); } SubscriptionProductType subscriptionType = ContextHelper.GetProductType(product); string productName = product.Name; Offering offering = context.Offerings.FirstOrDefault(o => o.OfferingId == GlobalConfig.offeringId); if (user != null) { if (offering != null) { if (user.HasPendingGomsChangeCountryTransaction(offering)) { errorMessage = "We are processing your recent change in location. Please try again after a few minutes."; collection = MyUtility.setError(ErrorCodes.HasPendingChangeCountryTransaction, errorMessage); return Content(MyUtility.buildJson(collection), "application/json"); } if (user.HasExceededMaximumPaymentTransactionsForTheDay(GlobalConfig.paymentTransactionMaximumThreshold, registDt)) { errorMessage = String.Format("You have exceeded the maximum number of transactions ({0}) allowed per day. Please try again later.", GlobalConfig.paymentTransactionMaximumThreshold); collection = MyUtility.setError(ErrorCodes.HasPendingChangeCountryTransaction, errorMessage); return Content(MyUtility.buildJson(collection), "application/json"); } } //decimal amount = Convert.ToDecimal(fc["amount"]); int cctype = Convert.ToInt32(fc["CreditCard"]); string name = fc["cardholdername"]; string cardnumber = fc["cardnumber"]; string securitycode = fc["securitycode"]; string expirymonth = fc["ExpiryMonth"]; string expiryyear = fc["ExpiryYear"]; string address = fc["address"]; string city = fc["city"]; string zip = fc["zip"]; var recur = fc["recur"]; //decimal amount = Convert.ToDecimal("4.99"); //int cctype = 2; //string name = "123"; //string cardnumber = "4111111111111111"; //string securitycode = "123"; //string expirymonth = "1"; //string expiryyear = "2014"; //string address = "123"; //string city = "123"; //string zip = "123"; CreditCardInfo info = new CreditCardInfo() { CardType = (IPTV2_Model.CreditCardType)cctype, Name = name, Number = cardnumber, CardSecurityCode = securitycode, ExpiryMonth = Convert.ToInt32(expirymonth), ExpiryYear = Convert.ToInt32(expiryyear), PostalCode = zip, StreetAddress = String.Format("{0}{1}", address, String.IsNullOrEmpty(city) ? "" : (", " + city)) }; //Get Recipient User recipient = null; if (!String.IsNullOrEmpty(wid)) { GSArray gsarray = GigyaMethods.GetWishlistDetails(wid); if (gsarray != null) { JObject o = JObject.Parse(gsarray.GetObject(0).ToJsonString()); System.Guid recipientUserId = new System.Guid(o["UID_s"].ToString()); recipient = context.Users.FirstOrDefault(u => u.UserId == recipientUserId); ViewBag.RecipientEmail = recipient.EMail; collection.Add("recipient", String.Format("{0} {1}", recipient.FirstName, recipient.LastName)); } if (subscriptionType == SubscriptionProductType.Package) { //Check if user has a current subscription if (!IsProductGiftable(context, product, recipient == null ? user.UserId : recipient.UserId)) { string CurrentProductName = ContextHelper.GetCurrentSubscribeProduct(context, product, recipient == null ? user.UserId : recipient.UserId, offering); errorMessage = String.Format("Sorry! You are already subscribed to {0}. You can no longer purchase {1}.", CurrentProductName, productName); if (recipient != null) { if (recipient.UserId != user.UserId) // same user errorMessage = String.Format("Sorry! {0} {1} is already subscribed to {2}. You can no longer gift {3}.", recipient.FirstName, recipient.LastName, CurrentProductName, productName); } collection = MyUtility.setError(ErrorCodes.ProductIsNotPurchaseable, errorMessage); return Content(MyUtility.buildJson(collection), "application/json"); } } } var checkIfEnrolled = CheckIfUserIsEnrolledToSameRecurringProductGroup(context, offering, user, product); if (checkIfEnrolled.value) { errorMessage = "You are currently automatically renewing a similar subscription product through credit card."; collection = MyUtility.setError(ErrorCodes.ProductIsNotPurchaseable, errorMessage); return Content(MyUtility.buildJson(collection), "application/json"); } ErrorResponse response; if (!String.IsNullOrEmpty(recur)) { if (recur.ToLowerInvariant().Contains("on")) response = PaymentHelper.PayViaCreditCardWithRecurringBilling(context, userId, info, product.ProductId, subscriptionType, recipient == null ? userId : recipient.UserId, cpid); else response = PaymentHelper.PayViaCreditCard2(context, userId, info, product.ProductId, subscriptionType, recipient == null ? userId : recipient.UserId, cpid); } else response = PaymentHelper.PayViaCreditCard2(context, userId, info, product.ProductId, subscriptionType, recipient == null ? userId : recipient.UserId, cpid); switch (response.Code) { case (int)ErrorCodes.IsProductIdInvalidPpc: errorMessage = "Please use proper card for this product."; break; case (int)ErrorCodes.IsReloadPpc: errorMessage = "Card is invalid. Type is for reloading wallet."; break; case (int)ErrorCodes.IsInvalidCombinationPpc: errorMessage = "Invalid serial/pin combination."; break; case (int)ErrorCodes.IsExpiredPpc: errorMessage = "Prepaid card is expired."; break; case (int)ErrorCodes.IsInvalidPpc: errorMessage = "Serial does not exist."; break; case (int)ErrorCodes.IsUsedPpc: errorMessage = "Ppc is already used."; break; case (int)ErrorCodes.IsNotValidInCountryPpc: errorMessage = "Ppc not valid in your country."; break; case (int)ErrorCodes.CreditCardHasExpired: errorMessage = "Your credit card has already expired."; break; case (int)ErrorCodes.IsNotValidAmountPpc: errorMessage = "Ppc credits not enough to buy this product."; break; case (int)ErrorCodes.Success: { //Insert to Recurring if (!String.IsNullOrEmpty(recur)) { if (recur.ToLowerInvariant().Contains("on")) { ////Check if product is subscription product //if (product is SubscriptionProduct) //{ // //check if there are any recurring products that have the same productgroup // SubscriptionProduct subscriptionProduct = (SubscriptionProduct)product; // //Get user's recurring productGroups // var recurringProductGroups = user.GetRecurringProductGroups(offering); // if (!recurringProductGroups.Contains(subscriptionProduct.ProductGroup)) // { // var productPackage = context.ProductPackages.FirstOrDefault(p => p.ProductId == product.ProductId); // if (productPackage != null) // { // var entitlement = user.PackageEntitlements.FirstOrDefault(p => p.PackageId == productPackage.PackageId); // if (entitlement != null) // { // var billing = new RecurringBilling() // { // CreatedOn = registDt, // Product = product, // User = user, // UpdatedOn = registDt, // EndDate = entitlement.EndDate, // NextRun = entitlement.EndDate.AddDays(-1).Date, // Run day before expiry // StatusId = GlobalConfig.Visible, // Offering = offering, // Package = (Package)productPackage.Package // }; // context.RecurringBillings.Add(billing); // context.SaveChanges(); // } // } // } //} } } if (!String.IsNullOrEmpty(wid)) { GigyaMethods.DeleteWishlist(wid); // Delete from Wishlist SendGiftShareToSocialNetwork(product, recipient); ReceiveGiftShareToSocialNetwork(product, recipient, user); } collection.Add("wid", wid); errorMessage = "Congratulations! You have now bought this product."; if (!String.IsNullOrEmpty(response.CCEnrollmentStatusMessage)) { //errorMessage = String.Format("{0} {1}", errorMessage, response.CCEnrollmentStatusMessage); //collection.Add("cErrorMessage", "This product will be renewed using the credit card you previously enrolled in your account."); collection.Add("cErrorMessage", "Auto-renewal was not successful. Please contact Customer Support."); } break; } default: errorMessage = response.Message; break; } collection["errorCode"] = response.Code; collection["errorMessage"] = errorMessage; } } else { collection["errorCode"] = (int)ErrorCodes.NotAuthenticated; collection.Add("errorMessage", "Your session has expired. Please login again."); } } catch (Exception e) { collection = MyUtility.setError(ErrorCodes.UnknownError, e.Message); } return Content(MyUtility.buildJson(collection), "application/json"); }
public static void AddToRecurringBilling(IPTV2Entities context, Product product, Offering offering, User user, DateTime registDt, CreditCardInfo info) { //Check if product is subscription product if (product is SubscriptionProduct) { //check if there are any recurring products that have the same productgroup SubscriptionProduct subscriptionProduct = (SubscriptionProduct)product; //Get user's recurring productGroups var recurringProductGroups = user.GetRecurringProductGroups(offering); if (!recurringProductGroups.Contains(subscriptionProduct.ProductGroup)) { var productPackage = context.ProductPackages.FirstOrDefault(p => p.ProductId == product.ProductId); if (productPackage != null) { var entitlement = user.PackageEntitlements.FirstOrDefault(p => p.PackageId == productPackage.PackageId); if (entitlement != null) { var billing = new CreditCardRecurringBilling() { CreatedOn = registDt, Product = product, User = user, UpdatedOn = registDt, EndDate = entitlement.EndDate, NextRun = entitlement.EndDate.AddDays(-3).Date, // Run day before expiry StatusId = GlobalConfig.Visible, Offering = offering, Package = (Package)productPackage.Package, CreditCardHash = MyUtility.GetSHA1(info.Number), NumberOfAttempts = 0 }; context.RecurringBillings.Add(billing); context.SaveChanges(); } } } } }
public ContentResult ReloadViaCreditCard(FormCollection fc) { Dictionary<string, object> collection = new Dictionary<string, object>(); ErrorCodes errorCode = ErrorCodes.UnknownError; string errorMessage = MyUtility.getErrorMessage(ErrorCodes.UnknownError); collection.Add("errorCode", (int)errorCode); collection.Add("errorMessage", errorMessage); if (User.Identity.IsAuthenticated) { var context = new IPTV2Entities(); System.Guid userId = new System.Guid(User.Identity.Name); User user = context.Users.FirstOrDefault(u => u.UserId == userId); if (user != null) { Offering offering = context.Offerings.Find(GlobalConfig.offeringId); if (user.HasPendingGomsChangeCountryTransaction(offering)) { errorMessage = "We are processing your recent change in location. Please try again after a few minutes."; collection = MyUtility.setError(ErrorCodes.HasPendingChangeCountryTransaction, errorMessage); return Content(MyUtility.buildJson(collection), "application/json"); } var registDt = DateTime.Now; if (user.HasExceededMaximumReloadTransactionsForTheDay(GlobalConfig.reloadTransactionMaximumThreshold, registDt)) { errorMessage = String.Format("You have exceeded the maximum number of transactions ({0}) allowed per day. Please try again later.", GlobalConfig.paymentTransactionMaximumThreshold); collection = MyUtility.setError(ErrorCodes.HasPendingChangeCountryTransaction, errorMessage); return Content(MyUtility.buildJson(collection), "application/json"); } decimal amount = Convert.ToDecimal(fc["amount"]); int cctype = Convert.ToInt32(fc["CreditCard"]); string name = fc["cardholdername"]; string cardnumber = fc["cardnumber"]; string securitycode = fc["securitycode"]; string expirymonth = fc["ExpiryMonth"]; string expiryyear = fc["ExpiryYear"]; string address = fc["address"]; string city = fc["city"]; string zip = fc["zip"]; CreditCardInfo info = new CreditCardInfo() { CardType = (IPTV2_Model.CreditCardType)cctype, Name = name, Number = cardnumber, CardSecurityCode = securitycode, ExpiryMonth = Convert.ToInt32(expirymonth), ExpiryYear = Convert.ToInt32(expiryyear), PostalCode = zip, StreetAddress = String.Format("{0}{1}", address, String.IsNullOrEmpty(city) ? "" : (", " + city)) }; ErrorResponse response = ReloadHelper.ReloadViaCreditCard2(context, userId, info, amount); switch (response.Code) { case (int)ErrorCodes.IsProductIdInvalidPpc: errorMessage = "Please use proper card for this product."; break; case (int)ErrorCodes.IsReloadPpc: errorMessage = "Card is invalid. Type is for reloading wallet."; break; case (int)ErrorCodes.IsSubscriptionPpc: errorMessage = "Card is invalid. Type is for subscription."; break; case (int)ErrorCodes.IsInvalidCombinationPpc: errorMessage = "Invalid serial/pin combination."; break; case (int)ErrorCodes.IsExpiredPpc: errorMessage = "Prepaid card is expired."; break; case (int)ErrorCodes.IsInvalidPpc: errorMessage = "Serial does not exist."; break; case (int)ErrorCodes.IsUsedPpc: errorMessage = "Ppc is already used."; break; case (int)ErrorCodes.IsNotValidInCountryPpc: errorMessage = "Ppc not valid in your country."; break; case (int)ErrorCodes.CreditCardHasExpired: errorMessage = "Your credit card has already expired."; break; case (int)ErrorCodes.IsNotValidAmountPpc: errorMessage = "Ppc credits not enough to buy this product."; break; case (int)ErrorCodes.Success: UserWallet wallet = user.UserWallets.FirstOrDefault(w => w.Currency == MyUtility.GetCurrencyOrDefault(user.CountryCode)); string CurrencyCode = MyUtility.GetCurrencyOrDefault(user.CountryCode); Currency currency = context.Currencies.FirstOrDefault(c => c.Code == CurrencyCode); string NewWalletBalance = ""; if (currency.IsLeft) NewWalletBalance = String.Format("{0}{1}", currency.Symbol, wallet.Balance.ToString("F")); else NewWalletBalance = String.Format("{0}{1}", wallet.Balance.ToString("F"), currency.Symbol); NewWalletBalance = String.Format("{0} {1}", currency.Code, wallet.Balance.ToString("F")); ViewBag.newBalance = NewWalletBalance; errorMessage = "Congratulations! You have now topped up your wallet. New wallet balance is " + NewWalletBalance; break; default: errorMessage = response.Message; break; } collection["errorCode"] = response.Code; collection["errorMessage"] = errorMessage; } } else { collection["errorCode"] = (int)ErrorCodes.NotAuthenticated; collection.Add("errorMessage", "Your session has expired. Please login again."); } return Content(MyUtility.buildJson(collection), "application/json"); }
public ActionResult _CreditCard(FormCollection fc) { Response.ContentType = "application/json"; var ReturnCode = new TransactionReturnType() { StatusCode = (int)ErrorCodes.UnknownError, StatusMessage = MyUtility.getErrorMessage(ErrorCodes.UnknownError) }; try { if (!Request.IsAjaxRequest()) { ReturnCode.StatusCode = (int)ErrorCodes.IsInvalidRequest; ReturnCode.StatusMessage = "Your request is invalid."; return Json(ReturnCode, JsonRequestBehavior.AllowGet); } if (!GlobalConfig.IsCreditCardReloadModeEnabled) { ReturnCode.StatusCode = (int)ReloadError.CREDIT_CARD_RELOAD_IS_DISABLED; ReturnCode.StatusMessage = "Credit Card reloading is currently disabled."; return Json(ReturnCode, JsonRequestBehavior.AllowGet); } if (User.Identity.IsAuthenticated) { var registDt = DateTime.Now; var context = new IPTV2Entities(); System.Guid userId = new System.Guid(User.Identity.Name); User user = context.Users.FirstOrDefault(u => u.UserId == userId); Offering offering = context.Offerings.FirstOrDefault(o => o.OfferingId == GlobalConfig.offeringId); if (user != null) { if (offering != null) { if (user.HasPendingGomsChangeCountryTransaction(offering)) { ReturnCode.StatusCode = (int)ErrorCodes.HasPendingChangeCountryTransaction; ReturnCode.StatusMessage = "We are processing your recent change in location. Please try again after a few minutes."; return Json(ReturnCode, JsonRequestBehavior.AllowGet); } if (user.HasExceededMaximumReloadTransactionsForTheDay(GlobalConfig.reloadTransactionMaximumThreshold, registDt)) { ReturnCode.StatusCode = (int)ErrorCodes.MaximumTransactionsExceeded; ReturnCode.StatusMessage = String.Format("You have exceeded the maximum number of transactions ({0}) allowed per day. Please try again later.", GlobalConfig.paymentTransactionMaximumThreshold); return Json(ReturnCode, JsonRequestBehavior.AllowGet); } } decimal amount = Convert.ToDecimal(fc["pamount"]); int cctype = Convert.ToInt32(fc["CreditCard"]); string name = fc["cardholdername"]; string cardnumber = fc["cardnumber"]; string securitycode = fc["securitycode"]; string expirymonth = fc["ExpiryMonth"]; string expiryyear = fc["ExpiryYear"]; string address = fc["address"]; string city = fc["city"]; string zip = fc["zip"]; CreditCardInfo info = new CreditCardInfo() { CardType = (IPTV2_Model.CreditCardType)cctype, Name = name, Number = cardnumber, CardSecurityCode = securitycode, ExpiryMonth = Convert.ToInt32(expirymonth), ExpiryYear = Convert.ToInt32(expiryyear), PostalCode = zip, StreetAddress = String.Format("{0}{1}", address, String.IsNullOrEmpty(city) ? "" : (", " + city)) }; ErrorResponse response = ReloadHelper.ReloadViaCreditCard2(context, userId, info, amount); string ErrorMessage = String.Empty; switch (response.Code) { case (int)ErrorCodes.IsProductIdInvalidPpc: ErrorMessage = "Please use proper card/ePIN for this product."; break; case (int)ErrorCodes.IsReloadPpc: ErrorMessage = "Card/ePIN is invalid. Type is for reloading wallet."; break; case (int)ErrorCodes.IsSubscriptionPpc: ErrorMessage = "Card/ePIN is invalid. Type is for subscription."; break; case (int)ErrorCodes.IsInvalidCombinationPpc: ErrorMessage = "Invalid serial/pin combination."; break; case (int)ErrorCodes.IsExpiredPpc: ErrorMessage = "Prepaid Card/ePIN is expired."; break; case (int)ErrorCodes.IsInvalidPpc: ErrorMessage = "Serial does not exist."; break; case (int)ErrorCodes.IsUsedPpc: ErrorMessage = "Prepaid Card/ePIN is already used."; break; case (int)ErrorCodes.IsNotValidInCountryPpc: ErrorMessage = "Prepaid Card/ePIN not valid in your country."; break; case (int)ErrorCodes.CreditCardHasExpired: ErrorMessage = "Your credit card has already expired."; break; case (int)ErrorCodes.IsNotValidAmountPpc: ErrorMessage = "Prepaid Card/ePIN credits not enough to buy this product."; break; case (int)ErrorCodes.Success: UserWallet wallet = user.UserWallets.FirstOrDefault(w => w.Currency == MyUtility.GetCurrencyOrDefault(user.CountryCode) && w.IsActive == true); var balance = String.Format("{0} {1}", wallet.Currency, wallet.Balance.ToString("F")); ErrorMessage = String.Format("Your new wallet balance is {0}", balance); TempData["ReloadMode"] = "CREDITCARD"; ReturnCode.HtmlUri = "/Load/Confirmation"; break; default: ErrorMessage = response.Message; break; } ReturnCode.StatusCode = response.Code; ReturnCode.StatusMessage = ErrorMessage; } } else { ReturnCode.StatusCode = (int)ErrorCodes.NotAuthenticated; ReturnCode.StatusMessage = "Your session has expired. Please login again."; } } catch (Exception e) { MyUtility.LogException(e); ReturnCode.StatusCode = (int)ErrorCodes.UnknownError; ReturnCode.StatusMessage = e.Message; } return Json(ReturnCode, JsonRequestBehavior.AllowGet); }
public ActionResult _LoadViaCreditCard(FormCollection fc) { var ReturnCode = new TransactionReturnType() { StatusCode = (int)ErrorCodes.UnknownError, StatusMessage = String.Empty, info = "CreditCard", TransactionType = "Load" }; string url = Url.Action("Index", "Load").ToString(); try { DateTime registDt = DateTime.Now; Dictionary<string, string> tmpCollection = fc.AllKeys.ToDictionary(k => k, v => fc[v]); bool isMissingRequiredFields = false; foreach (var x in tmpCollection) { if (String.IsNullOrEmpty(x.Value)) { isMissingRequiredFields = true; break; } } if (!isMissingRequiredFields) // process form { if (GlobalConfig.IsCreditCardReloadModeEnabled) { if (User.Identity.IsAuthenticated) { var context = new IPTV2Entities(); System.Guid userId = new System.Guid(User.Identity.Name); User user = context.Users.FirstOrDefault(u => u.UserId == userId); if (user != null) { var offering = context.Offerings.Find(GlobalConfig.offeringId); if (offering != null) { if (user.HasPendingGomsChangeCountryTransaction(offering)) ReturnCode.StatusMessage = "We are processing your recent change in location. Please try again after a few minutes."; else if (user.HasExceededMaximumReloadTransactionsForTheDay(GlobalConfig.reloadTransactionMaximumThreshold, registDt)) ReturnCode.StatusMessage = String.Format("You have exceeded the maximum number of transactions ({0}) allowed per day. Please try again later.", GlobalConfig.reloadTransactionMaximumThreshold); else { decimal amount = Convert.ToDecimal(fc["camount"]); int cctype = Convert.ToInt32(fc["CreditCard"]); string name = fc["cardholdername"]; string cardnumber = fc["cardnumber"]; string securitycode = fc["securitycode"]; string expirymonth = fc["ExpiryMonth"]; string expiryyear = fc["ExpiryYear"]; string address = fc["address"]; string city = fc["city"]; string zip = fc["zip"]; CreditCardInfo info = new CreditCardInfo() { CardType = (CreditCardType)cctype, Name = name, Number = cardnumber, CardSecurityCode = securitycode, ExpiryMonth = Convert.ToInt32(expirymonth), ExpiryYear = Convert.ToInt32(expiryyear), PostalCode = zip, StreetAddress = String.Format("{0}{1}", address, String.IsNullOrEmpty(city) ? "" : (", " + city)) }; ErrorResponse response = ReloadHelper.ReloadViaCreditCard2(context, userId, info, amount); string ErrorMessage = String.Empty; switch (response.Code) { case (int)ErrorCodes.IsProductIdInvalidPpc: ErrorMessage = "Please use proper card/ePIN for this product."; break; case (int)ErrorCodes.IsReloadPpc: ErrorMessage = "Card/ePIN is invalid. Type is for reloading wallet."; break; case (int)ErrorCodes.IsSubscriptionPpc: ErrorMessage = "Card/ePIN is invalid. Type is for subscription."; break; case (int)ErrorCodes.IsInvalidCombinationPpc: ErrorMessage = "Invalid serial/pin combination."; break; case (int)ErrorCodes.IsExpiredPpc: ErrorMessage = "Prepaid Card/ePIN is expired."; break; case (int)ErrorCodes.IsInvalidPpc: ErrorMessage = "Serial does not exist."; break; case (int)ErrorCodes.IsUsedPpc: ErrorMessage = "Prepaid Card/ePIN is already used."; break; case (int)ErrorCodes.IsNotValidInCountryPpc: ErrorMessage = "Prepaid Card/ePIN is not valid in your country."; break; case (int)ErrorCodes.CreditCardHasExpired: ErrorMessage = "Your credit card has already expired."; break; case (int)ErrorCodes.IsNotValidAmountPpc: ErrorMessage = "Prepaid Card/ePIN credits not enough to buy this product."; break; case (int)ErrorCodes.Success: UserWallet wallet = user.UserWallets.FirstOrDefault(w => w.Currency == MyUtility.GetCurrencyOrDefault(user.CountryCode) && w.IsActive); string balance = String.Format("Your new wallet balance is {0} {1}.", wallet.Currency, wallet.Balance.ToString("F")); ReturnCode.StatusCode = (int)ErrorCodes.Success; ReturnCode.StatusHeader = "You have successfully purchased credits!"; ReturnCode.StatusMessage = String.Format("Congratulations! You have reloaded your E-Wallet. {0}", balance); ReturnCode.StatusMessage2 = "Pwede ka nang manood ng mga piling Kapamilya shows at movies.<br>Visit your Free Trial page to see what's available and start watching!"; TempData["ErrorMessage"] = ReturnCode; return RedirectToAction("Index", "Home"); // successful reload default: ErrorMessage = response.Message; break; } ReturnCode.StatusMessage = ErrorMessage; } } else ReturnCode.StatusMessage = "Service not found. Please contact support."; } else ReturnCode.StatusMessage = "User does not exist."; } else ReturnCode.StatusMessage = "Your session has already expired. Please login again."; } else ReturnCode.StatusMessage = "Prepaid Card/ePIN payment is currenty disabled."; } else ReturnCode.StatusMessage = "Please fill in all required fields."; TempData["ErrorMessage"] = ReturnCode; url = Request.UrlReferrer.AbsolutePath; } catch (Exception e) { MyUtility.LogException(e); ReturnCode.StatusMessage = e.Message; TempData["ErrorMessage"] = ReturnCode; } return Redirect(url); }
public ActionResult _CreditCard(FormCollection fc) { var ReturnCode = new TransactionReturnType() { StatusCode = (int)ErrorCodes.UnknownError, StatusMessage = String.Empty, info = "CreditCard", TransactionType = "Subscription" }; string url = Url.Action("Details", "Subscribe", new { id = Url.RequestContext.RouteData.Values["id"] }).ToString(); try { DateTime registDt = DateTime.Now; Dictionary<string, string> tmpCollection = fc.AllKeys.ToDictionary(k => k, v => fc[v]); bool isMissingRequiredFields = false; foreach (var x in tmpCollection) { if (String.IsNullOrEmpty(x.Value)) { isMissingRequiredFields = true; break; } } if (!isMissingRequiredFields) // process form { if (GlobalConfig.IsCreditCardPaymentModeEnabled) { if (User.Identity.IsAuthenticated) { int pid = Convert.ToInt32(fc["pid"]); //Get ID int cctype = Convert.ToInt32(fc["CreditCard"]); string name = fc["cardholdername"]; string cardnumber = fc["cardnumber"]; string securitycode = fc["securitycode"]; int expirymonth = Convert.ToInt32(fc["ExpiryMonth"]); int expiryyear = Convert.ToInt32(fc["ExpiryYear"]); string address = fc["address"]; string city = fc["city"]; string zip = fc["zip"]; var recur = fc["recur"]; var f_apr = fc["f_apr"]; if (!String.IsNullOrEmpty(f_apr)) if (String.Compare(f_apr, "True", true) == 0) recur = f_apr; var context = new IPTV2Entities(); Product product = context.Products.FirstOrDefault(p => p.ProductId == pid); if (product == null) ReturnCode.StatusMessage = MyUtility.getErrorMessage(ErrorCodes.ProductIsNull); else if (product.StatusId != GlobalConfig.Visible) ReturnCode.StatusMessage = MyUtility.getErrorMessage(ErrorCodes.ProductIsNotPurchaseable); else if (!product.IsForSale) ReturnCode.StatusMessage = MyUtility.getErrorMessage(ErrorCodes.ProductIsNotPurchaseable); else { System.Guid userId = new System.Guid(User.Identity.Name); User user = context.Users.FirstOrDefault(u => u.UserId == userId); if (user != null) { Offering offering = context.Offerings.FirstOrDefault(o => o.OfferingId == GlobalConfig.offeringId); if (offering != null) { if (user.HasPendingGomsChangeCountryTransaction(offering)) ReturnCode.StatusMessage = "We are processing your recent change in location. Please try again after a few minutes."; else if (user.HasExceededMaximumPaymentTransactionsForTheDay(GlobalConfig.paymentTransactionMaximumThreshold, registDt)) ReturnCode.StatusMessage = String.Format("You have exceeded the maximum number of transactions ({0}) allowed per day. Please try again later.", GlobalConfig.paymentTransactionMaximumThreshold); else { if (GlobalConfig.IsRecurringBillingEnabled) { var checkIfEnrolled = ContextHelper.CheckIfUserIsEnrolledToSameRecurringProductGroup(context, offering, user, product); if (checkIfEnrolled.value) { ReturnCode.StatusMessage = "You are currently automatically renewing a similar subscription product through credit card."; TempData["ErrorMessage"] = ReturnCode; return Redirect(url); } } SubscriptionProductType subscriptionType = ContextHelper.GetProductType(product); string productName = product.Description; if (subscriptionType == SubscriptionProductType.Package || subscriptionType == SubscriptionProductType.Show) { if (!product.IsAllowed(user.CountryCode)) ReturnCode.StatusMessage = String.Format("Sorry! The ({0}) product is not available in your country.", productName); //else if (!ContextHelper.IsProductPurchaseable(context, product, user, offering)) //{ // //string CurrentProductName = ContextHelper.GetCurrentSubscribeProduct(context, product, user.UserId, offering); // string CurrentProductName = product.Description; // ReturnCode.StatusMessage = String.Format("Sorry! You are already subscribed to {0}. You can no longer purchase {1}.", CurrentProductName, productName); //} else { CreditCardInfo info = new CreditCardInfo() { CardType = (IPTV2_Model.CreditCardType)cctype, Name = name, Number = cardnumber, CardSecurityCode = securitycode, ExpiryMonth = expirymonth, ExpiryYear = expiryyear, PostalCode = zip, StreetAddress = String.Format("{0}{1}", address, String.IsNullOrEmpty(city) ? "" : (", " + city)) }; ErrorResponse response; if (!String.IsNullOrEmpty(recur)) { if (subscriptionType == SubscriptionProductType.Package) { if (recur.ToLowerInvariant().Contains("on") || recur.ToLowerInvariant().Contains("true")) { if (ContextHelper.IsXoomEligible(context, user)) response = PaymentHelper.PayViaCreditCardWithRecurringBilling_ValidateOnly(context, userId, info, product.ProductId, subscriptionType, user.UserId, null, GlobalConfig.Xoom2FreeProductId); else response = PaymentHelper.PayViaCreditCardWithRecurringBilling(context, userId, info, product.ProductId, subscriptionType, user.UserId, null); } else response = PaymentHelper.PayViaCreditCard2(context, userId, info, product.ProductId, subscriptionType, user.UserId, null); } else response = PaymentHelper.PayViaCreditCard2(context, userId, info, product.ProductId, subscriptionType, user.UserId, null); } else response = PaymentHelper.PayViaCreditCard2(context, userId, info, product.ProductId, subscriptionType, user.UserId, null); string ErrorMessage = String.Empty; switch (response.Code) { case (int)ErrorCodes.IsProductIdInvalidPpc: ErrorMessage = "Please use proper card/ePIN for this product."; break; case (int)ErrorCodes.IsReloadPpc: ErrorMessage = "Card/ePIN is invalid. Type is for reloading wallet."; break; case (int)ErrorCodes.IsInvalidCombinationPpc: ErrorMessage = "Invalid serial/pin combination."; break; case (int)ErrorCodes.IsExpiredPpc: ErrorMessage = "Prepaid Card/ePIN is expired."; break; case (int)ErrorCodes.IsInvalidPpc: ErrorMessage = "Serial does not exist."; break; case (int)ErrorCodes.IsUsedPpc: ErrorMessage = "Prepaid Card/ePIN is already used."; break; case (int)ErrorCodes.IsNotValidInCountryPpc: ErrorMessage = "Prepaid Card/ePIN not valid in your country."; break; case (int)ErrorCodes.CreditCardHasExpired: ErrorMessage = "Your credit card has already expired."; break; case (int)ErrorCodes.IsNotValidAmountPpc: ErrorMessage = "Prepaid Card/ePIN credits not enough to buy this product."; break; case (int)ErrorCodes.Success: { string CcStatusMessage = String.Empty; if (!String.IsNullOrEmpty(response.CCEnrollmentStatusMessage)) CcStatusMessage = "Auto-renewal was not successful. Please contact Customer Support."; ReturnCode.StatusCode = (int)ErrorCodes.Success; ReturnCode.StatusHeader = "You have successfully purchased a product!"; ReturnCode.StatusMessage = String.Format("Congratulations! You are now subscribed to {0}. {1}", product.Description, CcStatusMessage); ReturnCode.StatusMessage2 = "Pwede ka nang manood ng mga piling Kapamilya shows at movies!"; ReturnCode.info7 = user.EMail; //Project Black PaymentHelper.logProjectBlackUserPromo(context, userId, pid); //Xoom2 if (PaymentHelper.logUserPromo(context, userId, GlobalConfig.Xoom2PromoId)) { ReturnCode.StatusHeader = "You have successfully registered and subscribed to a package!"; ReturnCode.StatusMessage = String.Format("Congratulations! You claimed your FREE 1st month and subscribed to {0}", product.Description); } //GA ECommerce try { ReturnCode.info1 = String.Format("{0}", response.transaction.TransactionId); //transaction id ga ecommerce ReturnCode.info2 = String.Format("{0}", response.product.ProductId); //sku ga ecommerce ReturnCode.info3 = response.product.Description; //name ga ecommerce ReturnCode.info4 = String.Format("{0}", response.price.Amount.ToString("F")); //price ga ecommerce ReturnCode.info5 = response.price.CurrencyCode; //currency ga ecommerce ReturnCode.info6 = response.ProductType; //product type ga ecommerce } catch (Exception) { } try { if (this.ControllerContext.HttpContext.Request.Cookies.AllKeys.Contains("air")) { HttpCookie airCookie = new HttpCookie("air"); airCookie.Expires = DateTime.Now.AddDays(-1); Response.Cookies.Add(airCookie); } } catch (Exception) { } TempData["ErrorMessage"] = ReturnCode; try { var pacmayproductIdsForRedirect = MyUtility.StringToIntList(GlobalConfig.PacMayProductIdsForRedirect); if (pacmayproductIdsForRedirect.Contains(pid)) TempData["IsPacMayPurchase"] = true; } catch (Exception) { } return RedirectToAction("Index", "Home"); // successful payment } default: ErrorMessage = response.Message; break; } ReturnCode.StatusCode = response.Code; ReturnCode.StatusMessage = ErrorMessage; } } else ReturnCode.StatusMessage = "This type of product is not for sale."; } } else ReturnCode.StatusMessage = "Service not found. Please contact support."; } else ReturnCode.StatusMessage = "User does not exist."; } } else ReturnCode.StatusMessage = "Your session has already expired. Please login again."; } else ReturnCode.StatusMessage = "Credit card payment is currenty disabled."; } else ReturnCode.StatusMessage = "Please fill in all required fields."; TempData["ErrorMessage"] = ReturnCode; url = Request.UrlReferrer.AbsolutePath; } catch (Exception e) { MyUtility.LogException(e); ReturnCode.StatusMessage = e.Message; TempData["ErrorMessage"] = ReturnCode; } return Redirect(url); }
public static ErrorResponse ReloadViaCreditCard2(IPTV2Entities context, System.Guid userId, CreditCardInfo info, decimal amount) { ErrorResponse resp = new ErrorResponse(); try { DateTime registDt = DateTime.Now; User user = context.Users.FirstOrDefault(u => u.UserId == userId); UserWallet wallet = user.UserWallets.FirstOrDefault(w => w.Currency == MyUtility.GetCurrencyOrDefault(user.CountryCode)); string CurrencyCode = MyUtility.GetCurrencyOrDefault(user.CountryCode); Currency currency = context.Currencies.FirstOrDefault(c => c.Code == CurrencyCode); Offering offering = context.Offerings.FirstOrDefault(o => o.OfferingId == GlobalConfig.offeringId); if (info == null) { } if (String.IsNullOrEmpty(info.Number)) { } if (String.IsNullOrEmpty(info.CardSecurityCode)) { } if (String.IsNullOrEmpty(info.Name)) { } if (String.IsNullOrEmpty(info.StreetAddress)) { } if (String.IsNullOrEmpty(info.PostalCode)) { } CreditCardReloadTransaction transaction = new CreditCardReloadTransaction() { Amount = amount, Currency = CurrencyCode, Reference = info.CardType.ToString().Replace("_", " ").ToUpper(), UserWallet = wallet, Date = registDt, OfferingId = GlobalConfig.offeringId, StatusId = GlobalConfig.Visible }; //user.Transactions.Add(transaction); var gomsService = new GomsTfcTv(); var response = gomsService.ReloadWalletViaCreditCard(context, userId, transaction, info); if (response.IsSuccess) { resp.Code = (int)ErrorCodes.Success; resp.Message = "Successful"; return resp; } resp.Code = Convert.ToInt32(response.StatusCode); resp.Message = response.StatusMessage; return resp; } catch (Exception e) { Debug.WriteLine(e.InnerException); throw; } }