繁体   English   中英

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

[英]How to retrieve the stripe customer id from the stripe object after creation of the customer

在此处输入图片说明

<?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'];

这将为您提供帮助。

您可以使用客户对象获取ID

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

echo $customer->id;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM