致命错误:在第45行的/shortcodes.php中调用未定义的函数pippin_get_stripe_plans()

时间:2016-11-25 11:55:13

标签: php jquery wordpress stripe-payments

我正在关注本教程https://pippinsplugins.com/stripe-integration-part-4-multiple-recurring-payment-options/

在我尝试检索条纹计划之前,每件事都运行正常。当我检查时,它给了我这个错误。 致命错误:在第45行的/includes/myplugin/shortcodes.php中调用未定义的函数pippin_get_stripe_plans()

enter image description here

这是我的shortcode.php,它正在创建此问题

<div class="sk-form-row" id="stripe-plans" style="display:none;">
            <label><?php _e('Choose Your Plan', 'pippin_stripe'); ?></label>
            <select name="plan_id" id="stripe_plan_id">
                <?php 
                    $plans = pippin_get_stripe_plans();
                    if($plans) {
                        foreach($plans as $id => $plan) {
                            echo '<option value="' . $id . '">' . $plan . '</option>';
                        }
                    }
                ?>
            </select>
        </div>

我从stripefunction.php中调用它

<?php

function pippin_get_stripe_plans() {

global $stripe_options;

// load the stripe libraries
require_once(STRIPE_BASE_DIR . '/Stripe-php/init.php');

// check if we are using test mode
if(isset($stripe_options['test_mode']) && $stripe_options['test_mode']) {
    $secret_key = $stripe_options['test_secret_key'];
} else {
    $secret_key = $stripe_options['live_secret_key'];
}

\Stripe\Stripe::setApiKey($secret_key);
// retrieve all plans from stripe
$plans_data = \Stripe\Plan::all();
// setup a blank array
$plans = array();
if($plans_data) {
    foreach($plans_data['data'] as $plan) {
        // store the plan ID as the array key and the plan name as the value
        $plans[$plan['id']] = $plan['name'];
    }
}
return $plans;
}

可能不需要,但这是我用于下拉显示计划的jquery。

$('input[name|="recurring"]').change(function() {
    if($(this).val() == 'yes') {
        $('#stripe-plans').slideDown();
    } else {
        $('#stripe-plans').slideUp();
    }
});

0 个答案:

没有答案