コード例 #1
0
        internal override void WriteXml(XmlTextWriter xmlWriter)
        {
            xmlWriter.WriteStartElement("billing_info"); // Start: billing_info

            //if a recurly js token is supplied we don't want to send billing info here
            if (string.IsNullOrEmpty(TokenId))
            {
                xmlWriter.WriteStringIfValid("first_name", FirstName);
                xmlWriter.WriteStringIfValid("last_name", LastName);
                xmlWriter.WriteStringIfValid("name_on_account", NameOnAccount);
                xmlWriter.WriteStringIfValid("address1", Address1);
                xmlWriter.WriteStringIfValid("address2", Address2);
                xmlWriter.WriteStringIfValid("city", City);
                xmlWriter.WriteStringIfValid("state", State);
                xmlWriter.WriteStringIfValid("zip", PostalCode);
                xmlWriter.WriteStringIfValid("country", Country);
                xmlWriter.WriteStringIfValid("phone", PhoneNumber);
                xmlWriter.WriteStringIfValid("vat_number", VatNumber);
                xmlWriter.WriteStringIfValid("currency", Currency);

                if (!IpAddress.IsNullOrEmpty())
                {
                    xmlWriter.WriteElementString("ip_address", IpAddress);
                }
                else
                {
                    Debug.WriteLine("Recurly Client Library: Recording IP Address is strongly recommended.");
                }

                if (!CreditCardNumber.IsNullOrEmpty())
                {
                    xmlWriter.WriteElementString("number", CreditCardNumber);
                    xmlWriter.WriteElementString("month", ExpirationMonth.AsString());
                    xmlWriter.WriteElementString("year", ExpirationYear.AsString());

                    xmlWriter.WriteStringIfValid("verification_value", VerificationValue);
                }

                if (!AccountNumber.IsNullOrEmpty())
                {
                    xmlWriter.WriteElementString("routing_number", RoutingNumber);
                    xmlWriter.WriteElementString("account_number", AccountNumber);
                    xmlWriter.WriteElementString("account_type", AccountType.ToString().EnumNameToTransportCase());
                }

                if (!PaypalBillingAgreementId.IsNullOrEmpty())
                {
                    xmlWriter.WriteElementString("paypal_billing_agreement_id", PaypalBillingAgreementId);
                }

                if (!AmazonBillingAgreementId.IsNullOrEmpty())
                {
                    xmlWriter.WriteElementString("amazon_billing_agreement_id", AmazonBillingAgreementId);
                }
            }

            xmlWriter.WriteStringIfValid("token_id", TokenId);

            xmlWriter.WriteEndElement(); // End: billing_info
        }
コード例 #2
0
        public override int GetHashCode()
        {
            unchecked {
                int hash = 17;
                if (Country != default(string))
                {
                    hash = hash * 23 + Country.GetHashCode();
                }
                if (City != default(string))
                {
                    hash = hash * 23 + City.GetHashCode();
                }
                if (Bank != default(string))
                {
                    hash = hash * 23 + Bank.GetHashCode();
                }
                if (PostalCode != default(string))
                {
                    hash = hash * 23 + PostalCode.GetHashCode();
                }
                if (Financing != default(string))
                {
                    hash = hash * 23 + Financing.GetHashCode();
                }
                if (LastDigits != default(string))
                {
                    hash = hash * 23 + LastDigits.GetHashCode();
                }
                if (Brand != default(string))
                {
                    hash = hash * 23 + Brand.GetHashCode();
                }
                if (ExpirationMonth != default(int))
                {
                    hash = hash * 23 + ExpirationMonth.GetHashCode();
                }
                if (ExpirationYear != default(int))
                {
                    hash = hash * 23 + ExpirationYear.GetHashCode();
                }
                if (Fingerprint != default(string))
                {
                    hash = hash * 23 + Fingerprint.GetHashCode();
                }
                if (Name != default(string))
                {
                    hash = hash * 23 + Name.GetHashCode();
                }
                if (SecurityCodeCheck != default(bool))
                {
                    hash = hash * 23 + SecurityCodeCheck.GetHashCode();
                }

                return(hash);
            }
        }
コード例 #3
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);
            }
コード例 #4
0
        public virtual int _GetUniqueIdentifier()
        {
            var hashCode = 399326290;

            hashCode = hashCode * -1521134295 + (Id?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (PaymentMethod?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (CardholderName?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (CardNumber?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (CCV?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (ExpirationMonth?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (ExpirationYear?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (IBANNumber?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (BankName?.GetHashCode() ?? 0);
            return(hashCode);
        }
コード例 #5
0
        public bool IsExpired()
        {
            if (!ExpirationMonth.HasValue() || !ExpirationYear.HasValue())
            {
                return(false); // Prevent expiration verification from failing
            }

            var expYear        = int.Parse(ExpirationYear);
            var expMonth       = int.Parse(ExpirationMonth);
            var expirationDate = new DateTime(expYear, expMonth, DateTime.DaysInMonth(expYear, expMonth), 23, 59, 59);

            if (expirationDate < DateTime.Now)
            {
                return(true);
            }

            return(false);
        }
コード例 #6
0
        public static IEnumerable <ExpirationMonth> GetExpirationMonths()
        {
            var returnList = new List <ExpirationMonth>();

            for (var i = 1; i <= 12; i++)
            {
                string strMonthName = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(i);

                var expireMonth = new ExpirationMonth()
                {
                    Month     = i,
                    MonthName = strMonthName,
                };

                returnList.Add(expireMonth);
            }

            return(returnList);
        }
コード例 #7
0
        public override int GetHashCode()
        {
            unchecked {
                int hash = 17;
                hash = hash * 23 + Country.GetHashCode();
                hash = hash * 23 + City.GetHashCode();
                hash = hash * 23 + Bank.GetHashCode();
                hash = hash * 23 + PostalCode.GetHashCode();
                hash = hash * 23 + Financing.GetHashCode();
                hash = hash * 23 + LastDigits.GetHashCode();
                hash = hash * 23 + Brand.GetHashCode();
                hash = hash * 23 + ExpirationMonth.GetHashCode();
                hash = hash * 23 + ExpirationYear.GetHashCode();
                hash = hash * 23 + Fingerprint.GetHashCode();
                hash = hash * 23 + Name.GetHashCode();
                hash = hash * 23 + SecurityCodeCheck.GetHashCode();

                return(hash);
            }
        }
コード例 #8
0
        void control_OnEditCardInfo(object sender, CardInfoDetailEventArgs e)
        {
            GatewayPaymentProfile profile = GatewayPaymentProfileDataSource.Load(e.ProfileId);

            if (profile != null)
            {
                HiddenProfileId.Value = profile.Id.ToString();
                NameOnCardLabel.Text  = string.Format("{0}", profile.NameOnCard);
                ReferenceLabel.Text   = string.Format("Profile {0} ending in {1}", profile.InstrumentType, profile.ReferenceNumber);

                string   profileExpiry = profile.Expiry.ToString();
                string[] dateParts     = profileExpiry.Split('/');
                string   expiryMonth   = (dateParts[0].Length == 1) ? "0" + dateParts[0] : dateParts[0];
                string   expiryDay     = dateParts[1];
                string   expiryYear    = dateParts[2].Substring(0, 4);

                ListItem selectedYear = ExpirationYear.Items.FindByValue(expiryYear);
                if (selectedYear != null)
                {
                    ExpirationYear.ClearSelection();
                    selectedYear.Selected = true;
                }

                ListItem selectedMonth = ExpirationMonth.Items.FindByValue(expiryMonth);
                if (selectedMonth != null)
                {
                    ExpirationMonth.ClearSelection();
                    selectedMonth.Selected = true;
                }

                EditCardInfoPopUp.Show();
            }
            else
            {
                HiddenProfileId.Value = string.Empty;
            }
        }
コード例 #9
0
        internal override void WriteXml(XmlTextWriter xmlWriter)
        {
            xmlWriter.WriteStartElement("billing_info"); // Start: billing_info
            xmlWriter.WriteStringIfValid("first_name", FirstName);
            xmlWriter.WriteStringIfValid("last_name", LastName);
            xmlWriter.WriteStringIfValid("address1", Address1);
            xmlWriter.WriteStringIfValid("address2", Address2);
            xmlWriter.WriteStringIfValid("city", City);
            xmlWriter.WriteStringIfValid("state", State);
            xmlWriter.WriteStringIfValid("zip", PostalCode);
            xmlWriter.WriteStringIfValid("country", Country);
            xmlWriter.WriteStringIfValid("phone", PhoneNumber);

            xmlWriter.WriteStringIfValid("vat_number", VatNumber);

            if (!IpAddress.IsNullOrEmpty())
            {
                xmlWriter.WriteElementString("ip_address", IpAddress);
            }
            else
            {
                Debug.WriteLine("Recurly Client Library: Recording IP Address is strongly recommended.");
            }

            if (!CreditCardNumber.IsNullOrEmpty())
            {
                xmlWriter.WriteElementString("number", CreditCardNumber);
                xmlWriter.WriteElementString("month", ExpirationMonth.AsString());
                xmlWriter.WriteElementString("year", ExpirationYear.AsString());

                xmlWriter.WriteStringIfValid("verification_value", VerificationValue);
            }

            xmlWriter.WriteStringIfValid("token_id", TokenId);

            xmlWriter.WriteEndElement(); // End: billing_info
        }
コード例 #10
0
        public bool IsValid()
        {
            HolderDocument.ClearStrings();

            if (Brand.IsNullOrWhiteSpace())
            {
                throw new ArgumentException("Bandeira do cartão de crédito não informada");
            }

            if (ExpirationMonth.IsNullOrWhiteSpace())
            {
                throw new ArgumentException("Mês de expiração do cartão de crédito não informado");
            }

            int monthAsInt;

            int.TryParse(ExpirationMonth, out monthAsInt);

            if (monthAsInt < 1 || monthAsInt > 12)
            {
                throw new ArgumentException("Mês de expiração do cartão de crédito inválido");
            }

            if (ExpirationYear.IsNullOrWhiteSpace())
            {
                throw new ArgumentException("Ano de expiração do cartão de crédito não informado");
            }

            int yearAsInt;

            int.TryParse(ExpirationYear, out yearAsInt);

            if (yearAsInt < DateTime.Now.Year)
            {
                throw new ArgumentException("Ano de expiração do cartão de crédito inválido");
            }

            if (monthAsInt < DateTime.Now.Month && yearAsInt == DateTime.Now.Year)
            {
                throw new ArgumentException("Mês de expiração do cartão de crédito inválido");
            }

            if (HolderName.IsNullOrWhiteSpace())
            {
                throw new ArgumentException("Nome do titular do cartão de crédito não informado");
            }

            if (HolderDocument.IsNullOrWhiteSpace())
            {
                throw new ArgumentException("Documento do titular do cartão de crédito não informado");
            }

            if (!HolderDocument.IsValidCPF() && !HolderDocument.IsValidCNPJ())
            {
                throw new ArgumentException("Documento do titular do cartão de crédito inválido");
            }

            if (Bin.IsNullOrWhiteSpace())
            {
                throw new ArgumentException("Bin do cartão de crédito não informado");
            }

            if (LastDigits.IsNullOrWhiteSpace())
            {
                throw new ArgumentException("Últimos 4 dígitos do cartão de crédito não informados");
            }

            if (Signature.IsNullOrWhiteSpace())
            {
                throw new ArgumentException("Assinatura do cartão de crédito não informada");
            }

            if (Timestamp.IsNull() || Timestamp == DateTime.MinValue)
            {
                throw new ArgumentException("Timestamp do cartão de crédito não informados");
            }

            if (Token.IsNullOrWhiteSpace())
            {
                throw new ArgumentException("Token do cartão de crédito não informado");
            }

            return(true);
        }
コード例 #11
0
ファイル: CreateUserVM.cs プロジェクト: dhqua/PetShop
        // Creates user account and writes changes to XML files
        private void CreateClicked(object obj)
        {
            // Cannot access password directly so this work around passes the entire password box as a parameter
            if (obj != null)
            {
                PasswordBox workArond = obj as PasswordBox;
                Password = workArond.Password;
            }

            // Ensures the fields are not blank, creates new user and writes to file
            if (!string.IsNullOrWhiteSpace(UserName) && !string.IsNullOrWhiteSpace(Password) && !string.IsNullOrWhiteSpace(FirstName) && !string.IsNullOrWhiteSpace(LastName) && !string.IsNullOrWhiteSpace(Email) && !string.IsNullOrWhiteSpace(CvcCode))
            {
                tempUser = new User(UserName, Password, FirstName, LastName, Email, isSeller, new PaymentInfo(CreditCardNum, Int32.Parse(ExpirationMonth.ToString()), Int32.Parse(ExpirationYear.ToString()), CvcCode));
                Users.Add(tempUser);

                MainView.WriteXmlFile(Users);
                MainView.ActiveView = new LoginVM(MainView);
            }
            else
            {
                MessageBox.Show("Please fill all input boxes!");
            }
        }
コード例 #12
0
        internal override void WriteXml(XmlTextWriter xmlWriter)
        {
            xmlWriter.WriteStartElement("billing_info"); // Start: billing_info

            //if a recurly js token is supplied we don't want to send billing info here
            if (string.IsNullOrEmpty(TokenId))
            {
                xmlWriter.WriteStringIfValid("first_name", FirstName);
                xmlWriter.WriteStringIfValid("last_name", LastName);
                xmlWriter.WriteStringIfValid("company", Company);
                xmlWriter.WriteStringIfValid("name_on_account", NameOnAccount);
                xmlWriter.WriteStringIfValid("address1", Address1);
                xmlWriter.WriteStringIfValid("address2", Address2);
                xmlWriter.WriteStringIfValid("city", City);
                xmlWriter.WriteStringIfValid("state", State);
                xmlWriter.WriteStringIfValid("zip", PostalCode);
                xmlWriter.WriteStringIfValid("country", Country);
                xmlWriter.WriteStringIfValid("phone", PhoneNumber);
                xmlWriter.WriteStringIfValid("vat_number", VatNumber);
                xmlWriter.WriteStringIfValid("currency", Currency);

                if (!IpAddress.IsNullOrEmpty())
                {
                    xmlWriter.WriteElementString("ip_address", IpAddress);
                }
                else
                {
                    Debug.WriteLine("Recurly Client Library: Recording IP Address is strongly recommended.");
                }

                if (!CreditCardNumber.IsNullOrEmpty())
                {
                    xmlWriter.WriteElementString("number", CreditCardNumber);
                    xmlWriter.WriteElementString("month", ExpirationMonth.AsString());
                    xmlWriter.WriteElementString("year", ExpirationYear.AsString());

                    xmlWriter.WriteStringIfValid("verification_value", VerificationValue);
                }

                if (!AccountNumber.IsNullOrEmpty())
                {
                    xmlWriter.WriteElementString("routing_number", RoutingNumber);
                    xmlWriter.WriteElementString("account_number", AccountNumber);
                    xmlWriter.WriteElementString("account_type", AccountType.ToString().EnumNameToTransportCase());
                }

                if (!PaypalBillingAgreementId.IsNullOrEmpty())
                {
                    xmlWriter.WriteElementString("paypal_billing_agreement_id", PaypalBillingAgreementId);
                }

                if (!AmazonBillingAgreementId.IsNullOrEmpty())
                {
                    xmlWriter.WriteElementString("amazon_billing_agreement_id", AmazonBillingAgreementId);
                }

                if (!AmazonRegion.IsNullOrEmpty())
                {
                    xmlWriter.WriteElementString("amazon_region", AmazonRegion);
                }

                if (ExternalHppType.HasValue)
                {
                    xmlWriter.WriteElementString("external_hpp_type", ExternalHppType.Value.ToString().EnumNameToTransportCase());
                }

                if (!GatewayCode.IsNullOrEmpty())
                {
                    xmlWriter.WriteElementString("gateway_code", GatewayCode);
                    xmlWriter.WriteElementString("gateway_token", GatewayToken);

                    // EnumNameToTransportCase() turns MasterCard into "master_card",
                    // but it needs to be "master" for the server to accept it.
                    // Check for this edge case before writing the card_type tag.
                    var card = CardType.ToString().EnumNameToTransportCase();
                    if (card == "master_card")
                    {
                        card = "master";
                    }

                    xmlWriter.WriteElementString("card_type", card);
                }
            }

            xmlWriter.WriteStringIfValid("token_id", TokenId);

            xmlWriter.WriteEndElement(); // End: billing_info
        }
コード例 #13
0
 public CreditCardExpirationDate(ExpirationMonth month, int year)
 {
     Month = month;
     Year  = year;
 }
コード例 #14
0
    public void BindPage(Int64 paymentProfileId)
    {
        DisableButtonOnClick(ButtonSave);

        ErrorMessage.Text     = string.Empty;
        TextCardSecurity.Text = string.Empty;
        TextCreditCard.Text   = string.Empty;

        AspDotNetStorefrontCore.Customer adnsfCustomer = AspDotNetStorefrontCore.Customer.Current;
        int customerId = adnsfCustomer.CustomerID;

        PanelError.Visible = false;
        PopulateExpirationDates();
        PopulateAddresses(customerId);

        this.PaymentProfileId = 0;         // initially zero

        if (paymentProfileId <= 0)
        {
            return;
        }

        Int64 profileId = DataUtility.GetProfileId(customerId);

        if (profileId <= 0)
        {
            return;
        }

        var profileMgr     = new ProfileManager(customerId, adnsfCustomer.EMail, profileId);
        var paymentProfile = profileMgr.GetPaymentProfile(paymentProfileId);

        if (paymentProfile == null)
        {
            return;
        }

        this.PaymentProfileId = paymentProfileId;

        var ccPayment          = (GatewayAuthorizeNet.AuthorizeNetApi.CreditCardMaskedType)paymentProfile.payment.Item;
        var dataPaymentProfile = DataUtility.GetPaymentProfile(adnsfCustomer.CustomerID, this.PaymentProfileId);

        TextCreditCard.Text   = ccPayment.cardNumber;
        TextCardSecurity.Text = string.Empty;

        ExpirationMonth.ClearSelection();
        var foundItem = ExpirationMonth.Items.FindByValue(dataPaymentProfile.ExpirationMonth);

        if (foundItem != null)
        {
            foundItem.Selected = true;
        }

        ExpirationYear.ClearSelection();
        foundItem = ExpirationYear.Items.FindByValue(dataPaymentProfile.ExpirationYear);
        if (foundItem != null)
        {
            foundItem.Selected = true;
        }

        var address = DataUtility.GetPaymentProfile(customerId, this.PaymentProfileId);

        if (address != null)
        {
            BillingAddresses.ClearSelection();
            BillingAddresses.Items.FindByValue(address.AddressId.ToString()).Selected = true;
        }
    }
コード例 #15
0
        /// <summary>
        /// Method that will be called on an entity immediately before the item is saved by context
        /// </summary>
        /// <param name="dbContext"></param>
        /// <param name="entry"></param>
        public override void PreSaveChanges(Rock.Data.DbContext dbContext, DbEntityEntry entry)
        {
            var rockContext = ( RockContext )dbContext;

            HistoryChangeList = new History.HistoryChangeList();

            switch (entry.State)
            {
            case EntityState.Added:
            {
                History.EvaluateChange(HistoryChangeList, "Account Number", string.Empty, AccountNumberMasked);
                History.EvaluateChange(HistoryChangeList, "Currency Type", ( int? )null, CurrencyTypeValue, CurrencyTypeValueId);
                History.EvaluateChange(HistoryChangeList, "Credit Card Type", ( int? )null, CreditCardTypeValue, CreditCardTypeValueId);
                History.EvaluateChange(HistoryChangeList, "Name On Card", string.Empty, AccountNumberMasked, true);
                History.EvaluateChange(HistoryChangeList, "Expiration Month", string.Empty, ExpirationMonth.ToStringSafe(), true);
                History.EvaluateChange(HistoryChangeList, "Expiration Year", string.Empty, ExpirationYear.ToStringSafe(), true);
                History.EvaluateChange(HistoryChangeList, "Billing Location", string.Empty, History.GetValue <Location>(BillingLocation, BillingLocationId, rockContext));
                break;
            }

            case EntityState.Modified:
            case EntityState.Deleted:
            {
                History.EvaluateChange(HistoryChangeList, "Account Number", entry.OriginalValues["AccountNumberMasked"].ToStringSafe(), AccountNumberMasked);
                History.EvaluateChange(HistoryChangeList, "Currency Type", entry.OriginalValues["CurrencyTypeValueId"].ToStringSafe().AsIntegerOrNull(), CurrencyTypeValue, CurrencyTypeValueId);
                History.EvaluateChange(HistoryChangeList, "Credit Card Type", entry.OriginalValues["CreditCardTypeValueId"].ToStringSafe().AsIntegerOrNull(), CreditCardTypeValue, CreditCardTypeValueId);
                History.EvaluateChange(HistoryChangeList, "Name On Card", entry.OriginalValues["AccountNumberMasked"].ToStringSafe(), AccountNumberMasked, true);
                History.EvaluateChange(HistoryChangeList, "Expiration Month", entry.OriginalValues["ExpirationMonth"].ToStringSafe(), ExpirationMonth.ToStringSafe(), true);
                History.EvaluateChange(HistoryChangeList, "Expiration Year", entry.OriginalValues["ExpirationYear"].ToStringSafe(), ExpirationYear.ToStringSafe(), true);
                History.EvaluateChange(HistoryChangeList, "Billing Location", History.GetValue <Location>(null, entry.OriginalValues["BillingLocationId"].ToStringSafe().AsIntegerOrNull(), rockContext), History.GetValue <Location>(BillingLocation, BillingLocationId, rockContext));
                break;
            }
            }

            if (entry.State == EntityState.Added || entry.State == EntityState.Modified)
            {
                // Ensure that CurrencyTypeValueId is set. The UI tries to prevent it, but just in case, if it isn't, set it to Unknown
                if (!this.CurrencyTypeValueId.HasValue)
                {
                    this.CurrencyTypeValueId = DefinedValueCache.Get(Rock.SystemGuid.DefinedValue.CURRENCY_TYPE_UNKNOWN.AsGuid())?.Id;
                }
            }

            base.PreSaveChanges(dbContext, entry);
        }