Example #1
0
 /** Allocate gateway options, if needed */
 public function allocate_pm_options($options)
 {
     $gateway = leyka_get_gateway_by_id($this->_gateway_id);
     $gateway_section_index = -1;
     foreach ($options as $index => $option) {
         if (!empty($option['section']) && $option['section']['name'] == $gateway->id) {
             $gateway_section_index = $index;
             break;
         }
     }
     $pm_options_names = $this->get_pm_options_names();
     $pm_options_names[] = $this->full_id . '_label';
     if ($gateway_section_index < 0) {
         $options[] = array('section' => array('name' => $gateway->id, 'title' => $gateway->title, 'is_default_collapsed' => false, 'options' => $pm_options_names));
     } else {
         $options[$gateway_section_index]['section']['options'] = array_unique(array_merge($pm_options_names, $options[$gateway_section_index]['section']['options']));
     }
     return $options;
 }
function leyka_min_payment_settings_complete()
{
    $pm_list = leyka_get_pm_list(true);
    if (!$pm_list) {
        return false;
    }
    $gateway_options_valid = array();
    // Array of already validated gateways
    foreach (leyka_options()->opt('pm_available') as $pm_full_id) {
        // Full ID is "gateway_id-pm_id"
        $pm = leyka_get_pm_by_id($pm_full_id, true);
        $pm_full_id = explode('-', $pm_full_id);
        $gateway = leyka_get_gateway_by_id(reset($pm_full_id));
        if (!$pm || !$gateway) {
            return false;
        }
        foreach ($pm->get_pm_options_names() as $option_name) {
            if (!leyka_options()->is_valid($option_name)) {
                return false;
            }
        }
        if (empty($gateway_options_valid[$gateway->id])) {
            foreach ($gateway->get_options_names() as $option_name) {
                if (!leyka_options()->is_valid($option_name)) {
                    return false;
                }
            }
            $gateway_options_valid[$gateway->id] = true;
        }
    }
    return true;
}
Example #3
0
 public function get_specific_data_admin_fields()
 {
     $data_fields = leyka_get_gateway_by_id($this->gateway_id)->get_specific_data_admin_fields($this->id);
     return $data_fields ? $data_fields : array();
 }
function leyka_is_min_payment_settings_complete()
{
    $pm_list = leyka_get_pm_list(true);
    if (!$pm_list) {
        return false;
    }
    $gateway_options_valid = array();
    // Array of already validated gateways
    foreach ($pm_list as $pm) {
        /** @var $pm Leyka_Payment_Method */
        $gateway = leyka_get_gateway_by_id($pm->gateway_id);
        if (!$pm || !$gateway) {
            continue;
        }
        $min_settings_complete = true;
        foreach ($pm->get_pm_options_names() as $option_name) {
            if (!leyka_options()->is_valid($option_name)) {
                $min_settings_complete = false;
                break;
            }
        }
        if (!isset($gateway_options_valid[$gateway->id])) {
            foreach ($gateway->get_options_names() as $option_name) {
                if (!leyka_options()->is_valid($option_name)) {
                    $gateway_options_valid[$gateway->id] = false;
                    break;
                }
            }
            if (!isset($gateway_options_valid[$gateway->id])) {
                $gateway_options_valid[$gateway->id] = true;
            }
        }
        if ($min_settings_complete && !empty($gateway_options_valid[$gateway->id])) {
            return true;
        }
    }
    return false;
}