【问题标题】:Is it possible to get a Stripe token using customer id in Stripe payment?是否可以在 Stripe 支付中使用客户 ID 获得 Stripe 令牌?
【发布时间】:2017-07-16 06:50:06
【问题描述】:

我想使用客户 ID 检索 Stripe 令牌。我尝试在 PHP 中使用以下方法:

$num='cus_AkeyZp1eIsJHiI';
$customer=\Stripe\Customer::retrieve($num);
$customer=$customer->sources;
$customer=$customer->数据;

【问题讨论】:

    标签: stripe-payments


    【解决方案1】:

    如果您想使用客户的信用卡凭据在 Stripe 上创建另一个客户帐户,请使用:

    $token = \Stripe\Token::create(array(
        "customer" => $num,
    ));
    echo $token->id;
    

    您在此处创建了代表客户当前卡的令牌。如果需要,您现在可以使用此令牌创建新客户。

    $customer = \Stripe\Customer::create(array(
        "email" => {CUSTOMER_EMAIL},
        "source" => $token->id
    ));
    

    我认为没有任何方法可以检索您在创建客户时创建的令牌。

    或者如果你只需要他附上的卡ID,你可以试试:

    $num='cus_AkeyZp1eIsJHiI';
    $customer=\Stripe\Customer::retrieve($num);
    $customer = $customer->__toArray(true);
    print_r($customer['sources']['data']);
    

    这会将卡片附在客户身上。

    【讨论】:

      猜你喜欢
      • 2018-05-30
      • 1970-01-01
      • 2018-05-26
      • 2017-09-19
      • 2018-09-01
      • 1970-01-01
      • 2015-03-01
      • 2020-08-20
      • 2012-09-12
      相关资源
      最近更新 更多