本文整理匯總了PHP中GFFormDisplay::set_current_page方法的典型用法代碼示例。如果您正苦於以下問題:PHP GFFormDisplay::set_current_page方法的具體用法?PHP GFFormDisplay::set_current_page怎麽用?PHP GFFormDisplay::set_current_page使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類GFFormDisplay
的用法示例。
在下文中一共展示了GFFormDisplay::set_current_page方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: validation
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;
}
示例2: validation
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;
}
示例3: set_validation_result
/**
* @param $validation_result
* @param $post
* @param $error_message
*
* @return mixed
*/
public static function set_validation_result($validation_result, $post, $error_message)
{
$credit_card_page = 0;
foreach ($validation_result['form']['fields'] as &$field) {
if ('creditcard' == $field["type"]) {
$field['failed_validation'] = true;
$field['validation_message'] = $error_message;
$credit_card_page = $field['pageNumber'];
break;
}
}
$validation_result['is_valid'] = false;
GFFormDisplay::set_current_page($validation_result['form']['id'], $credit_card_page);
$validation_result = apply_filters('gfp_stripe_set_validation_result', $validation_result, $post, $error_message);
return $validation_result;
}
示例4: set_validation_result
private static function set_validation_result($validation_result, $post, $response, $responsetype)
{
if ($responsetype == "aim") {
$code = $response->response_reason_code;
switch ($code) {
case "2":
case "3":
case "4":
case "41":
$message = __("This credit card has been declined by your bank. Please use another form of payment.", "gravityformsauthorizenet");
break;
case "8":
$message = __("The credit card has expired.", "gravityformsauthorizenet");
break;
case "17":
case "28":
$message = __("The merchant does not accept this type of credit card.", "gravityformsauthorizenet");
break;
case "7":
case "44":
case "45":
case "65":
case "78":
case "6":
case "37":
case "27":
case "78":
case "45":
case "200":
case "201":
case "202":
$message = __("There was an error processing your credit card. Please verify the information and try again.", "gravityformsauthorizenet");
break;
default:
$message = __("There was an error processing your credit card. Please verify the information and try again.", "gravityformsauthorizenet");
}
} else {
$code = $response->getMessageCode();
switch ($code) {
case "E00012":
$message = __("A duplicate subscription already exists.", "gravityformsauthorizenet");
break;
case "E00018":
$message = __("The credit card expires before the subscription start date. Please use another form of payment.", "gravityformsauthorizenet");
break;
default:
$message = __("There was an error processing your credit card. Please verify the information and try again.", "gravityformsauthorizenet");
}
}
$message = "<!-- Error: " . $code . " -->" . $message;
$credit_card_page = 0;
foreach ($validation_result["form"]["fields"] as &$field) {
if ($field["type"] == "creditcard") {
$field["failed_validation"] = true;
$field["validation_message"] = $message;
$credit_card_page = $field["pageNumber"];
break;
}
}
$validation_result["is_valid"] = false;
GFFormDisplay::set_current_page($validation_result["form"]["id"], $credit_card_page);
return $validation_result;
}
示例5: gformValidation
/**
* process a form validation filter hook; if last page and has credit card field and total, attempt to bill it
* @param array $data an array with elements is_valid (boolean) and form (array of form elements)
* @return array
*/
public function gformValidation($data)
{
// make sure all other validations passed
if ($data['is_valid'] && self::isEwayForm($data['form']['id'], $data['form']['fields'])) {
require GFEWAY_PLUGIN_ROOT . 'includes/class.GFEwayFormData.php';
$formData = new GFEwayFormData($data['form']);
// make sure form hasn't already been submitted / processed
if ($this->hasFormBeenProcessed($data['form'])) {
$data['is_valid'] = false;
$formData->ccField['failed_validation'] = true;
$formData->ccField['validation_message'] = $this->getErrMsg(GFEWAY_ERROR_ALREADY_SUBMITTED);
} else {
if (!$formData->isCcHidden() && $formData->isLastPage() && $formData->ccField !== false) {
if (!$formData->hasPurchaseFields()) {
$data['is_valid'] = false;
$formData->ccField['failed_validation'] = true;
$formData->ccField['validation_message'] = $this->getErrMsg(GFEWAY_ERROR_NO_AMOUNT);
} else {
// only check credit card details if we've got something to bill
if ($formData->total > 0 || $formData->hasRecurringPayments()) {
// check for required fields
$required = array('ccName' => $this->getErrMsg(GFEWAY_ERROR_REQ_CARD_HOLDER), 'ccNumber' => $this->getErrMsg(GFEWAY_ERROR_REQ_CARD_NAME));
foreach ($required as $name => $message) {
if (empty($formData->{$name})) {
$data['is_valid'] = false;
$formData->ccField['failed_validation'] = true;
if (!empty($formData->ccField['validation_message'])) {
$formData->ccField['validation_message'] .= '<br />';
}
$formData->ccField['validation_message'] .= $message;
}
}
// if no errors, try to bill it
if ($data['is_valid']) {
if ($formData->hasRecurringPayments()) {
$data = $this->processRecurringPayment($data, $formData);
} else {
$data = $this->processSinglePayment($data, $formData);
}
}
}
}
}
}
// if errors, send back to credit card page
if (!$data['is_valid']) {
GFFormDisplay::set_current_page($data['form']['id'], $formData->ccField['pageNumber']);
}
}
return $data;
}