Php 请帮助我调试条带错误

Php 请帮助我调试条带错误,php,stripe-payments,Php,Stripe Payments,错误:[16-May-2018 22:16:06 UTC]PHP致命错误:未捕获异常“Stripe\Error\InvalidRequest”,消息“无效源对象:必须是字典或非空字符串”。请参阅API请求“req_6uGybuHR3adjqW”中/home/autravelservice/public_html/wp content/plugins/ats/libraries/stripe-php-6.0.0/lib/apirequector.php:120中“”的API文档 请看我的代码有什么

错误:[16-May-2018 22:16:06 UTC]PHP致命错误:未捕获异常“Stripe\Error\InvalidRequest”,消息“无效源对象:必须是字典或非空字符串”。请参阅API请求“req_6uGybuHR3adjqW”中/home/autravelservice/public_html/wp content/plugins/ats/libraries/stripe-php-6.0.0/lib/apirequector.php:120中“”的API文档

请看我的代码有什么我做错了吗

// Set your secret key: remember to change this to your live secret key in production
        // See your keys here: https://dashboard.stripe.com/account/apikeys
        \Stripe\Stripe::setApiKey($sk);

        // Token is created using Checkout or Elements!
        // Get the payment token ID submitted by the form:
        $token = $payment_details['token'];
        //echo 'pay:' . $pay_amount;

        // Create customer:
        $i = 0;
        foreach(get_field('applicant', $post_id) as $applicant) {
            if($i++ == 0) {
                $applicant_details = $applicant['applicant_details'];
                $contact_details = $applicant['contact_details'];


                $name_first = $applicant_details['first_name'];
                $name_last =  $applicant_details['last_name'];
                $email = $contact_details['email'];

                $user_info = array("First Name" => $name_first, "Last Name" => $name_last);

                $customer = \Stripe\Customer::create(array(
                    "email" => $email,
                    "card"  => $token,
                    "metadata" => $user_info
                ));

                // Charge the user's card:
                $charge = \Stripe\Charge::create(array(
                    "customer" => $customer->id,
                    "amount" => $pay_amount,
                    "currency" => "usd",
                    "description" => "Australian Travel Service"
                ));
            }
        }   
        if($charge->status == 'succeeded') {
            $counter = range(1, 5);
            $counter= shuffle($counter);
            $orderid = 'AUS-CU-' . date('Ymd') . $post_id . $counter;
            echo '<input type="hidden" name="orderid" id="app_order_id" value="'.$orderid.'">';
            echo '<input type="hidden" id="applicant_count" value="'.$applicant_count.'">';
            echo '<input type="hidden" id="processing_type" value="'.$processing_fee_type[0].'">';
            echo '<input type="hidden" id="order_total" value="'.$pay_amount.'">';
            appFormAdminMail($post_id, $orderid);
            acf_form(array(
                'id' => 'survey-form',
                'post_id' => $post_id,
                'field_groups'  => array(158),
                'return' => './survey-thank-you/?record=%post_id%',
                'submit_value' => 'SUBMIT SURVEY',
                'html_submit_button' => '<button type="submit" class="acf-btn red-btn rounded-btn">%s</button>'
            ));
        } else {
            echo 'Payment error...';
        }
//设置您的密钥:请记住在生产中将其更改为您的实时密钥
//请在此处查看您的钥匙:https://dashboard.stripe.com/account/apikeys
\Stripe\Stripe::setApiKey($sk);
//令牌是使用签出或元素创建的!
//获取表单提交的支付令牌ID:
$token=$payment_details['token'];
//回音“pay:”$支付金额;
//创建客户:
$i=0;
foreach(get_字段('applicator',$post_id)作为$applicator){
如果($i++==0){
$applicator_details=$applicator['applicator_details'];
$contact_details=$applicator['contact_details'];
$name_first=$applicator_details['first_name'];
$name_last=$applicator_details['last_name'];
$email=$contact_details['email'];
$user\u info=array(“First Name”=>$Name\u First,“Last Name”=>$Name\u Last);
$customer=\Stripe\customer::创建(数组)(
“email”=>$email,
“卡”=>$token,
“元数据”=>$user\u信息
));
//向用户的卡收费:
$charge=\Stripe\charge::创建(数组)(
“客户”=>$customer->id,
“金额”=>$pay\U金额,
“货币”=>“美元”,
“描述”=>“澳大利亚旅行社”
));
}
}   
如果($charge->status==“成功”){
$counter=范围(1,5);
$counter=洗牌($counter);
$orderid='AUS-CU-'。日期('Ymd')。$post_id.$counter;
回声';
回声';
回声';
回声';
appFormAdminMail($post\u id,$orderid);
acf_表格(数组)(
“id”=>“调查表”,
“post\u id”=>$post\u id,
“字段组”=>数组(158),
“return'=>”/调查谢谢/?记录=%post\u id%,
“提交值”=>“提交调查”,
“html\u提交按钮”=>“%s”
));
}否则{
回显“付款错误…”;
}

问题似乎出在您的
$token
变量上,它可能格式错误或缺失。我建议您
echo
查看它的价值是什么,或者分享更多关于如何创建
$payment\u details
的代码