dongpengyu1363 2016-03-30 17:04
浏览 50

Laravel Cashier - 使用现有客户对象创建新订阅

I'm using Laravel Cashier along with Stripe to manage subscriptions. The user will supply their credit card information when signing up, but they won't be subscribed in a specific plan at this point. So I can successfully use Stripe Checkout to create a Stripe customer object and save the Stripe customer ID in my database. But when it comes time for the user to enroll in a plan, I can't see a way to use the Stripe customer ID to enroll them in the plan they want.

Of course, I could ask for their credit card information again and get a Stripe token to use with Laravel Cashier, but I'd like to avoid this since the app already created a Stripe customer object when they signed up and I'd like to simply use the existing customer object to charge their credit card rather than asking for their card number again.

To try illustrate what I'm trying to do, here is some sample code from the Laravel docs:

$user->newSubscription('main', 'monthly')->create($creditCardToken);

But what I'd like to be able to do is something like this (note the change to the create method:

$user->newSubscription('main', 'monthly')->create($user->stripe_id);

Any advice?

  • 写回答

2条回答 默认 最新

  • douzhendi4559 2016-08-22 21:19
    关注

    If there is a stripe ID for the user, you don't have to supply the token

    $user->newSubscription('main', 'monthly')->create();
    

    Have a look at the SubscriptionBuilder class.

    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度