/**
  * Construct and initialize an Gravity Forms payment add-on
  *
  * @see https://github.com/wp-premium/gravityforms/blob/1.9.10.15/includes/addon/class-gf-payment-addon.php
  *
  * @since 1.3.0
  */
 public function __construct()
 {
     parent::__construct();
     /*
      * Slug
      *
      * @var string URL-friendly identifier used for form settings, add-on settings, text domain localization...
      * @see https://github.com/wp-premium/gravityforms/blob/1.9.10.15/includes/addon/class-gf-addon.php#L24-L27
      */
     $this->_slug = 'pronamic_pay';
     /*
      * Title
      *
      * @var string Title of the plugin to be used on the settings page, form settings and plugins page. Example: 'Gravity Forms MailChimp Add-On'
      * @see https://github.com/wp-premium/gravityforms/blob/1.9.10.15/includes/addon/class-gf-addon.php#L40-L43
      */
     $this->_title = __('WordPress Pay Add-On', 'pronamic_ideal');
     /*
      * Short title
      *
      * @var string Short version of the plugin title to be used on menus and other places where a less verbose string is useful. Example: 'MailChimp'
      * @see https://github.com/wp-premium/gravityforms/blob/1.9.10.15/includes/addon/class-gf-addon.php#L44-L47
      */
     $this->_short_title = __('Pay', 'pronamic_ideal');
 }
 public function init()
 {
     parent::init();
     add_filter('gform_field_value_feed_reference', array($this, 'generate_random_number'));
     add_filter('gform_field_value_main_reference', array($this, 'generate_random_main_number'));
     add_action('gform_admin_pre_render', array($this, 'add_merge_tags'));
     add_filter('gform_replace_merge_tags', array($this, 'replace_merge_tags'), 10, 7);
 }
 public function init_admin()
 {
     parent::init_admin();
     //add actions to allow the payment status to be modified
     add_action('gform_payment_status', array($this, 'admin_edit_payment_status'), 3, 3);
     add_action('gform_payment_date', array($this, 'admin_edit_payment_date'), 3, 3);
     add_action('gform_payment_transaction_id', array($this, 'admin_edit_payment_transaction_id'), 3, 3);
     add_action('gform_payment_amount', array($this, 'admin_edit_payment_amount'), 3, 3);
     add_action('gform_after_update_entry', array($this, 'admin_update_payment'), 4, 2);
     add_filter('gform_addon_navigation', array($this, 'maybe_create_menu'));
 }
Beispiel #4
0
 public function process_subscription($authorization, $feed, $submission_data, $form, $entry)
 {
     gform_update_meta($entry['id'], 'stripe_customer_id', $authorization['subscription']['customer_id']);
     return parent::process_subscription($authorization, $feed, $submission_data, $form, $entry);
 }
 public function init_admin()
 {
     parent::init_admin();
     //add actions to allow the payment status to be modified
     add_action('gform_payment_status', array($this, 'admin_edit_payment_status'), 3, 3);
     if (version_compare(GFCommon::$version, '1.8.17.4', '<')) {
         //using legacy hook
         add_action('gform_entry_info', array($this, 'admin_edit_payment_status_details'), 4, 2);
     } else {
         add_action('gform_payment_date', array($this, 'admin_edit_payment_date'), 3, 3);
         add_action('gform_payment_transaction_id', array($this, 'admin_edit_payment_transaction_id'), 3, 3);
         add_action('gform_payment_amount', array($this, 'admin_edit_payment_amount'), 3, 3);
     }
     add_action('gform_after_update_entry', array($this, 'admin_update_payment'), 4, 2);
     add_filter('gform_addon_navigation', array($this, 'maybe_create_menu'));
 }
 public function styles()
 {
     $styles = array(array("handle" => "my_styles_css", "src" => $this->get_base_url() . "/css/my_styles.css", "version" => $this->_version, "enqueue" => array(array("field_types" => array("poll")))));
     return array_merge(parent::styles(), $styles);
 }
 public function validation($validation_result)
 {
     if (!$this->has_feed($validation_result['form']['id'], true)) {
         return $validation_result;
     }
     foreach ($validation_result['form']['fields'] as $field) {
         $current_page = GFFormDisplay::get_source_page($validation_result['form']['id']);
         $field_on_curent_page = $current_page > 0 && $field['pageNumber'] == $current_page;
         if (GFFormsModel::get_input_type($field) != 'creditcard' || !$field_on_curent_page) {
             continue;
         }
         if ($this->getSecureSubmitJsError() && $this->hasPayment($validation_result)) {
             $field['failed_validation'] = true;
             $field['validation_message'] = $this->getSecureSubmitJsError();
         } else {
             // override validation in case user has marked field as required allowing securesubmit to handle cc validation
             $field['failed_validation'] = false;
         }
         // only one cc field per form, break once we've found it
         break;
     }
     // revalidate the validation result
     $validation_result['is_valid'] = true;
     foreach ($validation_result['form']['fields'] as $field) {
         if ($field['failed_validation']) {
             $validation_result['is_valid'] = false;
             break;
         }
     }
     return parent::validation($validation_result);
 }
 /**
  * Checks if a previous version was installed and if the feeds need migrating to the framework structure.
  *
  * @param string $previous_version The version number of the previously installed version.
  */
 public function upgrade($previous_version)
 {
     if (empty($previous_version)) {
         $previous_version = get_option('gf_paypalpaymentspro_version');
     }
     $previous_is_pre_addon_framework = !empty($previous_version) && version_compare($previous_version, '2.0.dev1', '<');
     if ($previous_is_pre_addon_framework) {
         $this->log_debug(__METHOD__ . '(): Copying over data to new table structure.');
         $old_feeds = $this->get_old_feeds();
         if (!$old_feeds) {
             $this->log_debug(__METHOD__ . '(): No old feeds found to copy.');
             return;
         }
         $counter = 1;
         foreach ($old_feeds as $old_feed) {
             $feed_name = 'Feed ' . $counter;
             $form_id = $old_feed['form_id'];
             $is_active = $old_feed['is_active'];
             $customer_fields = rgar($old_feed['meta'], 'customer_fields');
             $new_meta = array('feedName' => $feed_name, 'transactionType' => rgar($old_feed['meta'], 'type'), 'change_post_status' => rgar($old_feed['meta'], 'update_post_action') ? '1' : '0', 'update_post_action' => rgar($old_feed['meta'], 'update_post_action'), 'recurringAmount' => rgar($old_feed['meta'], 'recurring_amount_field') == 'all' ? 'form_total' : rgar($old_feed['meta'], 'recurring_amount_field'), 'recurringTimes' => rgar($old_feed['meta'], 'recurring_times'), 'payPeriod' => rgar($old_feed['meta'], 'pay_period'), 'paymentAmount' => 'form_total', 'setupFee_enabled' => rgar($old_feed['meta'], 'setup_fee_enabled'), 'setupFee_product' => rgar($old_feed['meta'], 'setup_fee_amount_field'), 'billingInformation_firstName' => rgar($customer_fields, 'first_name'), 'billingInformation_lastName' => rgar($customer_fields, 'last_name'), 'billingInformation_email' => rgar($customer_fields, 'email'), 'billingInformation_address' => rgar($customer_fields, 'address1'), 'billingInformation_address2' => rgar($customer_fields, 'address2'), 'billingInformation_city' => rgar($customer_fields, 'city'), 'billingInformation_state' => rgar($customer_fields, 'state'), 'billingInformation_zip' => rgar($customer_fields, 'zip'), 'billingInformation_country' => rgar($customer_fields, 'country'), 'apiSettingsEnabled' => rgar($old_feed['meta'], 'api_settings_enabled'), 'overrideMode' => rgar($old_feed['meta'], 'api_mode'), 'overrideUsername' => rgar($old_feed['meta'], 'api_username'), 'overridePassword' => rgar($old_feed['meta'], 'api_password'), 'overrideVendor' => rgar($old_feed['meta'], 'api_vendor'), 'overridePartner' => rgar($old_feed['meta'], 'api_partner'));
             $optin_enabled = rgar($old_feed['meta'], 'paypalpaymentspro_conditional_enabled');
             if ($optin_enabled) {
                 $new_meta['feed_condition_conditional_logic'] = 1;
                 $new_meta['feed_condition_conditional_logic_object'] = array('conditionalLogic' => array('actionType' => 'show', 'logicType' => 'all', 'rules' => array(array('fieldId' => $old_feed['meta']['paypalpaymentspro_conditional_field_id'], 'operator' => $old_feed['meta']['paypalpaymentspro_conditional_operator'], 'value' => $old_feed['meta']['paypalpaymentspro_conditional_value']))));
             } else {
                 $new_meta['feed_condition_conditional_logic'] = 0;
             }
             $this->insert_feed($form_id, $is_active, $new_meta);
             $counter++;
         }
         $old_settings = get_option('gf_paypalpaymentspro_settings');
         if (!empty($old_settings)) {
             $this->log_debug(__METHOD__ . '(): Copying plugin settings.');
             $new_settings = array('mode' => rgar($old_settings, 'mode'), 'username' => rgar($old_settings, 'username'), 'password' => rgar($old_settings, 'password'), 'vendor' => rgar($old_settings, 'vendor'), 'partner' => rgar($old_settings, 'partner'));
             parent::update_plugin_settings($new_settings);
         }
         //copy existing transactions to new table
         $this->copy_transactions();
     }
 }
 /**
  * Add the value of the trialPeriod property to the order data which is to be included in the $submission_data.
  *
  * @param array $feed The feed currently being processed.
  * @param array $form The form currently being processed.
  * @param array $entry The entry currently being processed.
  *
  * @return array
  */
 public function get_order_data($feed, $form, $entry)
 {
     $order_data = parent::get_order_data($feed, $form, $entry);
     $order_data['trial'] = rgars($feed, 'meta/trialPeriod');
     return $order_data;
 }
 public function process_subscription($authorization, $feed, $submission_data, $form, $entry)
 {
     //gform_update_meta( $entry['id'], 'subscription_payment_date', gmdate( 'Y-m-d H:i:s' ) );
     gform_update_meta($entry['id'], 'subscription_payment_date', $authorization['subscription']['subscription_start_date']);
     gform_update_meta($entry['id'], 'subscription_payment_count', '1');
     gform_update_meta($entry['id'], 'subscription_regular_amount', $authorization['subscription']['amount']);
     gform_update_meta($entry['id'], 'subscription_trial_amount', $authorization['subscription']['subscription_trial_amount']);
     /**
      * HOOKS for backwards compatibility.
      *
      * @deprecated
      */
     do_action('gform_authorizenet_post_create_subscription', $authorization['subscription']['is_success'], $this->_args_for_deprecated_hooks['arb_subscription'], $this->_args_for_deprecated_hooks['arb_response'], $entry, $form, rgars($authorization, 'subscription/config'));
     do_action('gform_authorizenet_after_subscription_created', $authorization['subscription']['subscription_id'], $authorization['subscription']['amount'], rgars($authorization, 'subscription/captured_payment/amount'));
     return parent::process_subscription($authorization, $feed, $submission_data, $form, $entry);
 }
Beispiel #11
0
 public function init_admin()
 {
     parent::init_admin();
     //add actions to allow the payment status to be modified
     add_action('gform_payment_status', array($this, 'admin_edit_payment_status'), 3, 3);
     add_action('gform_payment_date', array($this, 'admin_edit_payment_date'), 3, 3);
     add_action('gform_payment_transaction_id', array($this, 'admin_edit_payment_transaction_id'), 3, 3);
     add_action('gform_payment_amount', array($this, 'admin_edit_payment_amount'), 3, 3);
     add_action('gform_after_update_entry', array($this, 'admin_update_payment'), 4, 2);
     add_filter('gform_addon_navigation', array($this, 'maybe_create_menu'));
     //checking if webserver is compatible with PayPal SSL certificate
     add_action('admin_notices', array($this, 'check_ipn_request'));
 }
 /**
  * Get plugin settings
  *
  * @since 1.0
  * @return void
  */
 public function get_plugin_settings()
 {
     $settings = parent::get_plugin_settings();
     if ($this->settings_are_valid($settings)) {
         return $settings;
     } else {
         return false;
     }
 }