Exemple #1
0
        /// <summary>
        /// Deliberate Decision: Omit "Async" suffix (see link, best practice) from Aggregate methods to not blur the
        /// Ubiquitous language with technical implementation details
        /// </summary>
        /// <param name="merchantCreditCardInformation"></param>
        /// <param name="bankConnectorDS"></param>
        /// <returns></returns>
        public async Task <bool> AttemptPayment(CreditCardInformation merchantCreditCardInformation,
                                                IBankConnectorDomainService bankConnectorDS)
        {
            var result = await bankConnectorDS.TransmitPaymentOrderAsync(Amount.Amount, Amount.CurrencyCode, CreditCardInformation,
                                                                         merchantCreditCardInformation);

            PaymentOrderUniqueIdentifier = result.OrderUniqueIdentifier;

            switch (result.ResultStatus)
            {
            case PaymentOrderResultStatus.Successful:
                CurrentState = PaymentState.PaymentSuccessful;
                PaidDate     = DateTime.UtcNow;
                break;

            case PaymentOrderResultStatus.FailedDueToRejectedCreditCard:
            case PaymentOrderResultStatus.FailedDueToUnknownReason:
                CurrentState = PaymentState.PaymentFailed;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            return(CurrentState == PaymentState.PaymentSuccessful);
        }
Exemple #2
0
        public async Task <ActionResult> Create([FromBody] CreatePaymentRequestModel requestModel)
        {
            if (!EnsureMerchantValidity(out var merchant))
            {
                return(BadRequest(new ErrorResponseModel("missing or invalid merchant header")));
            }

            var creditCardInformation = new CreditCardInformation(requestModel.CreditCardNumber,
                                                                  new ExpiryDate(requestModel.CreditCardExpiryMonth, requestModel.CreditCardExpiryYear),
                                                                  requestModel.CreditCardCcv);

            var paymentAmount = new PaymentAmount(requestModel.Amount, requestModel.CurrencyCode);
            var payment       = Payment.Create(paymentAmount, creditCardInformation, merchant.MerchantId, requestModel.ExternalShopperIdentifier);

            bool wasPaymentSuccessful = await payment.AttemptPayment(merchant.CreditCardInformation, _bankConnectorDS);

            _paymentRepository.Add(payment);
            await _paymentRepository.PersistAsync();

            _logger.LogInformation($"New payment was created with PaymentId: {payment.PaymentId}");

            var responseModel = new CreatePaymentResponseModel
            {
                WasPaymentSuccessful = wasPaymentSuccessful,
                PaymentId            = payment.PaymentId
            };

            return(Accepted(responseModel));
        }
Exemple #3
0
        public static CreditCardCurrentTransaction CurrentTransactions(Params request)
        {
            CreditCardCurrentTransaction transaction = new CreditCardCurrentTransaction();

            try
            {
                if (request != null)
                {
                    if (request.Parameter.ContainsKey("cardNo"))
                    {
                        string cardNo = request.Parameter["cardNo"];
                        CreditCardInformation information = CreditCardService.RetrieveCreditCardDetail(cardNo, CreditCardService.RetrieveCreditCardType(cardNo));
                        transaction.CustomerNo = information.CustomerNo;
                        transaction.CreditCards.Add(information);
                        CreditCardCurrentTransaction currentTrx = RetrieveCreditCardCurrentTransactions(cardNo);
                        foreach (CreditCardTransaction trx in currentTrx.Transactions)
                        {
                            transaction.Transactions.Add(trx);
                        }
                    }
                    else if (request.Parameter.ContainsKey("custNo"))
                    {
                        // If a customer has multiple Credit Cards, the "Credit Card Customer No" is still the same for all the credit cards.
                        Params param = new Params()
                        {
                            Parameter = new Dictionary <string, string>()
                        };
                        param.RequestTransType = "GetAllRelatedCreditCardInOneCustNo";
                        param.Parameter.Add("custNo", request.Parameter["custNo"]);
                        param.WSDL = "AllRelatedDetail";
                        ESBData data = EAI.RetrieveESBData(param);
                        transaction.CustomerNo = request.Parameter["custNo"];

                        if (data.Result != null && data.Result.Count != 0)
                        {
                            // All related credit cards (from the service 'GetAllRelatedCreditCardInOneCustNo') are returned as a set of "cardType", "cardNo", "creditLinePerCard"
                            foreach (StringDictionary entry in data.Result)
                            {
                                CreditCardInformation information = CreditCardService.RetrieveCreditCardDetail(entry["cardNo"], entry["cardType"]);
                                transaction.CreditCards.Add(information);
                                CreditCardCurrentTransaction currentTrx = RetrieveCreditCardCurrentTransactions(entry["cardNo"]);
                                foreach (CreditCardTransaction trx in currentTrx.Transactions)
                                {
                                    transaction.Transactions.Add(trx);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
            }

            return(transaction);
        }
		public static bool DoPayment(CreditCardInformation creditCardInfo,
			IPAddress address, out string response)
		{
			var ret = false;
			response = ",,,";

            //try
            //{
            //    SoapDoDirectPayment payment = new SoapDoDirectPayment();

            //    payment.Request.IPAddress = address.ToString();
            //    payment.Request.PaymentDetails.OrderTotal = Convert.ToDecimal(creditCardInfo.PurchaseAmount);
            //    payment.Request.PaymentDetails.OrderDescription = creditCardInfo.Description;
				
            //    var creditCard = payment.Request.CreditCard;

            //    creditCard.Address.CityName = creditCardInfo.City;
            //    creditCard.Address.PostalCode = creditCardInfo.ZipCode;
            //    creditCard.Address.StateOrProvince = creditCardInfo.State;
            //    creditCard.Address.Street1 = creditCardInfo.Street1;
            //    creditCard.Address.Street2 = creditCardInfo.Street2;
            //    creditCard.Payer = creditCardInfo.Email;
            //    creditCard.FirstName = creditCardInfo.FirstName;
            //    creditCard.LastName = creditCardInfo.LastName;

            //    creditCard.CreditCardNumber = creditCardInfo.CardNumber;
            //    creditCard.CreditCardType = (CreditCardUtility.CreditCardTypeType)Enum.Parse(typeof(CreditCardUtility.CreditCardTypeType), creditCardInfo.CardType);
            //    creditCard.CVV2 = creditCardInfo.CVV2;
            //    creditCard.ExpMonth = Convert.ToInt32(creditCardInfo.ExpMonth);
            //    creditCard.ExpYear = Convert.ToInt32(creditCardInfo.ExpYear);

            //    ret = payment.Post();

            //    if (ret)
            //        response = payment.Response.TransactionID + "," +
            //            payment.Response.Amount.ToString("f") + "," +
            //                payment.Response.AVSCode + "," +
            //                    payment.Response.CVV2Code;
            //    else
            //        response = payment.Response.ErrorList[0].ErrorCode + "," +
            //            payment.Response.ErrorList[0].SeverityCode + "," +
            //                payment.Response.ErrorList[0].ShortMessage + "," +
            //                    payment.Response.ErrorList[0].LongMessage;
            //}
            //catch (Exception exception)
            //{
            //    ret = false;
            //    response = exception.Message + ",,,";
            //    Console.WriteLine(exception);
            //}
            //finally
            //{
            //    response = ret + "," + response;
            //}
			return ret;
		}
 public CreditCardModel MapAndMaskCreditCard(CreditCardInformation creditCardInformation)
 {
     return(new CreditCardModel
     {
         CardNumber = MaskCreditCardNumber(creditCardInformation.CardNumber),
         ExpiryDateYear = creditCardInformation.ExpiryDate.Year,
         ExpiryDateMonth = creditCardInformation.ExpiryDate.Month,
         Ccv = creditCardInformation.Ccv
     });
 }
Exemple #6
0
        public IActionResult Delete(CreditCardInformation creditCard)
        {
            var result = _creditCardInformationService.Delete(creditCard);

            if (result.Success)
            {
                return(Ok(result));
            }
            return(BadRequest(result));
        }
Exemple #7
0
        public IActionResult CheckIfCreditCardLegit(CreditCardInformation creditCard)
        {
            creditCard.CardYear += 2000;
            var result = _creditCardInformationService.CheckIfCreditCardLegit(creditCard);

            if (result.Success)
            {
                return(Ok(result));
            }
            return(BadRequest(result));
        }
Exemple #8
0
 public static Payment Create(PaymentAmount amount, CreditCardInformation creditCardInformation, Guid merchantId,
                              string externalShopperIdentifier)
 {
     return(new Payment
     {
         Amount = amount,
         CreditCardInformation = creditCardInformation,
         MerchantId = merchantId,
         ExternalShopperIdentifier = externalShopperIdentifier
     });
 }
Exemple #9
0
        public static Merchant RegisterNewMerchant(string name, CreditCardInformation creditCardInformation, IRandomDomainService randomDS)
        {
            var newMerchant = new Merchant
            {
                Name = name,
                CreditCardInformation = creditCardInformation
            };

            newMerchant.GenerateApiKey(randomDS);

            return(newMerchant);
        }
        public void Merchant_Is_Created_Enabled()
        {
            // Arrange
            var creditCardInformation = new CreditCardInformation("5105105105105100", new ExpiryDate(10, 2022), 667);
            var randomDS = new RandomDomainService();

            // Act
            var merchant = Merchant.RegisterNewMerchant("Test-Merchant", creditCardInformation, randomDS);

            // Assert
            Assert.IsTrue(merchant.IsEnabled);
        }
        public void Merchant_Has_Valid_ApiKey_After_Creation()
        {
            // Arrange
            var creditCardInformation = new CreditCardInformation("5105105105105100", new ExpiryDate(10, 2022), 667);
            var randomDS = new RandomDomainService();

            // Act
            var merchant = Merchant.RegisterNewMerchant("Test-Merchant", creditCardInformation, randomDS);

            // Assert
            Assert.IsFalse(string.IsNullOrWhiteSpace(merchant.ApiKey));
            Assert.AreEqual(22, merchant.ApiKey.Length);
        }
        public static CreditCardHistoricalTransaction HistoryTransactions(Params request)
        {
            CreditCardHistoricalTransaction transaction = new CreditCardHistoricalTransaction();
            string StatementDate = request.Parameter["statementDate"];

            try
            {
                if (request != null)
                {
                    AllRelatedCreditCardInformation allRelatedCreditCardInformation = null;

                    if (request.Parameter.ContainsKey("custNo"))
                    {
                        transaction.Information.CustomerNo = request.Parameter["custNo"];
                    }
                    allRelatedCreditCardInformation = CreditCardService.RetrieveAllRelatedCreditCards(request);

                    foreach (CreditCardInformation entry in allRelatedCreditCardInformation.RelatedCreditCards)
                    {
                        CreditCardInformation information = CreditCardService.RetrieveCreditCardDetail(entry.CreditCardNo, entry.CardType);
                        transaction.Information.CustomerNo = information.CustomerNo;
                        transaction.CreditCards.Add(information);
                        CreditCardHistoricalTransaction historyTrx = RetrieveCreditCardHistoricalTransactions(entry.CreditCardNo, StatementDate);
                        foreach (CreditCardTransaction trx in historyTrx.Transactions)
                        {
                            transaction.Transactions.Add(trx);
                        }
                    }

                    transaction.Information.OldBalance = (
                        from creditCardTransaction in transaction.Transactions
                        select creditCardTransaction.PreviousBalance).Sum();

                    transaction.Information.Credit = (
                        from creditCardTransaction in transaction.Transactions
                        where HistoricalTransactionCodesForNegativeAmount.Contains(creditCardTransaction.TransactionCode)
                        select creditCardTransaction.Amount).Sum();

                    transaction.Information.AccountDate = Formatter.ParseExact(StatementDate, "JY");
                    if (transaction.Information.AccountDate.HasValue)
                    {
                        transaction.Information.MaturityDate = transaction.Information.AccountDate.Value.AddDays(14);
                    }
                }
            }
            catch (Exception e)
            {
            }
            return(transaction);
        }
Exemple #13
0
        public void MapAndMaskCreditCard_Returns_Valid_Model()
        {
            // Arrange
            var modelMapper           = new ModelMapper();
            var creditCardInformation = new CreditCardInformation("4012888888881881", new ExpiryDate(10, 2020), 443);

            // Act
            var resultModel = modelMapper.MapAndMaskCreditCard(creditCardInformation);

            // Assert
            Assert.IsNotNull(resultModel);
            Assert.AreEqual("************1881", resultModel.CardNumber);
            Assert.AreEqual(10, resultModel.ExpiryDateMonth);
            Assert.AreEqual(2020, resultModel.ExpiryDateYear);
            Assert.AreEqual(443, resultModel.Ccv);
        }
        public void UserDidProvideCreditCardInfo(CreditCardInfo card, CardIOPaymentViewController paymentViewController)
        {
            paymentViewController.DismissViewController(true, null);

            if (card != null)
            {
                var creditCardInfo = new CreditCardInformation
                {
                    CardNumber      = card.CardNumber,
                    ExpirationMonth = card.ExpiryMonth.ToString(),
                    ExpirationYear  = card.ExpiryYear.ToString()
                };

                MessagingCenter.Send(creditCardInfo, MessengerKeys.CreditCardScanned);
            }
        }
Exemple #15
0
        public static CreditCardOutstandingTransaction OutstandingTransactions(Params request)
        {
            CreditCardOutstandingTransaction transaction = new CreditCardOutstandingTransaction();

            try
            {
                if (request.Parameter.ContainsKey("cardNo"))
                {
                    string cardNo = request.Parameter["cardNo"];
                    CreditCardInformation information = CreditCardService.RetrieveCreditCardDetail(cardNo, CreditCardService.RetrieveCreditCardType(cardNo));
                    transaction.CustomerNo = information.CustomerNo;
                    transaction.CreditCards.Add(information);
                    RetrieveCreditCardOutstandingTransactions(cardNo, transaction);
                }
                else if (request.Parameter.ContainsKey("custNo"))
                {
                    Params param = new Params()
                    {
                        Parameter = new Dictionary <string, string>()
                    };
                    param.RequestTransType = "GetAllRelatedCreditCardInOneCustNo";
                    param.Parameter.Add("custNo", request.Parameter["custNo"]);
                    param.WSDL = "AllRelatedDetail";
                    ESBData cardData = EAI.RetrieveESBData(param);
                    transaction.CustomerNo = request.Parameter["custNo"];

                    if (cardData.Result != null && cardData.Result.Count != 0)
                    {
                        foreach (StringDictionary entry in cardData.Result)
                        {
                            string cardno = entry["cardNo"];
                            if (!string.IsNullOrEmpty(cardno))
                            {
                                CreditCardInformation information = CreditCardService.RetrieveCreditCardDetail(cardno, entry["cardType"]);
                                transaction.CreditCards.Add(information);
                                RetrieveCreditCardOutstandingTransactions(cardno, transaction);
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
            }
            return(transaction);
        }
        protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
        {
            base.OnActivityResult(requestCode, resultCode, data);

            if (data != null)
            {
                var card = data.GetParcelableExtra(CardIOActivity.ExtraScanResult).JavaCast <CreditCard>();

                var creditCardInfo = new CreditCardInformation
                {
                    CardNumber      = card.CardNumber,
                    ExpirationMonth = card.ExpiryMonth.ToString(),
                    ExpirationYear  = card.ExpiryYear.ToString()
                };

                MessagingCenter.Send(creditCardInfo, MessengerKeys.CreditCardScanned);
            }
        }
        private async Task <OrchardCore.TenantBilling.Models.PaymentMethod> GetPaymentInformation(Invoice invoice)
        {
            //Get Customer
            var stripeCustomerId = invoice.CustomerId;
            var customerService  = new CustomerService();
            var customer         = await customerService.GetAsync(stripeCustomerId);

            //User Customer to extract subscription payment
            var paymentMethodId = customer.Subscriptions.Data[0].DefaultPaymentMethodId;
            var paymentService  = new PaymentMethodService();
            var paymentMethod   = await paymentService.GetAsync(paymentMethodId);

            //Get card info
            var card     = paymentMethod.Card;
            var cardType = (CardType)Enum.Parse(typeof(CardType), card.Brand.ToLower());
            var creditCardInformation = new CreditCardInformation(cardType, Int32.Parse(card.Last4), Convert.ToInt32(card.ExpMonth), Convert.ToInt32(card.ExpYear));
            var paymentInformation    = new OrchardCore.TenantBilling.Models.PaymentMethod(true, creditCardInformation);

            return(paymentInformation);
        }
        /// <summary>
        /// Sends the payment order to the Bank to do the actual retrieval of money from the Shopper's card and payout to the Merchant.
        ///
        /// NOTE: As this class is to be used inside the domain itself, we'll re-use the value types from the payments aggregate.
        /// This could be decoupled more with dedicated models but this would increase overall complexity and necessitate
        /// mapping between those classes thus I opted against it.
        /// </summary>
        /// <param name="currencyCode"></param>
        /// <param name="amount"></param>
        /// <param name="sourceCreditCardInformation"></param>
        /// <param name="targetCreditCardInformation"></param>
        /// <returns></returns>
        public Task <PaymentOrderResult> TransmitPaymentOrderAsync(decimal amount, string currencyCode, CreditCardInformation sourceCreditCardInformation,
                                                                   CreditCardInformation targetCreditCardInformation)
        {
            var isSuccess = DecideOrderSuccess();

            // NOTE: we're just using a GUID as string as the payment order identifier. Could also be a timestamp,
            // randomized string or incrementing number (or any combination of those) but the application will have to
            // store it as a foreign-decided string artifact anyway as we would not have control over it (every Bank
            // could have a different algorithm and even differ inside the same Bank because of a core banking system migration)
            // thus a simple string with no direct constraint on its content should be the most future-proof storing method here.
            var paymentOrderIdentifier = Guid.NewGuid().ToString();

            // randomize if the simulated payment order succeeded. If not, simulate a rejected (or invalid) credit card.
            var resultStatus = isSuccess
                ? PaymentOrderResultStatus.Successful
                : PaymentOrderResultStatus.FailedDueToRejectedCreditCard;
            var result = new PaymentOrderResult(paymentOrderIdentifier, resultStatus);

            // NOTE: fake asynchronicity because most-likely every other non-simulated processing will benefit from asynchronous processing,
            // so the interface of this method has to be async from the Point-of-view of the caller
            return(Task.FromResult(result));
        }
Exemple #19
0
        public IResult Add(CreditCardInformation creditCardInformation)
        {
            var result = BusinessRules.Run(CheckIfHasCard(creditCardInformation.UserId));

            if (result != null)
            {
                _creditCardInformationDal.Add(creditCardInformation);
                return(new SuccessResult(Messages.Successful));
            }
            var oldCreditCard = _creditCardInformationDal.Get(c => c.UserId == creditCardInformation.UserId);
            CreditCardInformation newCreditCard = new CreditCardInformation()
            {
                Id                 = oldCreditCard.Id,
                UserId             = creditCardInformation.UserId,
                CardMonth          = creditCardInformation.CardMonth,
                CardName           = creditCardInformation.CardName,
                CardNumber         = creditCardInformation.CardNumber,
                CardSecurityNumber = creditCardInformation.CardSecurityNumber,
                CardYear           = creditCardInformation.CardYear
            };

            _creditCardInformationDal.Update(newCreditCard);
            return(new SuccessResult(Messages.Successful));
        }
 public PaymentMethod(bool activeCard, CreditCardInformation creditCardInfo)
 {
     this.ActiveCard     = activeCard;
     this.CreditCardInfo = creditCardInfo;
 }
Exemple #21
0
		public void InvokeCreditCardsChanged(CreditCardInformation creditCardInformation)
		{
			EventAggregator.GetEvent<CreditCardsChangedEvent>().Publish(new CreditCardsChangedEventPayload(creditCardInformation));
		}
		/// <summary>
		/// Executes a credit card payment using Stripe.com and updates the db with the charge
		/// </summary>
		/// <param name="creditCardInformation"></param>
		/// <param name="response">Contains the response to send to the user.</param>
		/// <returns>Returns true if the credit card charge succeeded.</returns>
		public static StripeCharge DoPayment(CreditCardInformation creditCardInformation, out String response)
		{
			bool successful;
			var finalMessage = "Unknown Purchase Error";

			#region Create and Update a Stripe Customer (disabled)

			//StripeCustomer customer;

			//// Check to see if customer is an existing customer.
			//if (IsExistingCustomer(creditCardInformation.Email))
			//{
			//    var oldCustomer = GetCustomer(creditCardInformation.Email);

			//    var newCustomer = SetUpdateCustomer(oldCustomer, creditCardInformation, creditCardInformation.ItemName);
			//    var newCustomerService = new StripeCustomerService();
			//    try
			//    {
			//        customer = newCustomerService.Update(oldCustomer.Id, newCustomer);
			//    }
			//    catch (StripeException except)
			//    {
			//        finalMessage = except.StripeError.Code;
			//        Logger.TraceErr(finalMessage);
			//        response = String.Format("{0}, {1}", successful, finalMessage);
			//        return false;
			//        //throw;
			//    }
			//}
			//else
			//{	// If it is a new customer, create a customer with the info collected.
			//    var newCustomer = SetNewCustomer(creditCardInformation,creditCardInformation.ItemName);
			//    var newCustomerService = new StripeCustomerService();
			//    customer = newCustomerService.Create(newCustomer);
			//}

			#endregion

			StripeCharge result;

			try
			{
				var myCharge = new StripeChargeCreateOptions
				{
					AmountInCents = (int)(Convert.ToSingle(creditCardInformation.PurchaseAmount) * 100),
					Currency = creditCardInformation.Currency,
					Description = creditCardInformation.Description,
					//CustomerId = customer.Id
					CardNumber = creditCardInformation.CardNumber,
					CardCvc = creditCardInformation.CVV2,
					CardName = string.Format("{0} {1}", creditCardInformation.FirstName, creditCardInformation.LastName),
					CardExpirationMonth = creditCardInformation.ExpMonth,
					CardExpirationYear = creditCardInformation.ExpYear,
				};
				var chargeService = new StripeChargeService();
				result = chargeService.Create(myCharge);
				successful = true;
			}
			catch (StripeException stripeException)
			{
				Logger.TraceErr(stripeException);
				finalMessage = stripeException.Message;

				switch (stripeException.StripeError.Code)
				{
					case "invalid_expiry_month":
						break;
					case "invalid_cvc":
						break;
					case "expired_card":
						break;
					case "incorrect_cvc":
						break;
					case "card_declined":
						break;
					case "processing_error":
						break;
				}
				successful = false;
				result = null;
			}
			catch (Exception exception)
			{
				Logger.TraceErr(exception);
				successful = false;
				finalMessage = "Card Processing Failure: " + exception.Message;
				result = null;
			}
			if (successful)
			{
				finalMessage = "Purchase Complete!";
				try
				{
					var jsonSerializer = new JsonSerializer();
					var jsonStringWriter = new StringWriter();
					var jsonTextWriter = new JsonTextWriter(jsonStringWriter);
					jsonSerializer.Serialize(jsonTextWriter, result);
					Logger.TraceInfo(jsonStringWriter.ToString());
				}
				catch (Exception exception)
				{
					Logger.TraceErr(exception);
				}
			}
			response = String.Format("{0}, {1}", successful, finalMessage);
			return result;
		}
		static private StripeCustomerUpdateOptions SetUpdateCustomer(StripeCustomer oldCustomer, CreditCardInformation creditCardInfo, string productName)
		{
			var customerUpdateOptions = new StripeCustomerUpdateOptions
								{
									Email = creditCardInfo.Email,
									CardNumber = creditCardInfo.CardNumber,
									CardExpirationMonth = creditCardInfo.ExpMonth,
									CardExpirationYear = creditCardInfo.ExpYear,
									CardCvc = creditCardInfo.CVV2,
									CardName = creditCardInfo.FirstName + " " + creditCardInfo.LastName
								};
			//if (oldCustomer.Description != oldCustomer.StripeCard.Name + " (" + oldCustomer.Email + ")" + " has purchased tubeCore")
			//    customerUpdateOptions.Description = oldCustomer.Description + " and tubeCore";
			//else
			//    customerUpdateOptions.Description = customerUpdateOptions.CardName + " (" + customerUpdateOptions.Email + ")" + " has purchased tubeCore";
			if (!Utility.IsStringEmpty(oldCustomer.Description) && oldCustomer.Description.Contains("has purchased"))
				customerUpdateOptions.Description += string.Format("{0} and {1}", oldCustomer.Description, productName);
			else
				customerUpdateOptions.Description = string.Format("{0} ({1}) has purchased {2}", customerUpdateOptions.CardName, customerUpdateOptions.Email, productName);
			return customerUpdateOptions;
		}
		// Methods for doing Stripe payment
		static private StripeCustomerCreateOptions SetNewCustomer(CreditCardInformation creditCardInfo, string productName)
		{
			var newCustomer = new StripeCustomerCreateOptions
								{
									Email = creditCardInfo.Email,
									CardNumber = creditCardInfo.CardNumber,
									CardExpirationMonth = creditCardInfo.ExpMonth,
									CardExpirationYear = creditCardInfo.ExpYear,
									CardName = creditCardInfo.FirstName + " " + creditCardInfo.LastName
								};
			newCustomer.Description = string.Format("{0} ({1}) has purchased {2}", newCustomer.CardName, newCustomer.Email, productName);
			return newCustomer;
		}
Exemple #25
0
        public void EnvelopeCreateWithDocumentTest()
        {
            ConfigLoader.LoadConfig();

            bool expected = true;
            bool actual   = false;

            Account acct = new Account();

            acct.AccountName = Util.MakeUnique("freakin me out {unique}");
            acct.Email       = Util.MakeUnique("freakin_{unique}@gmail.com");
            acct.Password    = "******";

            AddressInformation ai = new AddressInformation();

            acct.Address  = ai;
            ai.address1   = "123 Main ST";
            ai.address2   = string.Empty;
            ai.city       = "Anytown";
            ai.country    = "USA";
            ai.postalCode = "11111";
            ai.state      = "WA";

            CreditCardInformation cc = new CreditCardInformation();

            acct.CreditCard    = cc;
            cc.cardNumber      = "4111111111111111";
            cc.cardType        = "visa";
            cc.expirationMonth = "12";
            cc.expirationYear  = "2015";
            cc.nameOnCard      = "Freak Me Out";

            try
            {
                actual = acct.Create();
            }
            catch (Exception)
            {
            }

            Assert.AreEqual(expected, actual);
            Assert.IsFalse(string.IsNullOrEmpty(acct.BaseUrl));

            Envelope target = new Envelope();

            target.Login = acct;
            FileInfo fi   = new FileInfo("./Test Contract.pdf");
            string   path = fi.FullName;

            actual = false;

            try
            {
                actual = target.Create(path);
            }
            catch (ArgumentNullException)
            {
            }

            Assert.AreEqual(expected, actual);
            Assert.IsFalse(string.IsNullOrEmpty(target.SenderViewUrl));
        }
        public void EnvelopeCreateWithSmsAuthenticationDocumentTest()
        {
            ConfigLoader.LoadConfig();

            bool expected = true;
            bool actual   = false;

            Account acct = new Account();

            acct.AccountName = Util.MakeUnique("freakin me out {unique}");
            acct.Email       = Util.MakeUnique("freakin_{unique}@gmail.com");
            acct.Password    = "******";

            AddressInformation ai = new AddressInformation();

            acct.Address  = ai;
            ai.address1   = "123 Main ST";
            ai.address2   = string.Empty;
            ai.city       = "Anytown";
            ai.country    = "USA";
            ai.postalCode = "11111";
            ai.state      = "WA";

            CreditCardInformation cc = new CreditCardInformation();

            acct.CreditCard    = cc;
            cc.cardNumber      = "4111111111111111";
            cc.cardType        = "visa";
            cc.expirationMonth = "12";
            cc.expirationYear  = "2015";
            cc.nameOnCard      = "Freak Me Out";

            try
            {
                actual = acct.Create();
            }
            catch (Exception)
            {
            }

            Assert.AreEqual(expected, actual);
            Assert.IsFalse(string.IsNullOrEmpty(acct.BaseUrl));

            if (expected == actual)
            {
                Envelope target = new Envelope();
                target.Login = acct;

                // add signers to the envelope
                target.Recipients = new Recipients()
                {
                    signers = new Signer[]
                    {
                        new Signer()
                        {
                            email                    = "freakin_{unique}@gmail.com",
                            name                     = "freakin",
                            routingOrder             = "1",
                            recipientId              = "1",
                            requireIdLookup          = "true",
                            idCheckConfigurationName = "SMS Auth $",
                            smsAuthentication        = new SmsAuthentication()
                            {
                                senderProvidedNumbers = new string[]
                                {
                                    String.Format("+{0} {1}", "34", "000000000")
                                }
                            }
                        }
                    }
                };

                // Email subject is a required parameter when requesting signatures
                target.EmailSubject = "Example subject";

                // "sent" to send immediately, "created" to save envelope as draft
                target.Status = "sent";

                FileInfo fi   = new FileInfo("./Test Contract.pdf");
                string   path = fi.FullName;

                actual = false;

                try
                {
                    actual = target.Create(path);
                }
                catch (ArgumentNullException)
                {
                }

                Assert.AreEqual(expected, actual);
                Assert.IsFalse(string.IsNullOrEmpty(target.SenderViewUrl));
            }
        }
Exemple #27
0
 public IResult Update(CreditCardInformation creditCardInformation)
 {
     _creditCardInformationDal.Update(creditCardInformation);
     return(new SuccessResult(Messages.Successful));
 }
Exemple #28
0
 public IResult CheckIfCreditCardLegit(CreditCardInformation creditCardInformation)
 {
     return(new SuccessResult());
 }
		public bool EditCreditCard(CreditCardInformation creditCardInformation)
		{
			var vm = new EditCreditCardViewModel { CreditCardInformation = creditCardInformation };
			var dialog = new EditCreditCardMetroWindow
			{
				Owner = (Window)ShellHandle,
				DataContext = vm,
			};
			ShellHandle = dialog;
			var result = dialog.ShowDialog();
			ShellHandle = dialog.Owner;
			return result.HasValue && result.Value;
		}