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 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥15 Oracle触发器记录修改前后的字段值
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题