这是我尝试过的:
$company = Auth::user()->company; $customer = $company->subscription()->getStripeCustomer(); // returns a StripeGateway object $customer->subscription->applyCoupon($input['coupon_code']);
这是错误消息:
"Call to undefined method Stripe_Subscription::updateSubscription()"
我可以将applyCoupon()方法作为一个整体用于客户,但不是实际的订阅…想法赞赏.
Stripe文档仅显示如何从订阅中删除折扣:
Discount Object.我在他们的文档中找到的唯一其他信息是:
Coupons and discounts
If you want to provide discounts to certain customers,you can create coupon codes in the Dashboard. Coupons have a discount percentage and a duration,so you could create coupons like a 10% lifetime discount,or a one month 50% discount,etc. Coupons can also have expiration dates attached,after which they can’t be used. Here’s an example of adding a discount to a user’s subscription. In this case,we’ve already created a coupon called 50OFF1MONTH:
curl https://api.stripe.com/v1/customers/cus_4fdAW5ftNQow1a \
-u sk_test_4LOIhlh19aUz8yFBLwMIxnBY: \
-d coupon=50OFF1MONTH
但是,这不是很有帮助.再一次,Laravel的文档有点优雅,并且缺少关于该主题的任何信息.
我想知道我是否只需要使用新优惠券完全重新创建订阅对象……但这并不理想,因为您需要一个卡片令牌.
更新1
我可以确认这实际上是将优惠券应用于订阅本身
$user->subscription('monthly') ->withCoupon('code') ->create($creditCardToken);
然而,问题是如何在事实之后添加优惠券.