Closed amanvision closed 3 years ago
Seems like you're trying to define a promotion code through your subscription settings and a coupon at the same time. This isn't supported by Stripe.
I would like to offer a discounted subscription to end-users, so I have created the following on Stripe:
And using the above code to apply the coupon, but getting a response "You may only specify one of these parameters: allow_promotion_codes, discounts", not sure what I did wrong.
config('setting.subscription.pricing.rl_yearly')
Remove the promotion code from this config.
Ah hmm, no that's not the issue it seems. I wonder what's going wrong for you but it's best that you contact Stripe for this as I can't see anything wrong with your code.
Ok, I figured it out. Instead of using withCouponCode, i'm using subscripton_data option like shown below:
$checkout = auth()->user()->newSubscription('default', config('setting.subscription.pricing.rl_yearly')) ->checkout([ 'success_url' => route('home'), 'cancel_url' => route('subscriber.setup'), 'billing_address_collection' => 'required', 'subscription_data' => [ 'coupon' => config('setting.subscription.coupon.discounted_subscription') ] ]);
That doesn't sound right. The current implementation uses the documented way by Stripe: https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-discounts-coupon
Description:
Getting error "You may only specify one of these parameters: allow_promotion_codes, discounts." even when allowPromotionalCodes() is not specified in below code.
Looks like the allow_promotion_codes option has a default value setup.
$checkout = auth()->user()->newSubscription('default', config('setting.subscription.pricing.rl_yearly')) ->withCoupon(config('setting.subscription.coupon.discounted_subscription')) ->checkout([ 'success_url' => route('home'), 'cancel_url' => route('subscriber.setup'), 'billing_address_collection' => 'required', ]);