コード例 #1
0
ファイル: leyka-ajax.php プロジェクト: slavam/adult-childhood
/** AJAX for donation form templates **/
function leyka_payment_method_action()
{
    check_ajax_referer('leyka_payment_form', '_leyka_ajax_nonce');
    if (empty($_POST['pm_id'])) {
        die('-1');
    }
    $curr_currency = trim($_POST['currency']);
    $curr_pm = leyka_get_pm_by_id(trim($_POST['pm_id']));
    if (!$curr_pm) {
        die('-1');
    }
    leyka_setup_current_pm($curr_pm, $curr_currency);
    ob_start();
    ?>


    <div class="leyka-pm-fields">

        <div class='leyka-user-data'>
            <!-- field for GA -->
            <input type="hidden" name="leyka_ga_payment_method" value="<?php 
    echo esc_attr($curr_pm->label);
    ?>
" />
            <?php 
    echo leyka_pf_get_name_field(empty($_POST['user_name']) ? '' : trim($_POST['user_name']));
    echo leyka_pf_get_email_field(empty($_POST['user_email']) ? '' : trim($_POST['user_email']));
    echo leyka_pf_get_pm_fields();
    ?>

        </div>

        <?php 
    echo leyka_pf_get_agree_field();
    echo leyka_pf_get_submit_field();
    $icons = leyka_pf_get_pm_icons();
    if ($icons) {
        $list = array();
        foreach ($icons as $i) {
            $list[] = "<li>{$i}</li>";
        }
        echo '<ul class="leyka-pm-icons cf">' . implode('', $list) . '</ul>';
    }
    ?>

    </div>
    <?php 
    echo "<div class='leyka-pm-desc'>" . apply_filters('leyka_the_content', leyka_pf_get_pm_description()) . "</div>";
    $out = ob_get_contents();
    ob_end_clean();
    $payment_form = new Leyka_Payment_Form($curr_pm, $curr_currency);
    echo json_encode(array('pm' => $out, 'currency' => $payment_form->get_currency_field()));
    die;
}
コード例 #2
0
ファイル: leyka-gateways-api.php プロジェクト: GenV/Leyka
/**
 * @param mixed $activity True to select only active PMs, false for only non-active ones,
 * NULL for both types altogether.
 * @param $currency mixed
 * @return array
 */
function leyka_get_pm_list($activity = null, $currency = false, $sorted = true)
{
    $pm_list = array();
    if ($sorted) {
        $pm_order = explode('pm_order[]=', leyka_options()->opt('pm_order'));
        array_shift($pm_order);
        foreach ($pm_order as $pm) {
            $pm = leyka_get_pm_by_id(str_replace(array('&amp;', '&'), '', $pm), true);
            if (!$pm) {
                continue;
            }
            if ((!$activity || $pm->active == $activity) && (!$currency || $pm->has_currency_support($currency))) {
                $pm_list[] = $pm;
            }
        }
    } else {
        foreach (leyka()->get_gateways() as $gateway) {
            /** @var Leyka_Gateway $gateway */
            $pm_list = array_merge($pm_list, $gateway->get_payment_methods($activity, $currency));
        }
    }
    return apply_filters('leyka_active_pm_list', $pm_list, $activity, $currency);
}
コード例 #3
0
function get_leyka_payment_form_template_html($campaign = null, $template = null)
{
    global $post;
    ob_start();
    if (!$campaign) {
        $campaign = new Leyka_Campaign($post);
    } elseif (is_int($campaign) || is_a($campaign, 'WP_Post')) {
        $campaign = new Leyka_Campaign($campaign);
    } elseif (!is_a($campaign, 'Leyka_Campaign')) {
        return false;
    }
    if ($campaign->is_finished) {
        ?>


    <div id="leyka-campaign-finished"><?php 
        echo __('The fundraising campaign has been finished. Thank you for your support!', 'leyka');
        ?>
</div>

<?php 
    } else {
        $pm_list = leyka_get_pm_list(true);
        $curr_pm = $pm_list ? leyka_get_pm_by_id(reset($pm_list)->full_id, true) : false;
        if (!$curr_pm) {
            ?>


        <div class="<?php 
            echo apply_filters('leyka_no_pm_error_classes', 'leyka-nopm-error');
            ?>
">
            <?php 
            echo is_user_logged_in() ? str_replace('%s', admin_url('admin.php?page=leyka_settings&stage=payment#leyka_pm_available-wrapper'), __('There are no payment methods selected to donate! Please, <a href="%s">set them up</a>.', 'leyka')) : __('Dear donor, we are very sorry, but we had not setted up the donations module yet :( Please try to donate later.', 'leyka');
            ?>

        </div>

        <?php 
        } else {
            $template = leyka_get_current_template_data($campaign, $template);
            if ($template && isset($template['file'])) {
                include $template['file'];
            }
        }
    }
    // Campaign finished
    $out = ob_get_contents();
    ob_end_clean();
    return $out;
}
コード例 #4
0
array_shift($pm_order);
foreach ($pm_order as $i => &$pm_full_id) {
    $pm_full_id = str_replace('&amp;', '', $pm_full_id);
    $pm = leyka_get_pm_by_id($pm_full_id, true);
    if ($pm && in_array($pm_full_id, $pm_available)) {
        leyka_pm_sortable_option_html(false, $pm_full_id, $pm->label, $pm->label_backend);
    } else {
        unset($pm_order[$i]);
    }
}
$pm_order_flipped = array_flip($pm_order);
// Somehow in_array() working incorrectly for no reason :((
foreach ($pm_available as $pm_full_id) {
    // Add to the end of the order all PMs that are out of this order
    if (!array_key_exists($pm_full_id, $pm_order_flipped)) {
        $pm = leyka_get_pm_by_id($pm_full_id, true);
        if ($pm) {
            leyka_pm_sortable_option_html(false, $pm_full_id, $pm->label, $pm->label_backend);
            $pm_order[] = $pm_full_id;
        }
    }
}
?>

        </ul>

        <input type="hidden" name="leyka_pm_order" value="<?php 
echo leyka_options()->opt('pm_order');
?>
">
コード例 #5
0
ファイル: leyka-class-donation.php プロジェクト: GenV/Leyka
 public function __get($field)
 {
     switch ($field) {
         case 'id':
         case 'ID':
             return $this->_id;
         case 'title':
         case 'name':
             return $this->_post_object->post_title;
         case 'purpose':
         case 'purpose_text':
         case 'payment_title':
         case 'campaign_payment_title':
             return $this->_donation_meta['payment_title'];
         case 'status':
             return $this->_post_object->post_status;
         case 'status_label':
             $stati = leyka_get_donation_status_list();
             return $stati[$this->_post_object->post_status];
         case 'status_log':
             return $this->_donation_meta['status_log'];
         case 'date':
         case 'date_label':
             $date_format = get_option('date_format');
             $time_format = get_option('time_format');
             $donation_timestamp = strtotime($this->_post_object->post_date);
             return apply_filters('leyka_admin_donation_date', date($date_format . ' ' . $time_format, $donation_timestamp), $donation_timestamp, $date_format, $time_format);
         case 'date_timestamp':
             return strtotime($this->_post_object->post_date);
         case 'date_funded':
         case 'funded_date':
             $date_funded = $this->get_funded_date();
             return $date_funded ? date(get_option('date_format'), $date_funded) : 0;
         case 'payment_method':
         case 'payment_method_id':
         case 'pm':
         case 'pm_id':
             return $this->_donation_meta['payment_method'];
         case 'gateway':
         case 'gateway_id':
         case 'gw_id':
             return $this->_donation_meta['gateway'];
         case 'gateway_label':
             $gateway = leyka_get_gateway_by_id($this->_donation_meta['gateway']);
             return $gateway ? $gateway->label : __('Unknown gateway', 'leyka');
         case 'pm_label':
         case 'payment_method_label':
             $pm = leyka_get_pm_by_id($this->_donation_meta['payment_method']);
             return $pm ? $pm->label : __('Unknown payment method', 'leyka');
         case 'currency':
             return $this->_donation_meta['currency'];
         case 'currency_label':
             return leyka_options()->opt('leyka_currency_' . $this->_donation_meta['currency'] . '_label');
         case 'sum':
         case 'amount':
             return $this->_donation_meta['amount'];
         case 'main_curr_amount':
         case 'amount_equiv':
             return $this->_donation_meta['main_curr_amount'];
         case 'donor_name':
             return $this->_donation_meta['donor_name'];
         case 'donor_email':
             return $this->_donation_meta['donor_email'];
         case 'donor_email_date':
             return $this->_donation_meta['donor_email_date'];
         case 'managers_emails_date':
             return $this->_donation_meta['managers_emails_date'];
         case 'campaign_id':
             return $this->_donation_meta['campaign_id'];
         case 'gateway_response':
             return $this->_donation_meta['gateway_response'];
         case 'gateway_response_formatted':
             return $this->gateway ? leyka_get_gateway_by_id($this->gateway)->get_gateway_response_formatted($this) : array();
         case 'type':
         case 'payment_type':
             return $this->_donation_meta['payment_type'];
         case 'type_label':
         case 'payment_type_label':
             return __($this->_donation_meta['payment_type'], 'leyka');
         case 'init_recurring_payment_id':
         case 'init_recurring_donation_id':
             return $this->_post_object->post_parent;
         case 'init_recurring_payment':
         case 'init_recurring_donation':
             return $this->_post_object->post_parent ? new Leyka_Donation($this->_post_object->post_parent) : false;
         default:
             return apply_filters('leyka_get_unknown_donation_field', null, $field, $this);
     }
 }
コード例 #6
0
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;
}
コード例 #7
0
<?php

if (!defined('WPINC')) {
    die;
}
/**
 * Leyka Template: Radios
 * Description: Radio options for each payment method
 **/
$active_pm = apply_filters('leyka_form_pm_order', leyka_get_pm_list(true));
leyka_pf_submission_errors();
$curr_pm = leyka_get_pm_by_id(reset($active_pm)->full_id, true);
leyka_setup_current_pm($curr_pm, $curr_pm->default_currency);
?>

<div id="leyka-payment-form" class="leyka-tpl-radio">

<div class="leyka-payment-option">
<!-- <?php 
echo __("This donation form is created by Leyka WordPress plugin, created by Teplitsa of Social Technologies. If you are interested in some way, don't hesitate to write to us: support@te-st.ru", 'leyka');
?>
 -->
    <form class="leyka-pm-form" action="<?php 
echo leyka_pf_get_form_action();
?>
" method="post" id="leyka-form-common">

        <div id="amount-selector" class="form-part freeze-fields">
            <?php 
echo leyka_pf_get_amount_field();
?>