'frm_stripe_icon frm_credit_card_alt_icon frmfont', // This is 99 in the Payments submodule but Stripe Lite only supports a single action. 'limit' => 1, 'active' => true, // After user registration. 'priority' => 45, 'event' => array( 'create' ), 'color' => '#3fac25', ); $this->FrmFormAction( 'payment', __( 'Collect a Payment', 'formidable' ), $action_ops ); } /** * @param WP_Post $instance * @param array $args */ public function form( $instance, $args = array() ) { $form_action = $instance; global $wpdb; $list_fields = self::get_defaults(); $action_control = $this; $options = $form_action->post_content; $form_fields = $this->get_field_options( $args['form']->id ); $field_dropdown_atts = compact( 'form_fields', 'form_action' ); $repeat_times = FrmTransLiteAppHelper::get_repeat_times(); $gateways = FrmTransLiteAppHelper::get_gateways(); if ( ! isset( $form_action->post_content['payment_limit'] ) ) { $form_action->post_content['payment_limit'] = ''; } include FrmTransLiteAppHelper::plugin_path() . '/views/action-settings/payments-options.php'; } /** * Capturing a payment later is only available in the Stripe add on. * This echos the HTML for a faded out capture payment dropdown. * When it is clicked, it should prompt to install Stripe. * * @since 6.5 * * @param string $selected_gateway The selected gateway for the given payment action. * * @return void */ public function echo_capture_payment_upsell( $selected_gateway = 'stripe' ) { // Add an upsell placeholder for the capture payment setting. $upgrading = FrmAddonsController::install_link( 'stripe' ); $upgrade_params = array(); if ( isset( $upgrading['url'] ) ) { $upgrade_params['data-oneclick'] = json_encode( $upgrading ); } else { $upgrade_params['data-requires'] = FrmAddonsController::get_addon_required_plan( 28136428 ); } unset( $upgrading ); include FrmTransLiteAppHelper::plugin_path() . '/views/action-settings/capture-payments-upsell.php'; } /** * @return array */ public function get_defaults() { $defaults = array( 'description' => '', 'email' => '', 'amount' => '', 'type' => '', 'interval_count' => 1, 'interval' => 'month', 'payment_count' => 9999, 'trial_interval_count' => 0, 'currency' => $this->default_currency(), 'gateway' => array(), 'credit_card' => '', 'billing_first_name' => '', 'billing_last_name' => '', 'billing_address' => '', 'shipping_email' => '', 'shipping_first_name' => '', 'shipping_last_name' => '', 'shipping_address' => '', 'entry_data_sync' => 'overwrite', ); return (array) apply_filters( 'frm_pay_action_defaults', $defaults ); } /** * @since 6.5, introduced in v2.01 of the Payments submodule. * * @return string */ private function default_currency() { $frm_settings = FrmAppHelper::get_settings(); $currency = trim( $frm_settings->currency ); if ( ! $currency ) { $currency = 'USD'; } return strtolower( $currency ); } /** * @param mixed $form_id * * @return array */ public function get_field_options( $form_id ) { $form_id = absint( $form_id ); $form_ids = $form_id; /** * Allows updating form ids used to query fields for displaying options with in the Payment action. * * @since 6.8 * * @param int|int[] $form_ids * @param int $form_id */ $form_ids = apply_filters( 'frm_trans_action_get_field_options_form_id', $form_ids, $form_id ); return FrmField::getAll( array( 'fi.form_id' => $form_ids, 'fi.type not' => array( 'divider', 'end_divider', 'html', 'break', 'captcha', 'rte', 'form' ), ), 'field_order' ); } /** * Get the ID of the credit card field. * We assume there is only a single credit card field in Stripe Lite. * This is saved as part of the Stripe payment action. * * @param array $form_atts * * @return int */ public function get_credit_card_field_id( $form_atts ) { $field_id = 0; foreach ( $form_atts['form_fields'] as $field ) { if ( 'credit_card' === $field->type ) { $field_id = (int) $field->id; break; } } return $field_id; } /** * Show the dropdown fields for custom form fields. * This is used for first and last name fields. * * @since 6.18 The `$field_atts` might contain `skipped_fields`. By default, the submit field is skipped. * * @param array $form_atts * @param array $field_atts * * @return void */ public function show_fields_dropdown( $form_atts, $field_atts ) { if ( ! isset( $field_atts['allowed_fields'] ) ) { $field_atts['allowed_fields'] = array(); } if ( ! isset( $field_atts['skipped_fields'] ) ) { $field_atts['skipped_fields'] = array( FrmSubmitHelper::FIELD_TYPE ); } $has_field = false; // phpcs:disable Generic.WhiteSpace.ScopeIndent ?> get_single_action( $action_id ); } }