douxianxing5712 2018-04-09 19:24
浏览 159
已采纳

Stripe订阅成功后,获取最后4位数的信用卡

For compliance reasons I am generating tokens on the client side and sending those details to stripe. I want to display the last four digits and the type of card on my confirmation page

I am creating a customer

// Create a Customer:
$customer = \Stripe\Customer::create([

  'source' => $token,

  'email' =>  $current_user->user_email,

]);

than adding them to a subscription

//create the subscription for the customer
  $subscription = \Stripe\Subscription::create(array(

        'customer' => $customer->id,

        "items" => array(
                      array(
                         "plan" => "dpc-standard",
                      ),
         )
    ));

The subscription returns https://stripe.com/docs/api#subscription_object a ton of data including the invoice_id that is generated for the subscription but doesn't return any CC details

  • 写回答

1条回答 默认 最新

  • douningle7944 2018-04-09 20:40
    关注

    When you create a Customer and pass the source parameter set to a token id, it will save that card on the new customer. The value returned by this call is a Customer object with the sources property which will contain the new card you just saved.

    You can access the last 4 digits easily using:

    $last4 = $customer->sources->data[0]->last4;
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 MATLAB运行显示错误,如何解决?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 UE5#if WITH_EDITOR导致打包的功能不可用
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题
  • ¥20 yolov5自定义Prune报错,如何解决?
  • ¥15 电磁场的matlab仿真
  • ¥15 mars2d在vue3中的引入问题
  • ¥50 h5唤醒支付宝并跳转至向小荷包转账界面
  • ¥15 算法题:数的划分,用记忆化DFS做WA求调