cartalyst / stripe-laravel

Cartalyst Stripe package integration for Laravel.
BSD 3-Clause "New" or "Revised" License
336 stars 58 forks source link

Coupon Code Calculations #72

Closed TheDoctorD closed 3 years ago

TheDoctorD commented 3 years ago

Should I be calculating the percentage off myself, or is there a built in method to apply the coupon to a stripe price id and get the result?

Example coupon is 99% off of $19.99. I get this as being .19 cents, but on the stripe invoice it is .20 cents.

brunogaspar commented 3 years ago

Hey

Usually you create the coupon and set the percentage or amount to be discounted.

Then when you create either an invoice or an order, you can apply that coupon there. Don't think you need to perform any kind of calculation.

But give me more information on what you're trying to achieve so i can try to help you out a bit further.

TheDoctorD commented 3 years ago

So I have the user at a checkout page, that shows the price of the subscription. I want to have them enter in a public facing promotion code such as SAVE50, have them apply it, and show them what they are going to save before checking out.

Screenshot 2021-06-29 085401

I didn't see anything about applying a coupon to a price before checking out. I only saw the method to apply the coupon to a subscription when it gets created:

$stripeSubscription = $user->newSubscription($product_title, $stripe_price_id)->withCoupon($subscription_product_coupon->coupon_stripe_id)->create($payment_method_token);

Thanks for any insight.

brunogaspar commented 3 years ago

That seems to be Laravel Cashier related code, so nothing to do with this integration or SDK.

But either way, i'm not sure that is currently possible on Stripe itself, unless you use their own checkout system, otherwise you need to perform these calculations yourself :)

Hope it helps.

TheDoctorD commented 3 years ago

Ah crap. Sorry!