Skip to content

Commit

Permalink
Dev- Square Payment Gateway (#1293)
Browse files Browse the repository at this point in the history
* Added - Square fields in free

* Added - Active square feature from form builder

* Added - Display error message when square is diabled

* Added - Validation for square credit card

* Added - Backward Compatibility

* updated

* Fix - Setting url

* Added - Image added on dashboard

* Tweak - Remove backward compatibility code

* Tweak - Auto enable ajax in square payment

---------

Co-authored-by: Deependra Chaudhary <elendoff11@gmail.com>
  • Loading branch information
NirajChaudhary143 and deepench authored Aug 2, 2024
1 parent 366d0fd commit d31341b
Show file tree
Hide file tree
Showing 14 changed files with 98 additions and 5 deletions.
3 changes: 2 additions & 1 deletion assets/css/admin.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2542,7 +2542,8 @@
&.turnstile_empty_key_validate,
&.hcaptcha_empty_key_validate,
&.enable-stripe-model,
&.enable-authorize-net-model {
&.enable-authorize-net-model,
&.enable-square-model{
opacity: 0.45;

&:hover {
Expand Down
16 changes: 16 additions & 0 deletions assets/extensions-json/sections/all_extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,22 @@
"setting_url": "admin.php?page=evf-settings&tab=integration&section=pipedrive",
"demo_video_url": "wJPX0EJ2OiI",
"popular_rank": 32
},
{
"title": "Square",
"slug": "everest-forms-square",
"name": "Everest Forms - Square",
"image": "extensions-json/sections/images/square-payment.png",
"excerpt": "Connect your Everest Forms data to your Trello accounts. Use Trello API to link Everest Forms with Trello, syncing your website's form submissions with Trello tasks.",
"link": "https://docs.everestforms.net/docs/trello/?utm_source=dashboard-all-features&utm_medium=card-documentation-link",
"released_date": "20/05/2024",
"plan": [
"personal",
"agency",
"themegrill agency"
],
"setting_url": "admin.php?page=evf-settings&tab=payment",
"demo_video_url": ""
}
]
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions assets/js/admin/evf-setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ jQuery(function ($) {
page: pagenow,
name: $itemRow.data("name"),
slug: $itemRow.data("slug"),
is_feature : $itemRow.data('is_feature')
},
});
});
Expand Down Expand Up @@ -509,6 +510,7 @@ jQuery(function ($) {
page: pagenow,
name: $(event).data("name"),
slug: $(event).data("slug"),
is_feature : $( event ).data( 'is_feature' )
},
});

Expand Down
2 changes: 0 additions & 2 deletions assets/js/admin/form-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
var $value = $(this).val();
$(this).val($value.replace(/<\s*script/gi, '').replace(/\s+on\w+\s*=/gi, ' '));
});


});

$( document ).ready( function( $ ) {
Expand Down
17 changes: 17 additions & 0 deletions assets/js/admin/upgrade.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ jQuery( function( $ ) {
$( document.body ).on( 'click dragstart', '.evf-registered-item.evf-upgrade-addon', this.evf_upgrade_addon );
$( document.body ).on( 'click dragstart', '.evf-registered-item.enable-stripe-model', this.enable_stripe_model );
$( document.body ).on( 'click dragstart', '.evf-registered-item.enable-authorize-net-model', this.enable_authorize_net_model );
$( document.body ).on( 'click dragstart', '.evf-registered-item.enable-square-model', this.enable_square_model );
$( document.body ).on( 'click dragstart', '.everest-forms-field-option-row.upgrade-modal', this.feature_upgrade );
$( document.body ).on( 'click dragstart', '.evf-upgradable-feature, .everest-forms-btn-group span.upgrade-modal', this.feature_upgrade );
$( document.body ).on( 'click dragstart', '.evf-one-time-draggable-field, .evf-registered-item.evf-one-time-draggable-field', this.evf_one_time_draggable_field );
Expand Down Expand Up @@ -200,6 +201,22 @@ jQuery( function( $ ) {
}
});
},
enable_square_model : function ( e ){
e.preventDefault();
$.alert({
title: evf_upgrade.enable_square_title,
content: evf_upgrade.enable_square_message,
icon: 'dashicons dashicons-info',
type: 'blue',
buttons : {
confirm : {
text: evf_data.i18n_close,
btnClass: 'btn-confirm',
keys: ['enter']
}
}
});
},
evf_one_time_draggable_field: function( e ){
e.preventDefault();
$.alert({
Expand Down
18 changes: 18 additions & 0 deletions assets/js/frontend/ajax-submission.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,19 @@ jQuery( function( $ ) {
return false;
}

//For square payment credit card validation.
var squareMsgContainer = formTuple.find(".everest-forms-gateway[data-gateway='square']").find('.sq-card-message-error');
if ( squareMsgContainer.length > 0 ) {
var squareErrorMsg = squareMsgContainer.text();
$( document ).ready( function() {
$( '#card-errors' ).html( squareErrorMsg ).show();
$( '.evf-submit' ).text( 'Submit' );
$( '.evf-submit' ).attr( 'disabled', false);
});
formTuple.trigger( 'focusout' ).trigger( 'change' ).trigger( 'submit' );
return false;
}

if ( typeof tinyMCE !== 'undefined' ) {
tinyMCE.triggerSave();
}
Expand Down Expand Up @@ -154,6 +167,11 @@ jQuery( function( $ ) {
formTuple.trigger( 'evf_process_payment', xhr.data );
return;
}
if( 'square' === formTuple.find( ".everest-forms-gateway[data-gateway='square']" ).data('gateway') ){
formTuple.trigger( 'everest_forms_frontend_payment_before_success_message', xhr.data );
return;
}

formTuple.trigger( 'reset' );
formTuple.closest( '.everest-forms' ).html( '<div class="everest-forms-notice everest-forms-notice--success" role="alert">' + xhr.data.message + pdf_download_message + '</div>' + quiz_reporting + preview_confirmation ).focus();
localStorage.removeItem(formTuple.attr('id'));
Expand Down
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* Feature - Enable minimum time for form submission.
* Feature - Delete option in Header logo in PDF Submission.
* Enhancement - Custom file name field settings.
* Dev - Square Payment.
* Dev - Transaction Table.
* Dev - Salesflare into Module.
* Dev - ConvertKit Compatibility.
Expand Down
2 changes: 2 additions & 0 deletions includes/admin/class-evf-admin-assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,8 @@ public function admin_scripts() {
'enable_stripe_message' => esc_html__( 'Enable Stripe Payment gateway in payments section to use this field.', 'everest-forms' ),
'enable_authorize_net_title' => esc_html__( 'Please enable Authorize.Net', 'everest-forms' ),
'enable_authorize_net_message' => esc_html__( 'Enable Authorize.Net Payment gateway in payments section to use this field.', 'everest-forms' ),
'enable_square_title' => esc_html( 'Please enable Square', 'everest-forms' ),
'enable_square_message' => esc_html__( 'Enable Square Payment gateway in payments section to use this field.', 'everest-forms' ),
'evf_install_and_active_nonce' => wp_create_nonce( 'install_and_active_nonce' ),
'upgrade_plan_title' => esc_html__( 'is a Premium Addon', 'everest-forms' ),
'upgrade_plan_message' => esc_html__( 'This addon requires premium plan. Please upgrade to the Premium plan to unlock all these awesome field.', 'everest-forms' ),
Expand Down
2 changes: 1 addition & 1 deletion includes/class-evf-form-task.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ public function do_task( $entry ) {
do_action( "everest_forms_process_before_{$form_id}", $entry, $this->form_data );

$ajax_form_submission = isset( $this->form_data['settings']['ajax_form_submission'] ) ? $this->form_data['settings']['ajax_form_submission'] : 0;
if ( isset( $this->form_data['payments']['stripe']['enable_stripe'] ) && '1' === $this->form_data['payments']['stripe']['enable_stripe'] ) {
if ( ( isset( $this->form_data['payments']['stripe']['enable_stripe'] ) && '1' === $this->form_data['payments']['stripe']['enable_stripe'] ) || ( isset( $this->form_data['payments']['square']['enable_square'] ) && '1' === $this->form_data['payments']['square']['enable_square'] ) ) {
$ajax_form_submission = '1';
}
if ( '1' === $ajax_form_submission ) {
Expand Down
1 change: 1 addition & 0 deletions includes/class-evf-forms-features.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public function form_fields( $fields ) {
'EVF_Field_Color',
'EVF_Field_Reset',
'EVF_Field_Lookup',
'EVF_Field_Payment_Square',
);

return array_merge( $fields, $pro_fields );
Expand Down
36 changes: 36 additions & 0 deletions includes/fields/class-evf-field-payment-square.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php
/**
* EVF_Field_Payment_Square field
*
* @package EverestForms\Fields
* @since 3.0.0
*/

defined( 'ABSPATH' ) || exit;

/**
* EVF_Field_Payment_Square Class.
*/
class EVF_Field_Payment_Square extends \EVF_Form_Fields {

/**
* Constructor.
*/
public function __construct() {

$this->name = esc_html__( 'Square', 'everest-forms' );
$this->type = 'square-payment';
$this->icon = 'evf-icon evf-icon-payment';
$this->order = 231;
$this->group = 'payment';
$this->is_pro = true;
$this->plan = 'personal agency themegrill-agency';
$this->addon = 'everest-forms-square';
$this->links = array(
'image_id' => '',
'vedio_id' => 'a5EcKjwWD1A',
);

parent::__construct();
}
}
2 changes: 1 addition & 1 deletion includes/shortcodes/class-evf-shortcode-form.php
Original file line number Diff line number Diff line change
Expand Up @@ -906,7 +906,7 @@ private static function view( $atts ) {
$form_enabled = isset( $form_data['form_enabled'] ) ? absint( $form_data['form_enabled'] ) : 1;
$kff_enabled = isset( $settings['keyboard_friendly_form'] ) ? absint( $settings['keyboard_friendly_form'] ) : 0;
$disable_message = isset( $form_data['settings']['form_disable_message'] ) ? evf_string_translation( $form_data['id'], 'form_disable_message', $form_data['settings']['form_disable_message'] ) : __( 'This form is disabled.', 'everest-forms' );
if ( isset( $form_data['payments']['stripe']['enable_stripe'] ) && '1' === $form_data['payments']['stripe']['enable_stripe'] ) {
if ( ( isset( $form_data['payments']['stripe']['enable_stripe'] ) && '1' === $form_data['payments']['stripe']['enable_stripe'] ) || ( isset( $form_data['payments']['square']['enable_square'] ) && '1' === $form_data['payments']['square']['enable_square'] ) ) {
$ajax_form_submission = isset( $settings['ajax_form_submission'] ) ? 1 : 0;
} else {
$ajax_form_submission = isset( $settings['ajax_form_submission'] ) ? $settings['ajax_form_submission'] : 0;
Expand Down
1 change: 1 addition & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ Yes you can! Join in on our [GitHub repository](https://github.com/wpeverest/eve
* Feature - Enable minimum time for form submission.
* Feature - Delete option in Header logo in PDF Submission.
* Enhancement - Custom file name field settings.
* Dev - Square Payment.
* Dev - Transaction Table.
* Dev - Salesflare into Module.
* Dev - ConvertKit Compatibility.
Expand Down

0 comments on commit d31341b

Please sign in to comment.