private function is_last_page($form) { if (class_exists('GFFormDisplay')) { return GFFormDisplay::is_last_page($form); } return true; }
public function validation($validation_result) { if (!$validation_result['is_valid'] || !GFFormDisplay::is_last_page($validation_result['form'])) { return $validation_result; } $form = $validation_result['form']; $entry = GFFormsModel::create_lead($form); $feed = $this->get_payment_feed($entry, $form); if (!$feed) { return $validation_result; } $submission_data = $this->get_submission_data($feed, $form, $entry); //Do not process payment if payment amount is 0 if (floatval($submission_data['payment_amount']) <= 0) { $this->log_debug(__METHOD__ . '(): Payment amount is $0.00 or less. Not sending to payment gateway.'); return $validation_result; } $this->is_payment_gateway = true; $this->current_feed = $this->_single_submission_feed = $feed; $this->current_submission_data = $submission_data; $performed_authorization = false; $is_subscription = $feed['meta']['transactionType'] == 'subscription'; if ($this->payment_method_is_overridden('authorize') && !$is_subscription) { //Running an authorization only transaction if function is implemented and this is a single payment $this->authorization = $this->authorize($feed, $submission_data, $form, $entry); $performed_authorization = true; } elseif ($this->payment_method_is_overridden('subscribe') && $is_subscription) { $subscription = $this->subscribe($feed, $submission_data, $form, $entry); $this->authorization['is_authorized'] = $subscription['is_success']; $this->authorization['error_message'] = rgar($subscription, 'error_message'); $this->authorization['subscription'] = $subscription; $performed_authorization = true; } if ($performed_authorization) { $this->log_debug(__METHOD__ . "(): Authorization result for form #{$form['id']} submission => " . print_r($this->authorization, 1)); } if ($performed_authorization && !$this->authorization['is_authorized']) { $validation_result = $this->get_validation_result($validation_result, $this->authorization); //Setting up current page to point to the credit card page since that will be the highlighted field GFFormDisplay::set_current_page($validation_result['form']['id'], $validation_result['credit_card_page']); } return $validation_result; }
public function validation($validation_result) { if (!GFFormDisplay::is_last_page($validation_result['form'])) { return $validation_result; } $has_authorize = $this->payment_method_is_overridden('authorize'); $has_subscribe = $this->payment_method_is_overridden('subscribe'); if (!$has_authorize && !$has_subscribe) { return $validation_result; } //Getting submission data $form = $validation_result["form"]; $entry = GFFormsModel::create_lead($form); $feed = $this->get_payment_feed($entry, $form); if (!$feed) { return $validation_result; } $do_authorization = $has_authorize && $feed["meta"]["transactionType"] == "product"; $do_subscription = $has_subscribe && $feed["meta"]["transactionType"] == "subscription"; if (!$do_authorization && !$do_subscription) { return $validation_result; } $submission_data = $this->get_submission_data($feed, $form, $entry); //Running an authorization only transaction if function is implemented and this is a single payment if ($do_authorization) { $this->authorization = $this->authorize($feed, $submission_data, $form, $entry); } else { if ($do_subscription) { $subscription = $this->subscribe($feed, $submission_data, $form, $entry); $this->authorization["is_authorized"] = $subscription["is_success"]; $this->authorization["error_message"] = rgar($subscription, "error_message"); $this->authorization["subscription"] = $subscription; } } $this->authorization["feed"] = $feed; $this->authorization["submission_data"] = $submission_data; if (!$this->authorization["is_authorized"]) { $validation_result = $this->get_validation_result($validation_result, $this->authorization); //Setting up current page to point to the credit card page since that will be the highlighted field GFFormDisplay::set_current_page($validation_result["form"]["id"], $validation_result["credit_card_page"]); } return $validation_result; }
/** * Check if the rest of the form has passed validation, is the last page, and that the honeypot field has not been completed. * * @param array $validation_result Contains the validation result, the form object, and the failed validation page number. * * @return array $validation_result */ public function maybe_validate($validation_result) { $form = $validation_result['form']; $is_last_page = GFFormDisplay::is_last_page($form); $failed_honeypot = false; if ($is_last_page && rgar($form, 'enableHoneypot')) { $honeypot_id = GFFormDisplay::get_max_field_id($form) + 1; $failed_honeypot = !rgempty("input_{$honeypot_id}"); } if (!$validation_result['is_valid'] || !$is_last_page || $failed_honeypot) { return $validation_result; } return $this->validation($validation_result); }
/** * Check if the rest of the form has passed validation, is the last page, and that the honeypot field has not been completed. * * @param array $validation_result Contains the validation result, the form object, and the failed validation page number. * * @return array $validation_result */ public function maybe_validate($validation_result) { $form = $validation_result['form']; $is_last_page = GFFormDisplay::is_last_page($form); $failed_honeypot = false; if ($is_last_page && rgar($form, 'enableHoneypot')) { $honeypot_id = GFFormDisplay::get_max_field_id($form) + 1; $failed_honeypot = !rgempty("input_{$honeypot_id}"); } $is_heartbeat = rgpost('action') == 'heartbeat'; // Validation called by partial entries feature via the heartbeat API. if (!$validation_result['is_valid'] || !$is_last_page || $failed_honeypot || $is_heartbeat) { return $validation_result; } return $this->validation($validation_result); }
private static function is_ready_for_capture($validation_result) { $form = $validation_result['form']; $is_last_page = GFFormDisplay::is_last_page($form); $failed_honeypot = false; if ($is_last_page && rgar($form, 'enableHoneypot')) { $honeypot_id = GFFormDisplay::get_max_field_id($form) + 1; $failed_honeypot = !rgempty("input_{$honeypot_id}"); } $is_heartbeat = rgpost('action') == 'heartbeat'; // Validation called by partial entries feature via the heartbeat API. if (!$validation_result['is_valid'] || !$is_last_page || $failed_honeypot || $is_heartbeat) { return false; } //getting config that matches condition (if conditions are enabled) $config = self::get_config($validation_result["form"]); if (!$config) { return false; } //making sure credit card field is visible $creditcard_field = self::get_creditcard_field($validation_result["form"]); if (RGFormsModel::is_field_hidden($validation_result["form"], $creditcard_field, array())) { return false; } return $config; }