Php 向现有消费者收取分条费用

Php 向现有消费者收取分条费用,php,stripe-payments,Php,Stripe Payments,我使用此代码付款,并在我的stripe仪表板上创建新客户 $customer = \Stripe\Customer::create([ "name" => $utente, "source" => $_POST['stripeToken'], "email" => $row['mail'], ]); $char

我使用此代码付款,并在我的stripe仪表板上创建新客户

            $customer = \Stripe\Customer::create([
                "name" => $utente,
                "source"  => $_POST['stripeToken'],
                "email" => $row['mail'],
            ]);
            $charge = \Stripe\Charge::create([
                "customer" => $customer->id,
                "amount" => $amount_cents,
                "currency" => "eur",
                "description" => $description
            ]);
当用户注册并连接到我的网站时,我会从我的网站的仪表板中获取信息,例如名称或用于创建新客户的电子邮件

这涉及到用户的第一个payment.php文件。 在第二个用户的付款上,站点重定向到第二个.php文件,在那里我需要向先前创建的客户添加第二个付款。问题是,如果我保留相同的代码,在stripe仪表板上,我会发现自己有两个相同的客户。我不知道如何获取客户id,当我重定向到第二个付款页面时,作为用户信息,我只有邮件和姓名。。我该怎么办

我将通过搜索stripe api参考来尝试类似的方法:

        $customer = \Stripe\Customer::all([
            'email' => $row['mail']
        ]);
        $charge = \Stripe\Charge::create([
            "customer" => $customer['data']->id,
            "amount" => $amount_cents,
            "currency" => "eur",
            "description" => $description
        ]);
但它给了我错误

Must provide source or customer..

列出客户将返回具有数据属性的对象<代码>数据是一个客户列表,因此在查看客户ID之前,您需要索引到该列表并抓取其中一个客户。它应该类似于:

$customer = \Stripe\Customer::all([
    'email' => $row['mail']
]);
$charge = \Stripe\Charge::create([
    'customer' => $customer->data[0]->id,
    'amount' => $amount_cents,
    'currency' => 'eur',
    'description' => $description
]);

我怀疑你只是想要
$customer->id
,而不是
$customer['data']->id
。我怀疑
Customer::all
返回的是一个客户数组,而不仅仅是一个。我也尝试过,但给出了相同的错误。。无论如何,这就是$customer值:我尝试了$customer->data->id、$customer['data']->id和$customer->id,但它给了我相同的错误,您需要
打印($customer)
来查看其中的内容。同样,我怀疑它将是一个数组,这意味着您尝试过的所有方法都不起作用。我使用print_r查看输出(就是我放在了pastebin上),是的,它是一个多维数组,但idk如何只获取此数组的子值,另外,因为我不知道它是否是一个特定的条带输出,因此它有自己精确的方法来调用值,所以在引用中它没有提到它