Ejemplo n.º 1
0
        protected internal override Transaction DoTransfer(PaySession session, Account from, Account to, Amount amount, string description = null, object extraData = null)
        {
            if (description.IsNullOrWhiteSpace())
            {
                description = m_PayoutNote;
            }

            return(new Transaction(
                       session.GenerateTransactionID(TransactionType.Transfer), TransactionType.Transfer, TransactionStatus.Promised,
                       from, to, Name, null, App.TimeSource.UTCNow, amount, description: description, extraData: extraData));
        }
Ejemplo n.º 2
0
        protected internal override Transaction DoCharge(PaySession session, Account from, Account to, Amount amount, bool capture = true, string description = null, object extraData = null)
        {
            var fromActualData = session.FetchAccountData(from);

            if (fromActualData == null)
            {
                StatChargeError();
                throw new PaymentMockException(StringConsts.PAYMENT_UNKNOWN_ACCOUNT_ERROR.Args(from) + this.GetType().Name + ".Charge");
            }

            if (m_Accounts.CreditCardDeclined.Any(c => c.AccountNumber == fromActualData.AccountID.ToString()))
            {
                StatChargeError();
                throw new PaymentMockException(this.GetType().Name + ".Charge: card '{0}' declined".Args(fromActualData));
            }

            if (m_Accounts.CreditCardLuhnError.Any(c => c.AccountNumber == fromActualData.AccountID.ToString()))
            {
                StatChargeError();
                throw new PaymentMockException(this.GetType().Name + ".Charge: card number '{0}' is incorrect".Args(fromActualData));
            }


            AccountData foundAccount = null;

            foundAccount = m_Accounts.CreditCardsCorrect.FirstOrDefault(c => c.AccountNumber == fromActualData.AccountID.ToString());

            if (foundAccount != null)
            {
                if (foundAccount.CardExpirationYear != fromActualData.CardExpirationDate.Value.Year)
                {
                    StatChargeError();
                    throw new PaymentMockException(StringConsts.PAYMENT_INVALID_EXPIRATION_DATE_ERROR
                                                   .Args(fromActualData.CardExpirationDate.Value.Year, fromActualData.CardExpirationDate.Value.Month) + this.GetType().Name + ".Charge");
                }

                if (foundAccount.CardExpirationMonth != fromActualData.CardExpirationDate.Value.Month)
                {
                    StatChargeError();
                    throw new PaymentMockException(StringConsts.PAYMENT_INVALID_EXPIRATION_DATE_ERROR
                                                   .Args(fromActualData.CardExpirationDate.Value.Year, fromActualData.CardExpirationDate.Value.Month) + this.GetType().Name + ".Charge");
                }

                if (foundAccount.CardVC != fromActualData.CardVC)
                {
                    StatChargeError();
                    throw new PaymentMockException(StringConsts.PAYMENT_INVALID_CVC_ERROR + this.GetType().Name + ".Charge");
                }

                var created = DateTime.UtcNow;

                var taId = session.GenerateTransactionID(TransactionType.Charge);

                var ta = new Transaction(taId, TransactionType.Charge, TransactionStatus.Success, from, to, this.Name, taId, created, amount, description: description, extraData: extraData);

                StatCharge(amount);

                return(ta);
            }

            foundAccount = m_Accounts.CreditCardCorrectWithAddr.FirstOrDefault(c => c.AccountNumber == fromActualData.AccountID.ToString());

            if (foundAccount != null)
            {
                if (foundAccount.CardExpirationYear != fromActualData.CardExpirationDate.Value.Year)
                {
                    StatChargeError();
                    throw new PaymentMockException(StringConsts.PAYMENT_INVALID_EXPIRATION_DATE_ERROR
                                                   .Args(fromActualData.CardExpirationDate.Value.Year, fromActualData.CardExpirationDate.Value.Month) + this.GetType().Name + ".Charge");
                }

                if (foundAccount.CardExpirationMonth != fromActualData.CardExpirationDate.Value.Month)
                {
                    StatChargeError();
                    throw new PaymentMockException(StringConsts.PAYMENT_INVALID_EXPIRATION_DATE_ERROR
                                                   .Args(fromActualData.CardExpirationDate.Value.Year, fromActualData.CardExpirationDate.Value.Month) + this.GetType().Name + ".Charge");
                }

                if (foundAccount.CardVC != fromActualData.CardVC)
                {
                    StatChargeError();
                    throw new PaymentMockException(StringConsts.PAYMENT_INVALID_CVC_ERROR.Args(fromActualData.CardVC) + this.GetType().Name + ".Charge");
                }

                if (foundAccount.BillingAddress1 != fromActualData.BillingAddress.Address1 ||
                    foundAccount.BillingAddress2 != fromActualData.BillingAddress.Address2 ||
                    foundAccount.BillingCountry != fromActualData.BillingAddress.Country ||
                    foundAccount.BillingCity != fromActualData.BillingAddress.City ||
                    foundAccount.BillingPostalCode != fromActualData.BillingAddress.PostalCode ||
                    foundAccount.BillingRegion != fromActualData.BillingAddress.Region ||
                    foundAccount.BillingEmail != fromActualData.BillingAddress.EMail ||
                    foundAccount.BillingPhone != fromActualData.BillingAddress.Phone)
                {
                    StatChargeError();
                    throw new PaymentMockException(StringConsts.PAYMENT_INVALID_ADDR_ERROR + this.GetType().Name + ".Charge");
                }

                var created = DateTime.UtcNow;

                var taId = session.GenerateTransactionID(TransactionType.Charge);

                var ta = new Transaction(taId, TransactionType.Charge, TransactionStatus.Success, from, to, this.Name, taId, created, amount, description: description, extraData: extraData);

                StatCharge(amount);

                return(ta);
            }

            throw new PaymentException(StringConsts.PAYMENT_INVALID_CARD_NUMBER_ERROR + this.GetType().Name + ".Charge");
        }
Ejemplo n.º 3
0
        protected internal override Transaction DoTransfer(PaySession session, Account from, Account to, Amount amount, string description = null, object extraData = null)
        {
            var actualAccountData = session.FetchAccountData(to);

            if (actualAccountData == null)
            {
                StatTransferError();
                throw new PaymentMockException(StringConsts.PAYMENT_UNKNOWN_ACCOUNT_ERROR.Args(from) + this.GetType().Name + ".Transfer");
            }

            AccountData accountData = null;

            accountData = m_Accounts.DebitBankCorrect.FirstOrDefault(c => c.AccountNumber == actualAccountData.AccountID.ToString() &&
                                                                     c.CardExpirationYear == actualAccountData.CardExpirationDate.Value.Year &&
                                                                     c.CardExpirationMonth == actualAccountData.CardExpirationDate.Value.Month &&
                                                                     c.CardVC == actualAccountData.CardVC);

            if (accountData != null)
            {
                var created = DateTime.Now;

                var taId = session.GenerateTransactionID(TransactionType.Transfer);

                var ta = new Transaction(taId, TransactionType.Transfer, TransactionStatus.Success, Account.EmptyInstance, to, this.Name, taId, created, amount, description: description, extraData: extraData);

                StatTransfer(amount);

                return(ta);
            }

            accountData = m_Accounts.DebitCardCorrect.FirstOrDefault(c => c.AccountNumber == actualAccountData.AccountID.ToString() &&
                                                                     c.CardExpirationYear == actualAccountData.CardExpirationDate.Value.Year &&
                                                                     c.CardExpirationMonth == actualAccountData.CardExpirationDate.Value.Month &&
                                                                     c.CardVC == actualAccountData.CardVC);

            if (accountData != null)
            {
                var created = DateTime.Now;

                var taId = session.GenerateTransactionID(TransactionType.Transfer);

                var ta = new Transaction(taId, TransactionType.Transfer, TransactionStatus.Success, Account.EmptyInstance, to, this.Name, taId, created, amount, description: description, extraData: extraData);

                StatTransfer(amount);

                return(ta);
            }

            accountData = m_Accounts.DebitCardCorrectWithAddr.FirstOrDefault(c => c.AccountNumber == actualAccountData.AccountID.ToString() &&
                                                                             c.CardExpirationYear == actualAccountData.CardExpirationDate.Value.Year &&
                                                                             c.CardExpirationMonth == actualAccountData.CardExpirationDate.Value.Month &&
                                                                             c.CardVC == actualAccountData.CardVC &&
                                                                             c.BillingAddress1 != actualAccountData.BillingAddress.Address1 &&
                                                                             c.BillingAddress2 != actualAccountData.BillingAddress.Address2 &&
                                                                             c.BillingCountry != actualAccountData.BillingAddress.Country &&
                                                                             c.BillingCity != actualAccountData.BillingAddress.City &&
                                                                             c.BillingPostalCode != actualAccountData.BillingAddress.PostalCode &&
                                                                             c.BillingRegion != actualAccountData.BillingAddress.Region &&
                                                                             c.BillingEmail != actualAccountData.BillingAddress.EMail &&
                                                                             c.BillingPhone != actualAccountData.BillingAddress.Phone);

            if (accountData != null)
            {
                var created = DateTime.Now;

                var taId = session.GenerateTransactionID(TransactionType.Transfer);

                var ta = new Transaction(taId, TransactionType.Transfer, TransactionStatus.Success, Account.EmptyInstance, to, this.Name, taId, created, amount, description: description, extraData: extraData);

                StatTransfer(amount);

                return(ta);
            }

            StatTransferError();
            throw new PaymentException(StringConsts.PAYMENT_INVALID_CARD_NUMBER_ERROR + this.GetType().Name + ".Transfer");
        }