Plugin Directory

Changeset 2722478


Ignore:
Timestamp:
05/12/2022 08:10:43 AM (4 years ago)
Author:
valuepaymy
Message:

Update plugin VPFF v1.0.3

Location:
valuepay-for-fluent-forms/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • valuepay-for-fluent-forms/trunk/includes/class-valuepay-fluentform-init.php

    r2714608 r2722478  
    88
    99        add_action( 'fluentform_loaded', array( $this, 'load_dependencies' ) );
     10
     11        // Smartcodes
     12        add_filter( 'fluentform_form_settings_smartcodes', array( $this, 'register_smartcodes' ) );
     13        add_filter( 'fluentform_shortcode_parser_callback_valuepay.payment_id', array( $this, 'smartcode_parse_payment_id' ), 10, 2 );
     14        add_filter( 'fluentform_shortcode_parser_callback_valuepay.payment_url', array( $this, 'smartcode_parse_payment_url' ), 10, 2 );
    1015
    1116    }
     
    2631    }
    2732
     33    // Register smartcodes (shortcodes)
     34    public function register_smartcodes( $groups ) {
     35
     36        $groups[] = array(
     37            'title' => __( 'ValuePay Payment Details', 'valuepay-fluentform' ),
     38            'shortcodes' => array(
     39                '{valuepay.payment_id}'  => __( 'ValuePay Payment ID', 'valuepay-fluentform' ),
     40                '{valuepay.payment_url}' => __( 'ValuePay Payment URL', 'valuepay-fluentform' ),
     41            ),
     42        );
     43
     44        return $groups;
     45
     46    }
     47
     48    // Parse smartcode for ValuePay payment ID
     49    public function smartcode_parse_payment_id( $return, $instance ) {
     50
     51        $form       = $instance::getForm();
     52        $entry      = $instance::getEntry();
     53        $fields     = \FluentForm\App\Modules\Form\FormFieldsParser::getEntryInputs( $form );
     54        $submission = \FluentForm\App\Modules\Form\FormDataParser::parseFormSubmission( $entry, $form, $fields, true );
     55
     56        $return = \FluentForm\App\Helpers\Helper::getSubmissionMeta( $submission->id, '_valuepay_payment_id' );
     57
     58        return $return;
     59
     60    }
     61
     62    // Parse smartcode for ValuePay payment URL
     63    public function smartcode_parse_payment_url( $return, $instance ) {
     64
     65        $form       = $instance::getForm();
     66        $entry      = $instance::getEntry();
     67        $fields     = \FluentForm\App\Modules\Form\FormFieldsParser::getEntryInputs( $form );
     68        $submission = \FluentForm\App\Modules\Form\FormDataParser::parseFormSubmission( $entry, $form, $fields, true );
     69
     70        $payment_id = $this->smartcode_parse_payment_id( $return, $instance );
     71        $payment_type = valuepay_fluentform_get_form_submission_value( $form, $submission, 'payment_type' );
     72
     73        if ( $payment_type === 'recurring' ) {
     74            $return = 'https://valuepay.my/m/' . $payment_id;
     75        } else {
     76            $return = 'https://valuepay.my/b/' . $payment_id;
     77        }
     78
     79        return $return;
     80
     81    }
     82
    2883}
    2984new Valuepay_Fluentform_Init();
  • valuepay-for-fluent-forms/trunk/includes/class-valuepay-fluentform-processor.php

    r2714608 r2722478  
    183183            }
    184184
    185             $paymentType = $this->getSubmissionValueByAdminLabel( $form, $submission, 'payment_type' );
     185            $paymentType = valuepay_fluentform_get_form_submission_value( $form, $submission, 'payment_type' );
    186186
    187187            if ( $paymentType === 'recurring' ) {
     
    236236    }
    237237
    238     // Get single submission value by admin label
    239     private function getSubmissionValueByAdminLabel( $form, $submission, $field ) {
    240 
    241         $labels = FormFieldsParser::getAdminLabels( $form );
    242         $fieldId = array_search( $field, $labels );
    243 
    244         return isset( $submission->response[ $fieldId ] ) ? $submission->response[ $fieldId ] : false;
    245 
    246     }
    247 
    248238    // Create an enrolment in ValuePay (for recurring payment)
    249239    private function getEnrolmentUrl( $transaction, $submission, $form ) {
     
    266256
    267257        // Identity information and bank code
    268         $identityType  = $this->getSubmissionValueByAdminLabel( $form, $submission, 'identity_type' );
    269         $identityValue = $this->getSubmissionValueByAdminLabel( $form, $submission, 'identity_value' );
    270         $bank           = $this->getSubmissionValueByAdminLabel( $form, $submission, 'bank' );
     258        $identityType  = valuepay_fluentform_get_form_submission_value( $form, $submission, 'identity_type' );
     259        $identityValue = valuepay_fluentform_get_form_submission_value( $form, $submission, 'identity_value' );
     260        $bank          = valuepay_fluentform_get_form_submission_value( $form, $submission, 'bank' );
    271261
    272262        if ( !$identityType || !$identityValue ) {
  • valuepay-for-fluent-forms/trunk/includes/functions.php

    r2714608 r2722478  
    6868
    6969}
     70
     71// Get single submission value by admin label from the form
     72function valuepay_fluentform_get_form_submission_value( $form, $submission, $field ) {
     73
     74    $labels = \FluentForm\App\Modules\Form\FormFieldsParser::getAdminLabels( $form );
     75    $field_id = array_search( $field, $labels );
     76
     77    return isset( $submission->response[ $field_id ] ) ? $submission->response[ $field_id ] : false;
     78
     79}
  • valuepay-for-fluent-forms/trunk/readme.txt

    r2714608 r2722478  
    11=== ValuePay for Fluent Forms ===
    2 Contributors: valuepaymy
    3 Tags: valuepay, fluent forms, payment
     2Contributors:      valuepaymy
     3Tags:              valuepay, fluent forms, payment
    44Requires at least: 4.6
    5 Tested up to: 5.9.3
    6 Stable tag: 1.0.2
    7 Requires PHP: 7.0
    8 License: GPLv2 or later
    9 License URI: https://www.gnu.org/licenses/gpl-2.0.html
     5Tested up to:      6.0
     6Stable tag:        1.0.3
     7Requires PHP:      7.0
     8License:           GPLv2 or later
     9License URI:       https://www.gnu.org/licenses/gpl-2.0.html
    1010
    1111Accept payment on Fluent Forms using ValuePay.
     
    4040== Changelog ==
    4141
     42= 1.0.3 - 2022-04-30 =
     43- Added: ValuePay payment ID and payment shortcodes in Fluent Forms
     44
    4245= 1.0.2 - 2022-04-17 =
    4346- Modified: Improve instant payment notification response data sanitization
  • valuepay-for-fluent-forms/trunk/valuepay-fluentform.php

    r2714608 r2722478  
    33 * Plugin Name:       ValuePay for Fluent Forms
    44 * Description:       Accept payment on Fluent Forms using ValuePay.
    5  * Version:           1.0.2
     5 * Version:           1.0.3
    66 * Requires at least: 4.6
    77 * Requires PHP:      7.0
     
    2020define( 'VALUEPAY_FLUENTFORM_PATH', plugin_dir_path( VALUEPAY_FLUENTFORM_FILE ) );
    2121define( 'VALUEPAY_FLUENTFORM_BASENAME', plugin_basename( VALUEPAY_FLUENTFORM_FILE ) );
    22 define( 'VALUEPAY_FLUENTFORM_VERSION', '1.0.2' );
     22define( 'VALUEPAY_FLUENTFORM_VERSION', '1.0.3' );
    2323
    2424// Plugin core class
Note: See TracChangeset for help on using the changeset viewer.