コード例 #1
0
        /// <summary>
        /// Gets the hash code for this object.
        /// </summary>
        /// <returns>
        /// The hash code for this object.
        /// </returns>
        /// <remarks>
        /// * CA2218:
        ///   * If two objects are equal in value based on the Equals override, they must both return the same value for calls
        ///     to GetHashCode.
        ///   * GetHashCode must be overridden whenever Equals is overridden.
        /// * It is fine if the value overflows.
        /// </remarks>
        public override int GetHashCode()
        {
            int result = Id.GetHashCode() +
                         GlobalUserId.GetHashCode() +
                         Expiration.GetHashCode() +
                         CardBrand.GetHashCode() +
                         RewardPrograms.GetHashCode();

            if (NameOnCard != null)
            {
                result += NameOnCard.GetHashCode();
            }

            if (LastFourDigits != null)
            {
                result += LastFourDigits.GetHashCode();
            }

            if (PanToken != null)
            {
                result += PanToken.GetHashCode();
            }

            return(result);
        }
コード例 #2
0
ファイル: CreditCard.cs プロジェクト: GTravesty/QBSDK
            public XElement ToQBXML(string name)
            {
                XElement xElement = new XElement(name);

                xElement.Add(CreditCardNumber.ToQBXML(nameof(CreditCardNumber)));
                xElement.Add(ExpirationMonth.ToQBXML(nameof(ExpirationMonth)));
                xElement.Add(ExpirationYear.ToQBXML(nameof(ExpirationYear)));
                xElement.Add(NameOnCard.ToQBXML(nameof(NameOnCard)));
                xElement.Add(CreditCardAddress.ToQBXML(nameof(CreditCardAddress)));
                xElement.Add(CreditCardPostalCode.ToQBXML(nameof(CreditCardPostalCode)));
                return(xElement);
            }
コード例 #3
0
        /// <summary>
        /// Sets from payment information.
        /// </summary>
        /// <param name="paymentInfo">The payment information.</param>
        /// <param name="paymentGateway">The payment gateway.</param>
        /// <param name="rockContext">The rock context.</param>
        public void SetFromPaymentInfo(PaymentInfo paymentInfo, GatewayComponent paymentGateway, RockContext rockContext)
        {
            if (AccountNumberMasked.IsNullOrWhiteSpace() && paymentInfo.MaskedNumber.IsNotNullOrWhiteSpace())
            {
                AccountNumberMasked = paymentInfo.MaskedNumber;
            }

            if (!CurrencyTypeValueId.HasValue && paymentInfo.CurrencyTypeValue != null)
            {
                CurrencyTypeValueId = paymentInfo.CurrencyTypeValue.Id;
            }

            if (!CreditCardTypeValueId.HasValue && paymentInfo.CreditCardTypeValue != null)
            {
                CreditCardTypeValueId = paymentInfo.CreditCardTypeValue.Id;
            }

            if (paymentInfo is CreditCardPaymentInfo)
            {
                var ccPaymentInfo = (CreditCardPaymentInfo)paymentInfo;

                string nameOnCard  = paymentGateway.SplitNameOnCard ? ccPaymentInfo.NameOnCard + " " + ccPaymentInfo.LastNameOnCard : ccPaymentInfo.NameOnCard;
                var    newLocation = new LocationService(rockContext).Get(
                    ccPaymentInfo.BillingStreet1, ccPaymentInfo.BillingStreet2, ccPaymentInfo.BillingCity, ccPaymentInfo.BillingState, ccPaymentInfo.BillingPostalCode, ccPaymentInfo.BillingCountry);

                if (NameOnCard.IsNullOrWhiteSpace() && NameOnCard.IsNotNullOrWhiteSpace())
                {
                    NameOnCardEncrypted = Encryption.EncryptString(nameOnCard);
                }

                if (!ExpirationMonth.HasValue)
                {
                    ExpirationMonthEncrypted = Encryption.EncryptString(ccPaymentInfo.ExpirationDate.Month.ToString());
                }

                if (!ExpirationYear.HasValue)
                {
                    ExpirationYearEncrypted = Encryption.EncryptString(ccPaymentInfo.ExpirationDate.Year.ToString());
                }

                if (!BillingLocationId.HasValue && newLocation != null)
                {
                    BillingLocationId = newLocation.Id;
                }
            }
            else if (paymentInfo is SwipePaymentInfo)
            {
                var swipePaymentInfo = (SwipePaymentInfo)paymentInfo;

                if (NameOnCard.IsNullOrWhiteSpace() && NameOnCard.IsNotNullOrWhiteSpace())
                {
                    NameOnCardEncrypted = Encryption.EncryptString(swipePaymentInfo.NameOnCard);
                }

                if (!ExpirationMonth.HasValue)
                {
                    ExpirationMonthEncrypted = Encryption.EncryptString(swipePaymentInfo.ExpirationDate.Month.ToString());
                }

                if (!ExpirationYear.HasValue)
                {
                    ExpirationYearEncrypted = Encryption.EncryptString(swipePaymentInfo.ExpirationDate.Year.ToString());
                }
            }
            else
            {
                var newLocation = new LocationService(rockContext).Get(
                    paymentInfo.Street1, paymentInfo.Street2, paymentInfo.City, paymentInfo.State, paymentInfo.PostalCode, paymentInfo.Country);

                if (!BillingLocationId.HasValue && newLocation != null)
                {
                    BillingLocationId = newLocation.Id;
                }
            }
        }
コード例 #4
0
        /// <summary>
        /// Sets any payment information that the <seealso cref="GatewayComponent">paymentGateway</seealso> didn't set
        /// </summary>
        /// <param name="paymentInfo">The payment information.</param>
        /// <param name="paymentGateway">The payment gateway.</param>
        /// <param name="rockContext">The rock context.</param>
        public void SetFromPaymentInfo(PaymentInfo paymentInfo, GatewayComponent paymentGateway, RockContext rockContext)
        {
            /* 2020-08-27 MDP
             * This method should only update values haven't been set yet. So
             *  1) Make sure paymentInfo has the data (isn't null or whitespace)
             *  2) Don't overwrite data in this (FinancialPaymentDetail) that already has the data set.
             */

            if (AccountNumberMasked.IsNullOrWhiteSpace() && paymentInfo.MaskedNumber.IsNotNullOrWhiteSpace())
            {
                AccountNumberMasked = paymentInfo.MaskedNumber;
            }

            if (paymentInfo is ReferencePaymentInfo referencePaymentInfo)
            {
                if (GatewayPersonIdentifier.IsNullOrWhiteSpace())
                {
                    GatewayPersonIdentifier = referencePaymentInfo.GatewayPersonIdentifier;
                }

                if (!FinancialPersonSavedAccountId.HasValue)
                {
                    FinancialPersonSavedAccountId = referencePaymentInfo.FinancialPersonSavedAccountId;
                }
            }

            if (!CurrencyTypeValueId.HasValue && paymentInfo.CurrencyTypeValue != null)
            {
                CurrencyTypeValueId = paymentInfo.CurrencyTypeValue.Id;
            }

            if (!CreditCardTypeValueId.HasValue && paymentInfo.CreditCardTypeValue != null)
            {
                CreditCardTypeValueId = paymentInfo.CreditCardTypeValue.Id;
            }

            if (paymentInfo is CreditCardPaymentInfo)
            {
                var ccPaymentInfo = ( CreditCardPaymentInfo )paymentInfo;

                string nameOnCard = paymentGateway.SplitNameOnCard ? ccPaymentInfo.NameOnCard + " " + ccPaymentInfo.LastNameOnCard : ccPaymentInfo.NameOnCard;

                // since the Address info could coming from an external system (the Gateway), don't do Location validation when creating a new location
                var newLocation = new LocationService(rockContext).Get(
                    ccPaymentInfo.BillingStreet1, ccPaymentInfo.BillingStreet2, ccPaymentInfo.BillingCity, ccPaymentInfo.BillingState, ccPaymentInfo.BillingPostalCode, ccPaymentInfo.BillingCountry, new GetLocationArgs {
                    ValidateLocation = false, CreateNewLocation = true
                });

                if (NameOnCard.IsNullOrWhiteSpace() && nameOnCard.IsNotNullOrWhiteSpace())
                {
                    NameOnCard = nameOnCard;
                }

                if (!ExpirationMonth.HasValue)
                {
                    ExpirationMonth = ccPaymentInfo.ExpirationDate.Month;
                }

                if (!ExpirationYear.HasValue)
                {
                    ExpirationYear = ccPaymentInfo.ExpirationDate.Year;
                }

                if (!BillingLocationId.HasValue && newLocation != null)
                {
                    BillingLocationId = newLocation.Id;
                }
            }
            else if (paymentInfo is SwipePaymentInfo)
            {
                var swipePaymentInfo = ( SwipePaymentInfo )paymentInfo;

                if (NameOnCard.IsNullOrWhiteSpace() && swipePaymentInfo.NameOnCard.IsNotNullOrWhiteSpace())
                {
                    NameOnCard = swipePaymentInfo.NameOnCard;
                }

                if (!ExpirationMonth.HasValue)
                {
                    ExpirationMonth = swipePaymentInfo.ExpirationDate.Month;
                }

                if (!ExpirationYear.HasValue)
                {
                    ExpirationYear = swipePaymentInfo.ExpirationDate.Year;
                }
            }
            else
            {
                // since the Address info could coming from an external system (the Gateway), don't do Location validation when creating a new location
                var newLocation = new LocationService(rockContext).Get(
                    paymentInfo.Street1, paymentInfo.Street2, paymentInfo.City, paymentInfo.State, paymentInfo.PostalCode, paymentInfo.Country, new GetLocationArgs {
                    ValidateLocation = false, CreateNewLocation = true
                });

                if (!BillingLocationId.HasValue && newLocation != null)
                {
                    BillingLocationId = newLocation.Id;
                }
            }
        }
コード例 #5
0
        /// <summary>
        /// Sets any payment information that the <seealso cref="GatewayComponent">paymentGateway</seealso> didn't set
        /// </summary>
        /// <param name="paymentInfo">The payment information.</param>
        /// <param name="paymentGateway">The payment gateway.</param>
        /// <param name="rockContext">The rock context.</param>
        public void SetFromPaymentInfo(PaymentInfo paymentInfo, GatewayComponent paymentGateway, RockContext rockContext)
        {
            /* 2020-08-27 MDP
             * This method should only update values haven't been set yet. So
             *  1) Make sure paymentInfo has the data (isn't null or whitespace)
             *  2) Don't overwrite data in this (FinancialPaymentDetail) that already has the data set.
             */

            if (AccountNumberMasked.IsNullOrWhiteSpace() && paymentInfo.MaskedNumber.IsNotNullOrWhiteSpace())
            {
                AccountNumberMasked = paymentInfo.MaskedNumber;
            }

            if (paymentInfo is ReferencePaymentInfo referencePaymentInfo)
            {
                if (GatewayPersonIdentifier.IsNullOrWhiteSpace())
                {
                    GatewayPersonIdentifier = referencePaymentInfo.GatewayPersonIdentifier;
                }

                if (!FinancialPersonSavedAccountId.HasValue)
                {
                    FinancialPersonSavedAccountId = referencePaymentInfo.FinancialPersonSavedAccountId;
                }
            }

            if (!CurrencyTypeValueId.HasValue && paymentInfo.CurrencyTypeValue != null)
            {
                CurrencyTypeValueId = paymentInfo.CurrencyTypeValue.Id;
            }

            if (!CreditCardTypeValueId.HasValue && paymentInfo.CreditCardTypeValue != null)
            {
                CreditCardTypeValueId = paymentInfo.CreditCardTypeValue.Id;
            }

            if (paymentInfo is CreditCardPaymentInfo)
            {
                var ccPaymentInfo = ( CreditCardPaymentInfo )paymentInfo;

                string nameOnCard  = paymentGateway.SplitNameOnCard ? ccPaymentInfo.NameOnCard + " " + ccPaymentInfo.LastNameOnCard : ccPaymentInfo.NameOnCard;
                var    newLocation = new LocationService(rockContext).Get(
                    ccPaymentInfo.BillingStreet1, ccPaymentInfo.BillingStreet2, ccPaymentInfo.BillingCity, ccPaymentInfo.BillingState, ccPaymentInfo.BillingPostalCode, ccPaymentInfo.BillingCountry);

                if (NameOnCard.IsNullOrWhiteSpace() && NameOnCard.IsNotNullOrWhiteSpace())
                {
                    NameOnCardEncrypted = Encryption.EncryptString(nameOnCard);
                }

                if (!ExpirationMonth.HasValue)
                {
                    ExpirationMonthEncrypted = Encryption.EncryptString(ccPaymentInfo.ExpirationDate.Month.ToString());
                }

                if (!ExpirationYear.HasValue)
                {
                    ExpirationYearEncrypted = Encryption.EncryptString(ccPaymentInfo.ExpirationDate.Year.ToString());
                }

                if (!BillingLocationId.HasValue && newLocation != null)
                {
                    BillingLocationId = newLocation.Id;
                }
            }
            else if (paymentInfo is SwipePaymentInfo)
            {
                var swipePaymentInfo = ( SwipePaymentInfo )paymentInfo;

                if (NameOnCard.IsNullOrWhiteSpace() && NameOnCard.IsNotNullOrWhiteSpace())
                {
                    NameOnCardEncrypted = Encryption.EncryptString(swipePaymentInfo.NameOnCard);
                }

                if (!ExpirationMonth.HasValue)
                {
                    ExpirationMonthEncrypted = Encryption.EncryptString(swipePaymentInfo.ExpirationDate.Month.ToString());
                }

                if (!ExpirationYear.HasValue)
                {
                    ExpirationYearEncrypted = Encryption.EncryptString(swipePaymentInfo.ExpirationDate.Year.ToString());
                }
            }
            else
            {
                var newLocation = new LocationService(rockContext).Get(
                    paymentInfo.Street1, paymentInfo.Street2, paymentInfo.City, paymentInfo.State, paymentInfo.PostalCode, paymentInfo.Country);

                if (!BillingLocationId.HasValue && newLocation != null)
                {
                    BillingLocationId = newLocation.Id;
                }
            }
        }