#s0viet-prorate
1 messages · Page 1 of 1 (latest)
could you share some examples of the code you wrote, the information you're looking at exactly, and what you expected to see instead?
I need some specific examples to look at to be able to follow unfortunately
Ok, give me a second
stripe.Subscription.modify(
subscription_id,
coupon=self._coupon_id,
proration_behavior='always_invoice',
proration_date=proration_date
)
I expect this API call to change subscription immediately as the subscription is unpaid at that moment.
ok and what happens instead? What is the sub_xxx ID of the subscription object you ran that on so I can have a look at it too?
I deleted the subscription, I can run it again
Generally - after this call , we run:
upcoming_invoice = stripe.Invoice.upcoming(
subscription=subscription_id,
subscription_proration_date=proration_date
)
to retrieve the pricing which IS GOOD - the price appears to be discounted.
Then , after user paid for the subscription, the pricing is still the full one - in order history the Invoice is for the full price, also panel shows that coupon would apply on the next billing cycle
sub_1K02vsHLVd2NTJNX0LptWPNF
Above is example subscription
This is how we create the subscription:
subscription = stripe.Subscription.create(
customer=self._stripe_customer["id"],
items=[{
'price': get_stripe_subscription_product_id(),
}],
automatic_tax={'enabled': True},
payment_behavior='default_incomplete',
expand=['latest_invoice.payment_intent']
)
thanks, give me a while to think/look
ok I think I get it
so yes you add the coupon, and the next recurring invoice will be discounted, indeed. Can you clarify what you want to happen additionally/instead? (I'm assuming you want some kind of invoice or payment to happen now at the point you update the sub to add the coupon)
As mentioned previously....
I want current subscription to change price.
Because we had to follow your flow - create subscription, then pay for it - after creating it we let users to still discount it before the paymetn
not sure I follow. Change price from what to what?
In this flow, you created the subscription, and the customer paid the $300 already. Now you're adding a coupon, which will apply to their next payment of $300 next month.
I think you think the subscription is still incomplete or something and that first payment hasn't happened? But it has, you paid the invoice(you confirmed the latest_invoice.payment_intent on the frontend which pays it).
No - I said already
In this flow, you created the subscription, and the customer paid the $300 already
The customer didn't pay for it.
We create an unpaid subscription that has to be modified before the payment
Yes, after the modification I completed it...
Yup! But I modified it before subscription was paid
So:
- Create subscription, fetch pricing
- Update it if coupon is applied, retrieve new pricing
- Pay for it
I think this one above should be clear, sorry if I was misleading you
then yeah, unfortunately this incomplete mode is not as flexible as you want it to be, applying the coupon doesn't actually change the outstanding invoice while the subscription in incomplete
I think you can try also modifying the outstanding invoice with a coupon, though I'm unsure the API will let you
like you could call https://stripe.com/docs/api/invoices/update#update_invoice-discounts on the subscription.latest_invoice before paying it
Hmm but yesterday I was told we can update it by proration behavior... how can we do this then?
I don't think we realised you were talking about modifying an incomplete subscription yesterday
I don't want to project subscription flow from scratch, I was basically following the guidelines, Can we just change the subscription default behavior or?
well the way I would do this is apply the coupon when creating the subscription
i.e. ask the customer for whatever you need to apply the coupon before you call stripe.Subscription.create and then pass in discounts if you need to at that point, instead of creating the subscription and then adding the coupon while it's incomplete
I get where you're coming from I think and I agree it would be nice it it worked more like the way you want(the subscription is like a 'draft' you can modify before finally confirming the Invoice PaymentIntent) but it doesn't , the incomplete status is fairly barebones and not exactly a "draft" as such
But this is exactly we don't want to do, as this requires us to change the flow....
Is it any way to not spend that much time on it? Like, using any different behavior for subscription that allow us to pay for it later?
Also, how we should then use:
- finishing the payment - as we pass clientSecret for confirmCardPayment
- modyfying coupons.... as the user is always able to do this on other ecommerce
as far as I understand your use case the best reasonable option is to do things upfront in your business logic before calling the Stripe API(i.e don't create the subscription and present the Invoice/PaymentIntent for the customer to pay until you have finalised the amount and any discounts)
okay, this is probably now the worst thing for us, but thanks for helping anyway, we woudl see what next
Hey I need to bump this
still no answer for:
1. finishing the payment - as we pass clientSecret for confirmCardPayment
2. modyfying coupons.... as the user is always able to do this on other ecommerce
Once coupon is applied, how we can change it basically as this is normal feature on every gateway or e-commerce
it's the same type of API call as ^^
you just add the new coupon that you created to the existing subscription, if you are changing the details of the discount.
Okay but we would have same issue again... right?
So we have to actually display/change the coupon before the subscritpion creation always, right?
that's what I meant by "do things upfront in your business logic before calling the Stripe API(i.e don't create the subscription and present the Invoice/PaymentIntent for the customer to pay until you have finalised the amount and any discounts)", yep
my answer just now is assuming you mean changing the coupon on an already-active subscription
but I guess you still mean changing the coupon in this "draft/incomplete" stage when creating the subscription? I thought I answered that(which is why I wasn't replying), but the overall answer there is the only reasonable option it to only call the Stripe API when you know the final discount you want to apply.
Ok, thank you. Is there however any way to call billing_cycle_anchor while updating subscription?
(as I think maybe that may help us) - so far I got error I can't change it
And since we already started talking... is there any API on Stripe side so we can calculate the pricecs dynamically? I was asking same question before and the only way was to use invoice preview, but now it cannot be done.
generally you'd use trial periods to push the billing cycle anchor(https://stripe.com/docs/billing/subscriptions/billing-cycle#changing describes this in detail)
can you expand on what "calculating the prices dynamically" means to you exactly? (not trying to push back, just those words can mean a lot of things so I want to be sure I'm understanding you)
Yeah no problem, we basically show our customers a total price, tax, subtotal and discount
right now, once discount is applied, we again retrieve upcoming invoicec and get the pricing
yep, that should work! You can get the 'upcoming invoice' of a subscription that doesn't exist yet, to be clear(I know it's not obvious)
so if you have logic upfront to pick the total prices/discounts you're going to use, you can pass those into subscription_items to get a preview of the first payment before creating the subscription
Oh, so I can just send the products we want to subscribe for, right?
you can yes