Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 此客户没有附加的付款来源_Php_Wordpress_Stripe Payments - Fatal编程技术网

Php 此客户没有附加的付款来源

Php 此客户没有附加的付款来源,php,wordpress,stripe-payments,Php,Wordpress,Stripe Payments,我的wordpress有一个问题,我使用stripe,我有一个错误消息:“这个客户没有附加的付款来源”,但我不明白为什么。在dev环境中我没有问题,现在在prod中我有这个问题。有关信息,我使用卡号4242进行测试 非常感谢你的帮助 if(isset($_POST['action']) && $_POST['action'] == 'stripe' && wp_verify_nonce($_POST['stripe_nonce'], 'stripe-nonce')

我的wordpress有一个问题,我使用stripe,我有一个错误消息:“这个客户没有附加的付款来源”,但我不明白为什么。在dev环境中我没有问题,现在在prod中我有这个问题。有关信息,我使用卡号4242进行测试

非常感谢你的帮助

if(isset($_POST['action']) && $_POST['action'] == 'stripe' && wp_verify_nonce($_POST['stripe_nonce'], 'stripe-nonce')) {

    global $stripe_options, $post;


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

    // retrieve the token generated by stripe.js
    $token = $_POST['stripeToken'];
    $amount = base64_decode($_POST['amount'])*100;
    $email = $_POST['email'];
    $plan_nickname = $_POST['plan_nickname'];
    $plan_id = $_POST['plan_id'];
    $nom = $_POST['name'];
    $prenom = $_POST['prenom'];
    $adresse = $_POST['address-line1'];
    $ville = $_POST['address-city'];
    $zip = $_POST['address-zip'];



    // 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'];
    }

    // attempt to charge the customer's card
    try {

        \Stripe\Stripe::setApiKey($secret_key);

        $product = \Stripe\Product::create([
            'name' => $stripe_options['product_name'],
            'type' => 'service',
        ]);

        $plan = \Stripe\Plan::create([
            'product' => $stripe_options['product_key'],
            'nickname' => $plan_nickname,
            'interval' => 'month',
            'currency' => 'eur',
            'amount' => $amount,
          ]);

        $customer = \Stripe\Customer::create([
            'email' => $email,
            'source' => $token,
            'description' => $plan_nickname,
        ]);

        $subscription = \Stripe\Subscription::create([
            'customer' => $customer->id,
            'items' => [['plan' => $plan_id]],
        ]);

        // redirect on successful payment
        $redirect = add_query_arg('payment', 'paid', $_POST['redirect']);

    } catch (Exception $e) {
        // redirect on failed payment
        //$redirect = add_query_arg('payment', 'failed', $_POST['redirect_failed']);
        var_dump($e);

    }

    // redirect back to our previous page with the added query variable
    wp_redirect($redirect); exit;
}

}检查条纹图上的平面图。如果计划有试用期,则需要使用试用期创建订阅。我正在使用laravel收银台和react stripe收银台,这对我很有用:

$user->newSubscription('main', 'basic')
            ->trialDays(30)
            ->create($request->token);

实际上,对于Stripe,如果客户没有注册卡(支付源),则无法创建订阅,因此您需要在Stripe中添加该客户的CC信息。或者可能是stripe的试用期在您的帐户中结束了问题是在我的post请求中StripeToken=null。我没有创建任何令牌!!好的,很好,那么你知道你需要做什么了吗?是的,你应该检查你创建令牌的前端代码。请注意,您不能在实时模式下使用4242测试卡,并且会出现错误,因此我敢打赌这就是发生的情况。