public MainframeBillingAddressOverride ConvertBillingAddress(BillingLocation address) { var props = typeof(MainframeBillingAddressOverride).GetProperties().ToDictionary(x => x.Name); var office = address.LegacyMappings.FirstOrDefault(x => x.LegacySystemName == LegacySystemNames.Account.Name)?.LegacyIdentifier.Substring(0, 2); return(new MainframeBillingAddressOverride { Name = GetFormat(props["Name"], address, office), Line1 = GetFormat(props["Line1"], address, office), Line2 = GetFormat(props["Line2"], address, office), Line3 = GetFormat(props["Line3"], address, office), City = GetFormat(props["City"], address, office), StateProvince = GetFormat(props["StateProvince"], address, office), CountryCode = GetFormat(props["CountryCode"], address, office), PostalCode = GetFormat(props["PostalCode"], address, office), }); }
/// <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> /// <param name="changes">The changes.</param> public void SetFromPaymentInfo(PaymentInfo paymentInfo, GatewayComponent paymentGateway, RockContext rockContext, List <string> changes = null) { if (changes != null) { if (!string.IsNullOrWhiteSpace(paymentInfo.MaskedNumber)) { History.EvaluateChange(changes, "Account Number", AccountNumberMasked, paymentInfo.MaskedNumber); } if (paymentInfo.CurrencyTypeValue != null) { History.EvaluateChange(changes, "Currency Type", DefinedValueCache.GetName(CurrencyTypeValueId), paymentInfo.CurrencyTypeValue.Value); } if (paymentInfo.CreditCardTypeValue != null) { History.EvaluateChange(changes, "Credit Card Type", DefinedValueCache.GetName(CreditCardTypeValueId), paymentInfo.CreditCardTypeValue.Value); } } if (!string.IsNullOrWhiteSpace(paymentInfo.MaskedNumber)) { AccountNumberMasked = paymentInfo.MaskedNumber; } if (paymentInfo.CurrencyTypeValue != null) { CurrencyTypeValueId = paymentInfo.CurrencyTypeValue.Id; } if (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 (changes != null) { string oldNameOnCard = Encryption.DecryptString(NameOnCardEncrypted); History.EvaluateChange(changes, "Name on Card", oldNameOnCard, nameOnCard); History.EvaluateChange(changes, "Expiration Month", Encryption.DecryptString(ExpirationMonthEncrypted), ccPaymentInfo.ExpirationDate.Month.ToString()); History.EvaluateChange(changes, "Expiration Year", Encryption.DecryptString(ExpirationYearEncrypted), ccPaymentInfo.ExpirationDate.Year.ToString()); History.EvaluateChange(changes, "Billing Location", BillingLocation != null ? BillingLocation.ToString() : string.Empty, newLocation != null ? newLocation.ToString() : string.Empty); } NameOnCardEncrypted = Encryption.EncryptString(nameOnCard); ExpirationMonthEncrypted = Encryption.EncryptString(ccPaymentInfo.ExpirationDate.Month.ToString()); ExpirationYearEncrypted = Encryption.EncryptString(ccPaymentInfo.ExpirationDate.Year.ToString()); BillingLocationId = newLocation != null ? newLocation.Id : (int?)null; } else if (paymentInfo is SwipePaymentInfo) { var swipePaymentInfo = (SwipePaymentInfo)paymentInfo; if (changes != null) { string oldNameOnCard = Encryption.DecryptString(NameOnCardEncrypted); History.EvaluateChange(changes, "Name on Card", oldNameOnCard, swipePaymentInfo.NameOnCard); History.EvaluateChange(changes, "Expiration Month", Encryption.DecryptString(ExpirationMonthEncrypted), swipePaymentInfo.ExpirationDate.Month.ToString()); History.EvaluateChange(changes, "Expiration Year", Encryption.DecryptString(ExpirationYearEncrypted), swipePaymentInfo.ExpirationDate.Year.ToString()); } NameOnCardEncrypted = Encryption.EncryptString(swipePaymentInfo.NameOnCard); ExpirationMonthEncrypted = Encryption.EncryptString(swipePaymentInfo.ExpirationDate.Month.ToString()); ExpirationYearEncrypted = Encryption.EncryptString(swipePaymentInfo.ExpirationDate.Year.ToString()); } }