private void ShowPersonal( Person person ) { if ( person != null ) { txtCurrentName.Text = person.FullName; txtEmail.Text = person.Email; var rockContext = new RockContext(); var personService = new PersonService( rockContext ); if ( GetAttributeValue( "DisplayPhone" ).AsBoolean() ) { var phoneNumber = personService.GetPhoneNumber( person, DefinedValueCache.Read( new Guid( Rock.SystemGuid.DefinedValue.PERSON_PHONE_TYPE_HOME ) ) ); // If person did not have a home phone number, read the cell phone number (which would then // get saved as a home number also if they don't change it, which is ok ). if ( phoneNumber == null || string.IsNullOrWhiteSpace( phoneNumber.Number ) ) { phoneNumber = personService.GetPhoneNumber( person, DefinedValueCache.Read( new Guid( Rock.SystemGuid.DefinedValue.PERSON_PHONE_TYPE_MOBILE ) ) ); } if ( phoneNumber != null ) { pnbPhone.CountryCode = phoneNumber.CountryCode; pnbPhone.Number = phoneNumber.ToString(); } else { pnbPhone.CountryCode = PhoneNumber.DefaultCountryCode(); pnbPhone.Number = string.Empty; } } Guid addressTypeGuid = Guid.Empty; if ( !Guid.TryParse( GetAttributeValue( "AddressType" ), out addressTypeGuid ) ) { addressTypeGuid = new Guid( Rock.SystemGuid.DefinedValue.GROUP_LOCATION_TYPE_HOME ); } var groupLocation = personService.GetFirstLocation( person.Id, DefinedValueCache.Read( addressTypeGuid ).Id ); if ( groupLocation != null ) { GroupLocationId = groupLocation.Id; acAddress.SetValues( groupLocation.Location ); } else { acAddress.SetValues( null ); } } else { txtLastName.Text = string.Empty; txtFirstName.Text = string.Empty; txtEmail.Text = string.Empty; pnbPhone.CountryCode = PhoneNumber.DefaultCountryCode(); pnbPhone.Number = string.Empty; acAddress.SetValues( null ); } }
private void SetControlOptions() { FluidLayout = GetAttributeValue( "LayoutStyle" ) == "Fluid"; // Set page/panel titles lPanelTitle1.Text = GetAttributeValue( "PanelTitle" ); lPanelTitle2.Text = GetAttributeValue( "PanelTitle" ); lContributionInfoTitle.Text = GetAttributeValue( "ContributionInfoTitle" ); lPersonalInfoTitle.Text = GetAttributeValue( "PersonalInfoTitle" ); lPaymentInfoTitle.Text = GetAttributeValue( "PaymentInfoTitle" ); lConfirmationTitle.Text = GetAttributeValue( "ConfirmationTitle" ); lSuccessTitle.Text = GetAttributeValue( "SuccessTitle" ); lSaveAcccountTitle.Text = GetAttributeValue( "SaveAccountTitle" ); btnAddAccount.Title = GetAttributeValue( "AddAccountText" ); divRepeatingPayments.Visible = btnFrequency.Items.Count > 0; bool displayEmail = GetAttributeValue( "DisplayEmail" ).AsBoolean(); txtEmail.Visible = displayEmail; tdEmailConfirm.Visible = displayEmail; tdEmailReceipt.Visible = displayEmail; bool displayPhone = GetAttributeValue( "DisplayPhone" ).AsBoolean(); pnbPhone.Visible = displayPhone; tdPhoneConfirm.Visible = displayPhone; tdPhoneReceipt.Visible = displayPhone; var person = GetPerson( false ); if ( person != null ) { txtCurrentName.Text = person.FullName; txtEmail.Text = person.Email; var rockContext = new RockContext(); var personService = new PersonService( rockContext ); if ( displayPhone ) { var phoneNumber = personService.GetPhoneNumber( person, DefinedValueCache.Read( new Guid( Rock.SystemGuid.DefinedValue.PERSON_PHONE_TYPE_HOME ) ) ); // If person did not have a home phone number, read the cell phone number (which would then // get saved as a home number also if they don't change it, which is ok ). if ( phoneNumber == null || string.IsNullOrWhiteSpace( phoneNumber.Number ) ) { phoneNumber = personService.GetPhoneNumber( person, DefinedValueCache.Read( new Guid( Rock.SystemGuid.DefinedValue.PERSON_PHONE_TYPE_MOBILE ) ) ); } if ( phoneNumber != null ) { pnbPhone.CountryCode = phoneNumber.CountryCode; pnbPhone.Number = phoneNumber.ToString(); } else { pnbPhone.CountryCode = PhoneNumber.DefaultCountryCode(); pnbPhone.Number = string.Empty; } } Guid addressTypeGuid = Guid.Empty; if ( !Guid.TryParse( GetAttributeValue( "AddressType" ), out addressTypeGuid ) ) { addressTypeGuid = new Guid( Rock.SystemGuid.DefinedValue.GROUP_LOCATION_TYPE_HOME ); } var groupLocation = personService.GetFirstLocation( person.Id, DefinedValueCache.Read( addressTypeGuid ).Id ); if ( groupLocation != null ) { GroupLocationId = groupLocation.Id; acAddress.SetValues( groupLocation.Location ); } else { acAddress.SetValues( null ); } } txtCurrentName.Visible = person != null; txtFirstName.Visible = person == null; txtLastName.Visible = person == null; // Evaluate if comment entry box should be displayed txtCommentEntry.Label = GetAttributeValue( "CommentEntryLabel" ); txtCommentEntry.Visible = GetAttributeValue( "EnableCommentEntry" ).AsBoolean(); // Se the payment method tabs bool ccEnabled = _ccGatewayComponent != null; bool achEnabled = _achGatewayComponent != null; divCCPaymentInfo.Visible = ccEnabled; divACHPaymentInfo.Visible = achEnabled; if ( ccEnabled || achEnabled ) { hfPaymentTab.Value = ccEnabled ? "CreditCard" : "ACH"; if ( ccEnabled && achEnabled ) { phPills.Visible = true; } } // Determine if and how Name on Card should be displayed txtCardFirstName.Visible = _ccGatewayComponent != null && _ccGatewayComponent.PromptForNameOnCard( _ccGateway ) && _ccGatewayComponent.SplitNameOnCard; txtCardLastName.Visible = _ccGatewayComponent != null && _ccGatewayComponent.PromptForNameOnCard( _ccGateway ) && _ccGatewayComponent.SplitNameOnCard; txtCardName.Visible = _ccGatewayComponent != null && _ccGatewayComponent.PromptForNameOnCard( _ccGateway ) && !_ccGatewayComponent.SplitNameOnCard; // Set cc expiration min/max mypExpiration.MinimumYear = RockDateTime.Now.Year; mypExpiration.MaximumYear = mypExpiration.MinimumYear + 15; // Determine if account name should be displayed for bank account txtAccountName.Visible = _achGatewayComponent != null && _achGatewayComponent.PromptForBankAccountName( _achGateway ); // Determine if billing address should be displayed cbBillingAddress.Visible = _ccGatewayComponent.PromptForBillingAddress( _ccGateway ); divBillingAddress.Visible = _ccGatewayComponent.PromptForBillingAddress( _ccGateway ); }
/// <summary> /// Raises the <see cref="E:System.Web.UI.Control.Load" /> event. /// </summary> /// <param name="e">The <see cref="T:System.EventArgs" /> object that contains the event data.</param> protected override void OnLoad( EventArgs e ) { base.OnLoad( e ); // Hide the error box on every postback nbMessage.Visible = false; pnlDupWarning.Visible = false; nbSaveAccount.Visible = false; if ( _ccGateway != null || _achGateway != null ) { // Save amounts from controls to the viewstate list foreach ( RepeaterItem item in rptAccountList.Items ) { var accountAmount = item.FindControl( "txtAccountAmount" ) as RockTextBox; if ( accountAmount != null ) { if ( SelectedAccounts.Count > item.ItemIndex ) { decimal amount = decimal.MinValue; if ( decimal.TryParse( accountAmount.Text, out amount ) ) { SelectedAccounts[item.ItemIndex].Amount = amount; } } } } // Update the total amount lblTotalAmount.Text = SelectedAccounts.Sum( f => f.Amount ).ToString( "F2" ); // Set the frequency date label based on if 'One Time' is selected or not if ( btnFrequency.Items.Count > 0 ) { dtpStartDate.Label = btnFrequency.Items[0].Selected ? "When" : "First Gift"; } // If there are both CC and ACH options, set the active tab based on the hidden field value that tracks the active tag if ( phPills.Visible ) { if ( hfPaymentTab.Value == "ACH" ) { liCreditCard.RemoveCssClass( "active" ); liACH.AddCssClass( "active" ); divCCPaymentInfo.RemoveCssClass( "active" ); divACHPaymentInfo.AddCssClass( "active" ); } else { liCreditCard.AddCssClass( "active" ); liACH.RemoveCssClass( "active" ); divCCPaymentInfo.AddCssClass( "active" ); divACHPaymentInfo.RemoveCssClass( "active" ); } } // Show or Hide the Credit card entry panel based on if a saved account exists and it's selected or not. divNewCard.Style[HtmlTextWriterStyle.Display] = ( rblSavedCC.Items.Count == 0 || rblSavedCC.Items[rblSavedCC.Items.Count - 1].Selected ) ? "block" : "none"; // Show billing address based on if billing address checkbox is checked divBillingAddress.Style[HtmlTextWriterStyle.Display] = cbBillingAddress.Checked ? "block" : "none"; // Show save account info based on if checkbox is checked divSaveAccount.Style[HtmlTextWriterStyle.Display] = cbSaveAccount.Checked ? "block" : "none"; if ( !Page.IsPostBack ) { var rockContext = new RockContext(); SetPage( 1 ); // Get the list of accounts that can be used GetAccounts(); BindAccounts(); // Set personal information if there is a currently logged in person var person = GetPerson( false ); if ( person != null ) { // If there is a currently logged in user, do not allow them to change their name. txtCurrentName.Visible = true; txtCurrentName.Text = person.FullName; txtFirstName.Visible = false; txtLastName.Visible = false; txtEmail.Text = person.Email; var personService = new PersonService( rockContext ); bool displayPhone = false; if ( bool.TryParse( GetAttributeValue( "DisplayPhone" ), out displayPhone ) && displayPhone ) { var phoneNumber = personService.GetPhoneNumber( person, DefinedValueCache.Read( new Guid( Rock.SystemGuid.DefinedValue.PERSON_PHONE_TYPE_HOME ) ) ); // If person did not have a home phone number, read the cell phone number (which would then // get saved as a home number also if they don't change it, which is ok ). if ( phoneNumber == null || string.IsNullOrWhiteSpace( phoneNumber.Number ) ) { phoneNumber = personService.GetPhoneNumber( person, DefinedValueCache.Read( new Guid( Rock.SystemGuid.DefinedValue.PERSON_PHONE_TYPE_MOBILE ) ) ); } if ( phoneNumber != null ) { pnbPhone.CountryCode = phoneNumber.CountryCode; pnbPhone.Number = phoneNumber.ToString(); } else { pnbPhone.CountryCode = PhoneNumber.DefaultCountryCode(); pnbPhone.Number = string.Empty; } } Guid addressTypeGuid = Guid.Empty; if ( !Guid.TryParse( GetAttributeValue( "AddressType" ), out addressTypeGuid ) ) { addressTypeGuid = new Guid( Rock.SystemGuid.DefinedValue.GROUP_LOCATION_TYPE_HOME ); } var groupLocation = personService.GetFirstLocation( person.Id, DefinedValueCache.Read( addressTypeGuid ).Id ); if ( groupLocation != null ) { GroupLocationId = groupLocation.Id; acAddress.SetValues( groupLocation.Location ); } else { acAddress.SetValues( null ); } } else { txtCurrentName.Visible = false; txtFirstName.Visible = true; txtLastName.Visible = true; } SetPage( 1 ); } } else { SetPage( 0 ); ShowMessage( NotificationBoxType.Danger, "Configuration Error", "Please check the configuration of this block and make sure a valid Credit Card and/or ACH Financial Gateway has been selected." ); } }
/// <summary> /// Gets the payment information. /// </summary> /// <returns></returns> private PaymentInfo GetPaymentInfo(PersonService personService, FinancialScheduledTransaction scheduledTransaction) { PaymentInfo paymentInfo = null; if ( hfPaymentTab.Value == "ACH" ) { if ( rblSavedAch.Items.Count > 0 && ( rblSavedAch.SelectedValueAsId() ?? 0 ) > 0 ) { paymentInfo = GetReferenceInfo( rblSavedAch.SelectedValueAsId().Value ); } else { paymentInfo = GetACHInfo(); } } else if ( hfPaymentTab.Value == "CreditCard" ) { if ( rblSavedCC.Items.Count > 0 && ( rblSavedCC.SelectedValueAsId() ?? 0 ) > 0 ) { paymentInfo = GetReferenceInfo( rblSavedCC.SelectedValueAsId().Value ); } else { paymentInfo = GetCCInfo(); } } else { paymentInfo = new PaymentInfo(); } if ( paymentInfo != null ) { paymentInfo.Amount = SelectedAccounts.Sum( a => a.Amount ); paymentInfo.FirstName = scheduledTransaction.AuthorizedPerson.FirstName; paymentInfo.LastName = scheduledTransaction.AuthorizedPerson.LastName; paymentInfo.Email = scheduledTransaction.AuthorizedPerson.Email; bool displayPhone = false; if ( bool.TryParse( GetAttributeValue( "DisplayPhone" ), out displayPhone ) && displayPhone ) { var phoneNumber = personService.GetPhoneNumber( scheduledTransaction.AuthorizedPerson, DefinedValueCache.Read( new Guid( Rock.SystemGuid.DefinedValue.PERSON_PHONE_TYPE_HOME ) ) ); paymentInfo.Phone = phoneNumber != null ? phoneNumber.NumberFormatted : string.Empty; } Guid addressTypeGuid = Guid.Empty; if ( !Guid.TryParse( GetAttributeValue( "AddressType" ), out addressTypeGuid ) ) { addressTypeGuid = new Guid( Rock.SystemGuid.DefinedValue.GROUP_LOCATION_TYPE_HOME ); } var address = personService.GetFirstLocation( scheduledTransaction.AuthorizedPerson, DefinedValueCache.Read( addressTypeGuid ).Id ); if ( address != null ) { paymentInfo.Street = address.Street1; paymentInfo.City = address.City; paymentInfo.State = address.State; paymentInfo.Zip = address.Zip; } } return paymentInfo; }
/// <summary> /// Gets the payment information. /// </summary> /// <returns></returns> private PaymentInfo GetPaymentInfo( PersonService personService, FinancialScheduledTransaction scheduledTransaction ) { PaymentInfo paymentInfo = null; if ( hfPaymentTab.Value == "ACH" ) { if ( rblSavedAch.Items.Count > 0 && ( rblSavedAch.SelectedValueAsId() ?? 0 ) > 0 ) { paymentInfo = GetReferenceInfo( rblSavedAch.SelectedValueAsId().Value ); } else { paymentInfo = GetACHInfo(); } } else if ( hfPaymentTab.Value == "CreditCard" ) { if ( rblSavedCC.Items.Count > 0 && ( rblSavedCC.SelectedValueAsId() ?? 0 ) > 0 ) { paymentInfo = GetReferenceInfo( rblSavedCC.SelectedValueAsId().Value ); } else { paymentInfo = GetCCInfo(); } } else { paymentInfo = new PaymentInfo(); } if ( paymentInfo != null ) { paymentInfo.Amount = SelectedAccounts.Sum( a => a.Amount ); var authorizedPerson = scheduledTransaction.AuthorizedPersonAlias.Person; paymentInfo.FirstName = authorizedPerson.FirstName; paymentInfo.LastName = authorizedPerson.LastName; paymentInfo.Email = authorizedPerson.Email; bool displayPhone = GetAttributeValue( "DisplayPhone" ).AsBoolean(); if ( displayPhone ) { var phoneNumber = personService.GetPhoneNumber( authorizedPerson, DefinedValueCache.Read( new Guid( Rock.SystemGuid.DefinedValue.PERSON_PHONE_TYPE_HOME ) ) ); paymentInfo.Phone = phoneNumber != null ? phoneNumber.ToString() : string.Empty; } Guid addressTypeGuid = Guid.Empty; if ( !Guid.TryParse( GetAttributeValue( "AddressType" ), out addressTypeGuid ) ) { addressTypeGuid = new Guid( Rock.SystemGuid.DefinedValue.GROUP_LOCATION_TYPE_HOME ); } var groupLocation = personService.GetFirstLocation( authorizedPerson.Id, DefinedValueCache.Read( addressTypeGuid ).Id ); if ( groupLocation != null && groupLocation.Location != null ) { paymentInfo.Street1 = groupLocation.Location.Street1; paymentInfo.Street2 = groupLocation.Location.Street2; paymentInfo.City = groupLocation.Location.City; paymentInfo.State = groupLocation.Location.State; paymentInfo.PostalCode = groupLocation.Location.PostalCode; paymentInfo.Country = groupLocation.Location.Country; } } return paymentInfo; }