微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何为特定产品计划应用条纹优惠券? POST 详情: $request->plan price id , $coupon =>coupon id $card['id'] => card token

如何解决如何为特定产品计划应用条纹优惠券? POST 详情: $request->plan price id , $coupon =>coupon id $card['id'] => card token

我为 abc 产品添加了一张优惠券,在创建订阅时我可以为所有人申请该优惠券 产品。我希望它只能适用于 abc 产品。我在用着 https://cartalyst.com/manual/stripe/2.0#subscriptions 文档。

 $stripe->subscriptions()->create($stripe_customer_id,[
             'plan'   => $request->plan,'coupon' => $coupon,'default_payment_method' => $card['id'],]);

解决方法

您可以使用 applies_to 属性将优惠券应用于仅限于特定产品的订阅。例如,在下面的代码中,优惠券仅适用于prod_xxx,因此当创建订阅时的价格来自 prod_xxx 并且价格来自 prod_yyy,则折扣仅适用于 prod_xxx/price_xxx 的金额

$coupon = $stripe->coupons->create([
  'percent_off' => 25,'duration' => 'repeating','duration_in_months' => 3,'applies_to' => ["products" => ["prod_xxx"]]
]);

$stripe->subscriptions->create([
  'coupon' => $coupon->id,'customer' => 'cus_xxx','items' => [
    ['price' => 'price_xxx'],# <-- coupon will apply
    ['price' => 'price_yyy'],],]);

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。