/** * Purchase Form Validate Gateway * * Validate the gateway and donation amount * * @access private * @since 1.0 * @return string */ function give_purchase_form_validate_gateway() { $form_id = isset($_REQUEST['give-form-id']) ? $_REQUEST['give-form-id'] : 0; $amount = isset($_REQUEST['give-amount']) ? give_sanitize_amount($_REQUEST['give-amount']) : 0; $gateway = give_get_default_gateway($form_id); // Check if a gateway value is present if (!empty($_REQUEST['give-gateway'])) { $gateway = sanitize_text_field($_REQUEST['give-gateway']); //Is amount being donated in LIVE mode 0.00? If so, error: if ($amount == 0 && !give_is_test_mode()) { give_set_error('invalid_donation_amount', esc_html__('Please insert a valid donation amount.', 'give')); } elseif (!give_verify_minimum_price()) { give_set_error('invalid_donation_minimum', sprintf(esc_html__('This form has a minimum donation amount of %s.', 'give'), give_currency_filter(give_format_amount(give_get_form_minimum_price($form_id))))); } elseif ($amount == 0 && give_is_test_mode()) { $gateway = 'manual'; } elseif (!give_is_gateway_active($gateway)) { give_set_error('invalid_gateway', esc_html__('The selected payment gateway is not enabled.', 'give')); } } return $gateway; }
/** * Purchase Form Validate Gateway * * @access private * @since 1.0 * @return string */ function give_purchase_form_validate_gateway() { $gateway = give_get_default_gateway($_REQUEST['give-form-id']); // Check if a gateway value is present if (!empty($_REQUEST['give-gateway'])) { $gateway = sanitize_text_field($_REQUEST['give-gateway']); //Is amount being donated in LIVE mode above 0.00? if ('0.00' == $_REQUEST['give-amount'] && !give_is_test_mode()) { give_set_error('invalid_donation_amount', __('Please insert a valid donation amount.', 'give')); } elseif (!give_verify_minimum_price()) { $minimum = give_currency_filter(give_format_amount(give_get_form_minimum_price($_REQUEST['give-form-id']))); $error_message = __('This form has a minimum donation amount of %s', 'give'); give_set_error('invalid_donation_minimum', sprintf($error_message, $minimum)); } elseif ('0.00' == $_REQUEST['give-amount'] && give_is_test_mode()) { $gateway = 'manual'; } elseif (!give_is_gateway_active($gateway)) { give_set_error('invalid_gateway', __('The selected payment gateway is not enabled', 'give')); } } return $gateway; }