Example #1
0
        static public void CreditCardReload()
        {
            var context = new IPTV2_Model.IPTV2Entities();
            var gomsService = new GomsTfcTv();

            var user = context.Users.FirstOrDefault(u => u.EMail == "*****@*****.**");
            if (user != null)
            {
                // create transaction
                var transaction = new IPTV2_Model.CreditCardReloadTransaction
                    {
                        Amount = 10,
                        Currency = user.Country.CurrencyCode,
                        Date = DateTime.Now,
                    };

                var resp = gomsService.ReloadWalletViaCreditCard(context, user.UserId, transaction, GetCreditCard());
                if (resp.IsSuccess)
                {
                    // YEY
                }

            }

        }
Example #2
0
        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; }
        }