Skip to content
Up To 40% Eid Discount!
Seal The Deal
Formidable Forms alternatives
  • Pricing
  • Features
  • Demos
  • Integrations
  • Blog
  • Docs
  • Contact

Up To 40% Eid Discount!

Seal The Deal
Formidable Forms alternatives
Popular Search submitteddatajavascriptconfirmationemailsubmission

Developer Docs

  • Database Tables of Fluent Forms
  • Submission Lifecycle
  • Integration Feed – Fields API
  • Creating Custom SmartCode for Form Editor
  • Limit Email Domains in Fluent Forms Form Submission
  • Email verification with truemail
  • Email Confirmation Field
  • How to make a login form with Fluent Form
  • How to make a strong password requirement in user registration forms with Fluent Forms
  • Create Unique Fields in Fluent Forms
  • Populate dropdown field options from Google Sheet
  • Form PHP API
  • PHP Action Hooks
  • PHP Filter Hooks
  • Useful Snippets
  • Creating Pretty Conversational Form URL Slug

Action Hooks

  • fluentform_before_insert_submission
  • fluentform_submission_inserted
  • fluentform_before_submission_confirmation
  • fluentform_inserted_new_form
  • fluentform_before_form_render
  • fluentform_loaded
  • fluentform_before_form_actions_processing
  • fluentform_before_insert_payment_form
  • flentform_form_duplicated
  • fluentform_form_imported
  • fluentform_after_save_form_settings
  • fluent_editor_init
  • fluentform_loading_editor_assets
  • fluentform_before_editor_start
  • fluentform_after_editor_start
  • fluentform_after_form_screen_wrapper
  • fluentform_before_form_screen_wrapper
  • fluentform_render_item_{$item}
  • fluentform_after_form_render
  • fluentform_form_element_start
  • fluentform_render_item_step_start
  • fluentform_render_item_step_end
  • ff_rendering_calculation_form
  • fluentform_maybe_scheduled_jobs
  • fluentform_do_email_report_scheduled_tasks
  • before_fluentform_permission_set_assignment
  • after_fluentform_permission_set_assignment
  • fluentform_global_menu
  • fluentform_after_form_navigation
  • ff_fluentform_form_application_view_{$route}
  • fluentform_init_custom_stylesheet
  • fluentform_load_form_assets
  • fluentform_scripts_registered
  • flunetform_render_payment_entries
  • fluentform_pre_load_scripts
  • fluentform_new_response_note_added
  • fluentform_starting_file_upload
  • fluentform_global_notify_completed
  • fluentform_save_global_integration_settings_{ $settingsKey}
  • ff_integration_action_result
  • fluentform_email_summary_details
  • fluentform_email_template_after_footer
  • fluentform_addons_page_render_{$current_menu_item}
  • fluentform_before_form_settings_app
  • fluentform_after_form_settings_app
  • fluentform_form_settings_container_{$current_sub_route}
  • fluentform_before_global_settings_wrapper
  • fluentform_after_global_settings_wrapper
  • fluentform_global_settings_component_{$currentComponent}
  • fluentform_after_global_settings_option_render
  • fluentform_before_global_settings_option_render
  • fluentform_before_export_import_wrapper
  • fluentform_after_export_import_wrapper
  • fluentform_before_export_import_container
  • fluentform_after_before_export_import_container
  • fluentform_form_styler
  • fluentform_after_style_generated
  • fluentform_conversational_frame_head
  • fluentform_conversational_frame_footer
  • fluentform_user_registration_before_start
  • fluentform_created_user
  • fluentform_user_registration_completed
  • fluentform_post_integration_success
  • fluentformpro_entry_confirmation
  • fluentform_before_partial_entry_deleted
  • fluentform_after_partial_entry_deleted
  • flunetform_render_payment_entries
  • fluentform_before_all_entries_render
  • fluentform_after_all_entries_render
  • fluentform_before_entry_deleted
  • fluentform_after_entry_deleted
  • fluentform_payment_receipt_before_content
  • fluentform_payment_receipt_after_content
  • fluent_payment_frameless_{$paymentMethod}
  • fluentform_rending_payment_method_
  • fluentform_payment_method_render_{$methodName}
  • fluentform_before_payment_status_change
  • fluentform_after_payment_status_change
  • fluentform_payment_refunded_{$method}
  • fluentform_payment_refunded
  • fluentform_payment_refund_updated_{$method}
  • fluentform_payment_refund_updated
  • fluentform_paypal_ipn_verification_failed
  • fluentform_ipn_endpint_
  • fluentform_ipn_paypal_action_
  • fluentform_ipn_paypal_action_web_accept

Filter Hooks

  • fluentform_insert_response_data
  • fluentform_filter_insert_data
  • fluentform_submission_confirmation
  • fluentform_validate_input_item_{input_key}
  • fluentform_entry_statuses
  • fluentform_rendering_field_data_{INPUT_KEY}
  • fluentform_email_body
  • fluentform_rendering_field_data_select
  • fluentform_filter_email_attachments
  • fluentform_rendering_form
  • fluentform_is_form_renderable
  • fluentform_is_handling_submission
  • fluentform_validation_errors
  • fluentform_honeypot_name
  • fluentform_before_render_item
  • fluentform_rendering_field_html_{$elementName}
  • fluentform_skip_no_conflict
  • fluentform_load_styles
  • fluentform_load_default_public
  • fluentform_is_hide_submit_btn_{ $formId}
  • fluentform_form_class
  • fluent_form_html_attributes
  • fluentform_editor_shortcodes
  • fluentform_shortcode_parser_callback_{smart_code_name}
  • fluentform_all_editor_shortcodes
  • fluentform_smartcode_group_{$group}
  • fluentform_payment_smartcode
  • fluentform_entry_statuses_core
  • fluentform_nonce_verify
  • fluentform_nonce_error
  • fluentform_numeric_styles
  • fluentform_akismet_fields
  • ff_will_return_html
  • fluentform_honeypot_status
  • fluentform_dashboard_notices
  • fluentform_is_admin_page
  • fluentform_single_response_data
  • fluentform/available_date_formats
  • fluentform_permission_set
  • fluentform_api_all_logs
  • fluentform_api_success_log
  • fluentform_api_failed_log
  • fluentform_truncate_password_values
  • fluentform_verify_user_permission_{ $eachPermission}
  • fluentform_permission_callback
  • fluentform_nonce_error
  • fluentform_editor_init_element_{$element}
  • fluent_editor_validation_rule_settings
  • fluent_editor_element_settings_placement
  • fluent_editor_components
  • fluent_editor_countries
  • fluent_editor_element_customization_settings
  • fluentform_addons_extra_menu
  • fluentform_global_addons
  • fluentform_global_integration_settings_{$settingsKey}
  • fluentform_global_integration_fields_{$settingsKey}
  • fluentform_global_notification_active_types
  • fluentform_notifying_async_{$integrationKey}
  • fluentform_mailchimp_keep_existing_interests
  • fluentform_mailchimp_keep_existing_tags
  • fluentform_global_notification_feed_{$feed->meta_key}
  • fluentform_integration_data_{$integrationKey}
  • fluentform_shortcode_defaults
  • fluentform_info_shortcode_defaults
  • fluentform_get_raw_responses
  • fluentform_export_data
  • fluentform_shortcode_feed_text
  • fluentform_entry_lists_labels
  • fluentform_all_entries
  • fluentform_step_string
  • fluentform_global_form_vars
  • fluentform_all_entry_labels
  • fluentform_all_entry_labels_with_payment
  • fluentforms_recaptcha_v3_ref_score
  • fluentform_auto_read
  • fluentform_create_default_settings
  • fluentform_form_fields_update
  • fluentform_single_entry_widgets
  • fluentform-disabled_analytics
  • fluentform_entry_notes
  • fluentform_add_response_note
  • fluentform_disable_attachment_delete
  • fluentform_response_render_{element}
  • fluentform_settings_module_{$module}
  • fluentform_rendering_field_html_
  • fluentform_validation_message_{$ruleName}
  • fluentform_item_rules_{$item}
  • fluentform_send_plain_html_email
  • fluentform_submission_message_parse
  • fluentform_email_subject
  • fluentform_email_body
  • fluentform_email_to
  • fluentform_email_header
  • fluentform_email_footer
  • fluentform_email_styles
  • fluentform_email_template_footer_text
  • fluentform_email_attachments
  • fluentform_email_summary_body_text
  • fluentform_email_summary_footer_text
  • fluentform_email_content_type_header
  • fluentform_email_template_header_image
  • fluentform_email_template_email_heading
  • fluentform_email_template_colors
  • fluentform_nonce_verify
  • fluentform_popup_shortcode_defaults
  • fluentform_survey_shortcode_defaults
  • fluentform_itl_options
  • fluentform_ip_provider
  • fluentform_post_type_selection_types_args
  • fluentform_post_selection_types
  • fluentform_post_selection_posts_pre_data
  • fluentform_post_selection_label_by
  • fluentform_user_registration_field_defaults
  • fluentform_icontact_request_args
  • fluentform_user_registration_feed_fields
  • fluentorm_UserRegistration_creatable_roles
  • fluentform_payment_settings_{$method}
  • payment_method_settings_validation_{$method}
  • fluentform_with_payment_submission_data
  • fluentform_submission_order_items
  • fluentform_payment_field_{$elementName}
  • fluentform_stripe_checkout_args
  • fluentform_uploader_args
  • fluent_file_uploaded
  • fluentform_file_upload_params
  • fluentform_uploaded_file_name
  • fluentform_file_upload_validations
  • fluentform_file_upload_validation_error
  • fluentform_disable_inputmode
  • fluentform_file_type_options

Reference API Classes

  • BaseFieldManager Class
  • IntegrationManager Class
  • PDF TemplateManager Class
  • BasePaymentMethod Class
  • BaseProcessor Class

Data Definations

  • $submission_data Array
  • $form Object
  • Home
  • Docs
  • Reference API Classes
  • BasePaymentMethod Class

BasePaymentMethod Class

Table of Contents
  • Introduction
  • Methods
    • __construct()
    • init()
    • pushPaymentMethodToForm($methods)
    • modifyTransaction($transaction)
    • getGlobalFields()
    • getGlobalSettings()
    • Further read
      • Validate settings of payment method
      • All Together
      • Final Note

Introduction #

The Fluent Forms BasePaymentMethod Class provides developers with a simple way to add new Payment methods easily. The BaseProcessor Class is also required for the payment method background processing. The BasePaymentMethod class mainly works for displaying and storing the payment method settings, while the BaseProcessor class process and finalize the payments.

The API Functions are automatically included when Fluent Forms Pro Booted. The BaseFieldManager class is located in src/Payments/PaymentMethods/BasePaymentMethod.php .

Notice: Please do not initiate this class directly. You should extend this class to add start adding a new payment method

Methods #

__construct() #

<?php

use FluentFormPro\Payments\PaymentMethods\BasePaymentMethod;

class MyCustomPaymentMethod extends BasePaymentMethod
{    
     /*
     * Extend your payment method with a payment key identifier
     */
     public function __construct()
     {
         parent::__construct('myCustomPaymentKey');
     }

This is an example of how you can extend the BasePaymentMethod. This key will be used to identify the payment later on for the payment actions.

init() #

This is the main function that will run all the required actions for this payment settings and processing. These hooks will be called dynamically during the payment processing & settings after the payment method setup is completed.

 public function init()
    {
        add_filter('payment_method_settings_validation_'.$this->key, array($this, 'validateSettings'), 10, 2);

        if(!$this->isEnabled()) {
            return;
        }

        add_filter('fluentform_transaction_data_' . $this->key, array($this, 'modifyTransaction'), 10, 1);

        add_filter(
            'fluentformpro_available_payment_methods',
            [$this, 'pushPaymentMethodToForm']
        );
    }

pushPaymentMethodToForm($methods) #

This method will push the payment method with existing $methods to form editor. So it can be added to your fluentforms. Here is the format you need to follow to add the method. The $methods parameter is available with the fluentformpro_available_payment_methods hook.

/*
* @param $methods - Payment Methods Array data
*/    
public function pushPaymentMethodToForm($methods)
{
    $methods[$this->key] = [
        'title' => __('CustomPayment Method', 'fluentformpro'),
        'enabled' => 'yes',
        'method_value' => $this->key,
        'settings' => [
            'option_label' => [
                 'type' => 'text',
                 'template' => 'inputText',
                 'value' => 'Pay with MyCustomPaymentMethod ',
                 'label' => 'Method Label'
             ]
         ]
    ];
    return $methods;
}

modifyTransaction($transaction) #

This method modifies a transaction record with the payment method dashboard entry url. Use this to link the transaction with your payment method’s dashboard transaction page using the $transaction->charge_id charge id. The $transaction parameter is available with the ‘fluentform_transaction_data_'{$key} hook.

/*
* @param $transaction - Transaction Data array
*/
public function modifyTransaction($transaction)
{
   if ($transaction->charge_id) {
        $transaction->action_url =  'https://dashboard.mypaymentsitedemo.com/app/payments/'.$transaction->charge_id;
    }
    return $transaction;
}

getGlobalFields() #

This method will return all the admin settings for the current payment method. You can add your own settings also here. In the end of this page you will see an example with the settings format.

 abstract public function getGlobalFields();

getGlobalSettings() #

This method should return the saved data from the database. It will be based on the settings that were provided by getGlobalFields() method. You can get your settings like this get_option(‘fluentform_payment_settings_{key}’, []);

abstract public function getGlobalSettings();

Further read #

Validate settings of payment method #

If you want to validate the payment admin settings use this hook

add_filter('payment_method_settings_validation_{key}', function ($errors, $settings) {
        if(!($settings['test_api_key']) && !($settings['live_api_key'])) {
             $errors['test_api_key'] = __('API Key is required', 'fluentformpro');
        }
        return $errors;
}, 10, 2);

All Together #

Your ideal implementation should look like this with validation.

class MyCustomPaymentMethod extends BasePaymentMethod
{
    public function __construct()
    {
        parent::__construct('myCustomPaymentKey');
    }

    public function init()
    {  
        add_filter('payment_method_settings_validation_'.$this->key, array($this, 'validateSettings'), 10, 2);

        add_filter('fluentform_transaction_data_' . $this->key, array($this, 'modifyTransaction'), 10, 1);

        add_filter(
            'fluentformpro_available_payment_methods',
            [$this, 'pushPaymentMethodToForm']
        );
    }

    public function pushPaymentMethodToForm($methods)
    {
        $methods[$this->key] = [
            'title' => __('CustomPayment Method', 'fluentformpro'),
            'enabled' => 'yes',
            'method_value' => $this->key,
            'settings' => [
                'option_label' => [
                    'type' => 'text',
                    'template' => 'inputText',
                    'value' => 'Pay with MyCustomPaymentMethod ',
                    'label' => 'Method Label'
                ]
            ]
        ];

        return $methods;
    }

    public function validateSettings($errors, $settings)
    {
        if(!($settings['test_api_key']) && !($settings['live_api_key'])) {
            $errors['test_api_key'] = __('API Key is required', 'fluentformpro');
        }
        return $errors;
    }

    public function modifyTransaction($transaction)
    {
        return $transaction;
    }

    public function getGlobalFields()
    {
        return [
            'label' => 'MyCustom Payment Settings',
            'fields' => [
                [
                    'settings_key' => 'is_active',
                    'type' => 'yes-no-checkbox',
                    'label' => 'Status',
                    'checkbox_label' => 'Enable MyCustom Payment Payment Method'
                ],
                [
                    'settings_key' => 'payment_mode',
                    'type' => 'input-radio',
                    'label' => 'Payment Mode',
                    'options' => [
                        'test' => 'Test Mode',
                        'live' => 'Live Mode'
                    ],
                    'info_help' => 'Select the payment mode. for testing purposes you should select Test Mode otherwise select Live mode.',
                    'check_status' => 'yes'
                ],
                [
                    'settings_key' => 'test_api_key',
                    'type' => 'input-text',
                    'data_type' => 'password',
                    'placeholder' => 'Test API Key',
                    'label' => 'Test API Key',
                    'inline_help' => 'Provide your test api key for your test payments',
                    'check_status' => 'yes'
                ],
                [
                    'settings_key' => 'live_api_key',
                    'type' => 'input-text',
                    'data_type' => 'password',
                    'label' => 'Live API Key',
                    'placeholder' => 'Live API Key',
                    'inline_help' => 'Provide your live api key for your live payments',
                    'check_status' => 'yes'
                ]
            ]
        ];
    }

    public function getGlobalSettings()
    {
        return get_option('fluentform_payment_settings_'.$this->key, []);
    }
}

Final Note #

It’s highly recommended to explore our source files and try to understand the procedure. Once you understand it’s very easy to implement your own custom payment method.

If you have any questions please feel free to reach to our facebook community group

Custom Payment Method, Tutorial
What are your Feelings
Share This Article :
  • Facebook
  • Twitter
  • LinkedIn
  • Pinterest
Still stuck? How can we help?

How can we help?

Updated on July 29, 2021
PDF TemplateManager ClassBaseProcessor Class

Powered by BetterDocs

Table of Contents
  • Introduction
  • Methods
    • __construct()
    • init()
    • pushPaymentMethodToForm($methods)
    • modifyTransaction($transaction)
    • getGlobalFields()
    • getGlobalSettings()
    • Further read
      • Validate settings of payment method
      • All Together
      • Final Note
Fluent Forms

Addons

  • Signature (Paid)
  • PDF Generator
  • Mautic
  • Mailpoet

Get Help

  • Documentation
  • API Docs
  • Support
  • Brand Guideline
  • Nonprofit Discounts

Resource

  • Fluent Forms Free vs. Pro
  • Fluent Forms vs. WPForms
  • Fluent Forms vs. Gravity Forms
  • Fluent Forms vs. Ninja Forms
  • Fluent Forms vs. Forminator

Our Brands

  • Ninja Tables
  • FluentCRM
  • Fluent Support
  • FluentSMTP
  • WPSocialNinja
  • AzonPress

Email Newsletter

We won't send you spam. Unsubscribe at any time.
Facebook Group Twitter Instagram YouTube WordPress

Copyright © 2022 Fluent Forms. A Brand of  WPManageNinja™ | Affiliate | Terms & Privacy

Scroll to top
  • Pricing
  • Features
  • Demos
  • Integrations
  • Blog
  • Docs
  • Contact