ed. * @param array $field Field settings. * * @return bool */ public function default_required( $required, $field ) { return $field['type'] === $this->type ? true : $required; } /** * Enqueue assets for the builder. * * @since 1.8.2 * * @param string $view Current view. */ public function builder_enqueues( $view ) { $min = wpforms_get_min_suffix(); wp_enqueue_style( 'wpforms-builder-stripe-card-field', WPFORMS_PLUGIN_URL . "assets/css/integrations/stripe/builder-stripe{$min}.css", [], WPFORMS_VERSION ); wp_enqueue_script( 'wpforms-builder-stripe-card-field', WPFORMS_PLUGIN_URL . "assets/js/integrations/stripe/admin-builder-stripe-card-field{$min}.js", [ 'jquery', 'wpforms-builder' ], WPFORMS_VERSION, true ); wp_localize_script( 'wpforms-builder-stripe-card-field', 'wpforms_builder_stripe_card_field', [ 'field_slug' => Helpers::get_field_slug(), ] ); } /** * Add our localized strings to be available in the form builder. * * @since 1.8.2 * * @param array $strings Form builder JS strings. * @param array $form Form data. * * @return array */ public function builder_js_strings( $strings, $form ) { $strings['stripe_ajax_required'] = wp_kses( __( '
AJAX form submissions are required when using the Stripe Credit Card field.
To proceed, please go to Settings » General » Advanced and check Enable AJAX form submission.
', 'wpforms-lite' ), [ 'p' => [], 'strong' => [], ] ); $strings['stripe_keys_required'] = wp_kses( __( 'Stripe account connection is required when using the Stripe Credit Card field.
To proceed, please go to WPForms Settings » Payments » Stripe and press Connect with Stripe button.
', 'wpforms-lite' ), [ 'p' => [], 'strong' => [], ] ); $strings['payments_enabled_required'] = wp_kses( __( 'Stripe Payments must be enabled when using the Stripe Credit Card field.
To proceed, please go to Payments » Stripe and check Enable Stripe payments.
', 'wpforms-lite' ), [ 'p' => [], 'strong' => [], ] ); return $strings; } /** * Define additional "Add Field" button attributes. * * @since 1.8.2 * * @param array $attributes Button attributes. * @param array $field Field settings. * @param array $form_data Form data and settings. * * @return array */ public function field_button_attributes( $attributes, $field, $form_data ) { if ( Helpers::get_field_slug() !== $field['type'] ) { return $attributes; } if ( Helpers::has_stripe_field( $form_data ) ) { $attributes['atts']['disabled'] = 'true'; return $attributes; } if ( ! Helpers::has_stripe_keys() ) { $attributes['class'][] = 'warning-modal'; $attributes['class'][] = 'stripe-keys-required'; } return $attributes; } /** * Currently validation happens on the front end. We do not do * generic server-side validation because we do not allow the card * details to POST to the server. * * @since 1.8.2 * * @param int $field_id Field ID. * @param array $field_submit Submitted field value (raw data). * @param array $form_data Form data and settings. */ public function validate( $field_id, $field_submit, $form_data ) { } /** * Format field. * * @since 1.8.2 * * @param int $field_id Field ID. * @param array $field_submit Submitted field value. * @param array $form_data Form data and settings. */ public function format( $field_id, $field_submit, $form_data ) { // Define data. $name = ! empty( $form_data['fields'][ $field_id ]['label'] ) ? $form_data['fields'][ $field_id ]['label'] : ''; // Set final field details. wpforms()->get( 'process' )->fields[ $field_id ] = [ 'name' => sanitize_text_field( $name ), 'value' => '', 'id' => absint( $field_id ), 'type' => $this->type, ]; } /** * The field value availability for the entry preview field. * * @since 1.8.2 * * @param bool $is_supported The field availability. * @param string $value The submitted Credit Card detail. * @param array $field Field data. * @param array $form_data Form data. * * @return bool */ public function entry_preview_availability( $is_supported, $value, $field, $form_data ) { return ! empty( $value ) && $value !== '-'; } /** * Maybe display errors before field. * * @since 1.8.2 * * @param array $form_data Form data and settings. * * @return bool */ private function field_display_errors( $form_data ) { // Display warning for non SSL pages. if ( ! is_ssl() ) { echo '