id(); if ( !isset( $_POST['save_checkout_redirect_setting_nonce'] ) || !wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['save_checkout_redirect_setting_nonce'] ) ), 'save_checkout_redirect_setting' ) ) { return; } $payment_settings = $_POST[static::$_prefix]; $settings = array( 'enable' => $this->get_text_field_value( $payment_settings, 'enable', 'no' ), 'enable_link' => $this->get_text_field_value( $payment_settings, 'enable_link', 'no' ), 'stripe_link' => ( isset( $payment_settings['stripe_link'] ) ? esc_url_raw( $payment_settings['stripe_link'] ) : '' ), 'payment_method_types' => array_map( 'sanitize_text_field', $payment_settings['payment_method_types'] ), 'save_metadata' => $this->get_text_field_value( $payment_settings, 'save_metadata', 'no' ), 'payment_type' => sanitize_text_field( $payment_settings['payment_type'] ), 'success_url' => ( isset( $payment_settings['success_url'] ) ? esc_url_raw( $payment_settings['success_url'] ) : '' ), 'cancel_url' => ( isset( $payment_settings['cancel_url'] ) ? esc_url_raw( $payment_settings['cancel_url'] ) : '' ), 'submit_type' => sanitize_text_field( $payment_settings['submit_type'] ), 'automatic_tax' => $this->get_text_field_value( $payment_settings, 'automatic_tax', 'no' ), 'tax_id_collection' => $this->get_text_field_value( $payment_settings, 'tax_id_collection', 'no' ), 'tax_behavior' => sanitize_text_field( $payment_settings['tax_behavior'] ), 'phone_number_collection' => $this->get_text_field_value( $payment_settings, 'phone_number_collection', 'no' ), 'terms_of_service' => $this->get_text_field_value( $payment_settings, 'terms_of_service', 'no' ), 'allow_promotion_codes' => $this->get_text_field_value( $payment_settings, 'allow_promotion_codes', 'no' ), 'billing_address_collection' => $this->get_text_field_value( $payment_settings, 'billing_address_collection', 'no' ), 'shipping_address_collection' => array_map( 'sanitize_text_field', $payment_settings['shipping_address_collection'] ?? [] ), 'email_field' => ( isset( $payment_settings['email_field'] ) ? sanitize_text_field( $payment_settings['email_field'] ) : '' ), 'onetime_currency' => ( isset( $payment_settings['onetime_currency'] ) ? sanitize_text_field( $payment_settings['onetime_currency'] ) : '' ), 'onetime_amount_field' => ( isset( $payment_settings['onetime_amount_field'] ) ? sanitize_text_field( $payment_settings['onetime_amount_field'] ) : '' ), 'onetime_quantity_field' => ( isset( $payment_settings['onetime_quantity_field'] ) ? sanitize_text_field( $payment_settings['onetime_quantity_field'] ) : '' ), 'onetime_product_name_field' => ( isset( $payment_settings['onetime_product_name_field'] ) ? sanitize_text_field( $payment_settings['onetime_product_name_field'] ) : '' ), 'onetime_product_desc_field' => ( isset( $payment_settings['onetime_product_desc_field'] ) ? sanitize_text_field( $payment_settings['onetime_product_desc_field'] ) : '' ), 'sub_currency' => ( isset( $payment_settings['sub_currency'] ) ? sanitize_text_field( $payment_settings['sub_currency'] ) : '' ), 'sub_amount_field' => ( isset( $payment_settings['sub_amount_field'] ) ? sanitize_text_field( $payment_settings['sub_amount_field'] ) : '' ), 'sub_quantity_field' => ( isset( $payment_settings['sub_quantity_field'] ) ? sanitize_text_field( $payment_settings['sub_quantity_field'] ) : '' ), 'sub_product_name_field' => ( isset( $payment_settings['sub_product_name_field'] ) ? sanitize_text_field( $payment_settings['sub_product_name_field'] ) : '' ), 'sub_product_desc_field' => ( isset( $payment_settings['sub_product_desc_field'] ) ? sanitize_text_field( $payment_settings['sub_product_desc_field'] ) : '' ), 'sub_interval_count_field' => ( isset( $payment_settings['sub_interval_count_field'] ) ? sanitize_text_field( $payment_settings['sub_interval_count_field'] ) : '' ), 'sub_interval_field' => ( isset( $payment_settings['sub_interval_field'] ) ? sanitize_text_field( $payment_settings['sub_interval_field'] ) : '' ), 'payment_type_condition_field' => ( isset( $payment_settings['payment_type_condition_field'] ) ? sanitize_text_field( $payment_settings['payment_type_condition_field'] ) : '' ), 'payment_type_condition_operation' => ( isset( $payment_settings['payment_type_condition_operation'] ) ? sanitize_text_field( $payment_settings['payment_type_condition_operation'] ) : '' ), 'payment_type_condition_value' => ( isset( $payment_settings['payment_type_condition_value'] ) ? sanitize_text_field( $payment_settings['payment_type_condition_value'] ) : '' ), ); // For new forms, we might need to save immediately after creation if ( empty( $form_id ) ) { add_action( 'wpcf7_after_create', function ( $contact_form ) use($settings) { update_post_meta( $contact_form->id(), self::$_setting_id, $settings ); } ); } else { update_post_meta( $form_id, self::$_setting_id, $settings ); } } function wpcf7_editor_panels( $panels ) { $panels['cf7pacr-panel'] = array( 'title' => __( 'Stripe Checkout Redirection', 'accept-stripe-for-contact-form-7' ), 'callback' => array($this, 'cf7_payment_settings_panel_html'), ); return $panels; } function cf7_payment_settings_panel_html( $post ) { $form_id = $post->id(); $settings = get_post_meta( $form_id, self::$_setting_id, true ); $settings = wp_parse_args( $settings, array( 'enable' => 'no', 'enable_link' => 'no', 'stripe_link' => '', 'payment_type' => 'onetime', 'payment_method_types' => ['automatic'], 'submit_type' => 'auto', 'success_url' => '', 'cancel_url' => '', 'save_metadata' => 'yes', 'billing_address_collection' => 'yes', 'allow_promotion_codes' => 'yes', 'automatic_tax' => 'yes', 'tax_id_collection' => 'no', 'tax_behavior' => 'exclusive', 'phone_number_collection' => 'no', 'terms_of_service' => 'no', 'shipping_address_collection' => ['US'], 'email_field' => '', 'onetime_currency' => '', 'onetime_amount_field' => '19.9', 'onetime_quantity_field' => '1', 'onetime_product_name_field' => 'your product name', 'onetime_product_desc_field' => 'your product description', 'sub_currency' => '', 'sub_quantity_field' => '1', 'sub_amount_field' => '19.9', 'sub_interval_count_field' => '1', 'sub_interval_field' => 'month', 'sub_product_name_field' => 'your product name', 'sub_product_desc_field' => 'your product description', 'payment_type_condition_field' => '', 'payment_type_condition_operation' => '', 'payment_type_condition_value' => '', ) ); $form_fields = $post->scan_form_tags(); ?>

render_form_fields( [ 'enable' => [ 'type' => 'checkbox', 'label' => 'Enable', 'value' => $settings['enable'], ], 'enable_link' => [ 'type' => 'checkbox', 'label' => 'Enable Stripe Link', 'value' => $settings['enable_link'], 'premium' => true, ], 'stripe_link' => [ 'type' => 'text', 'label' => 'Stripe Link', 'value' => $settings['stripe_link'], 'description' => __( 'During generating this Stripe link, two items are required:
1. In the "After Payment" tab, select "Don\'t show confirmation page" to ensure customers are redirected back to your site.
2. Append the fixed parameter string \'?session_id={CHECKOUT_SESSION_ID}\' after your specify URL.', 'accept-stripe-for-contact-form-7' ), 'premium' => true, ], ] ); ?>

Basic Settings

render_form_fields( Controls::get_session_checkout_setting_fields( $settings ) ); ?>

render_form_fields( [ 'email_field' => [ 'type' => 'text', 'label' => esc_html__( 'Customer Email Field', 'accept-stripe-for-contact-form-7' ), 'value' => $settings['email_field'], 'placeholder' => "[your-email]", 'description' => esc_html__( 'a fixed value or a form field such as [your-email]', 'accept-stripe-for-contact-form-7' ), ], 'payment_type' => [ 'type' => 'dropdown', 'label' => esc_html__( 'Payment Type', 'accept-stripe-for-contact-form-7' ), 'value' => $settings['payment_type'], 'options' => [ 'onetime' => esc_html__( 'One-time', 'accept-stripe-for-contact-form-7' ), 'subscription' => esc_html__( 'Subscription (pro)', 'accept-stripe-for-contact-form-7' ), 'flex' => esc_html__( 'Flex (pro)', 'accept-stripe-for-contact-form-7' ), ], 'description' => esc_html__( 'One-time, Subscription, or Flex (decided by end-user)', 'accept-stripe-for-contact-form-7' ), ], ] ); ?>
render_form_fields( Controls::get_one_time_pricing_fields( $settings ) ); ?>