gpt4 book ai didi

php - 创建客户后如何从Stripe对象中检索Stripe客户ID

转载 作者:行者123 更新时间:2023-12-03 22:54:51 26 4
gpt4 key购买 nike

enter image description here

<?php
require_once('Stripe/lib/Stripe.php');
Stripe::setApiKey(trim($pkey));

try
{
$customer = Stripe_Customer::create(array(
'email' => $_POST['stripeEmail'],
'source' => $_POST['stripeToken'],
'plan' => trim($plan)
));

}
catch(Exception $e)
{
//header('Location:oops.html');
error_log("unable to sign up customer:" . $_POST['stripeEmail'].
", error:" . $e->getMessage());
}
?>


在这里我想获取客户ID,所以我打印$ customer对象,它给出了条纹对象,但是我不知道如何从该结果中获取客户ID。
如果有人知道,请帮助我。
提前致谢

最佳答案

只需使用以下代码行,您将获得客户ID。

 $customer = $stripe->customers()->create([
'email' => $_POST['stripeEmail'],
'source' => $_POST['stripeToken'],
'plan' => trim($plan)
]);

echo $customer['id'];


这将为您提供帮助。

关于php - 创建客户后如何从Stripe对象中检索Stripe客户ID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36939144/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com