#Yashish
1 messages ยท Page 1 of 1 (latest)
Once the invoice is finalised, coupon can't be applied. If the invoice is still in draft status, then coupon can be applied with discounts.coupon parameter: https://stripe.com/docs/api/invoices/update#update_invoice-discounts-coupon
A coupon can also be applied on Subscription: https://stripe.com/docs/billing/subscriptions/coupons
When the invoice fails, it means that the invoice has been finalised and coupon can't be applied
can i provide you with the code that i am using so that you can tell where i can add the option for user to add the coupon
this code is for subscription update
`subscription = stripe.Subscription.retrieve(subscription_id)
subscription_item_id = subscription['items']['data'][0]['id']
new_plan = stripe.Plan.retrieve(plan_id)
new_plan_stripe_id = new_plan["id"]
subscription_item = {
"id": subscription_item_id,
"price": new_plan_stripe_id,
}
# Update the subscription with the new plan and proration behavior
subscription = subscription.modify(
subscription_id,
proration_behavior='always_invoice',
items=[subscription_item],
payment_behavior='pending_if_incomplete',
)
subscription = stripe.Subscription.retrieve(subscription_id)
invoice = stripe.Invoice.retrieve(subscription.latest_invoice, expand=['payment_intent'])
invoice_url = invoice.hosted_invoice_url
print("661 invoice_url-->",invoice_url)
return redirect(invoice_url)`
The coupon can be applied when modifying the subscription as mentioned here: https://stripe.com/docs/billing/subscriptions/coupons
can we use
allow_promotion_codes
?
allow_promotion_codes is only available new subscription created through Checkout Session. It doesn't work on existing subscription or subscription created through API directly
Stripe doesn't support applying coupon after an invoice is finalised
if we want to modify the old subscription and for the payment of thatb i want user to apply the coupon then it can be possible?
Yes, you can set coupon in Subscription Update API: https://stripe.com/docs/api/subscriptions/update#update_subscription-coupon
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
I want the user to enter the coupon code during the payment i do not want to enter the static value in code
That will not be possible with invoice or existing subscription
A coupon can only be applied through the code
This signifies that after setting up a subscription, if a user intends to upgrade the subscription to a higher tier, such as the "Advance" plan, there is no provision for customers to manually input a coupon code during the payment process for the subscription upgrade.
is this conform?
In this scenario, when a user starts with the basic plan and wishes to switch to the advanced plan
Your system should implement the coupon redemption. For example, when user decides to upgrade, your website will have a section for customer to enter the promotion/coupon code. Then you update the subscription and set coupon in the API
but then there will not be a way to verify the coupon?
Your system will verify the coupon if it is valid
how ?
here if the coupon is deleted in stripe of if it is expire or if the coupon can ot to applied to that product
When you set the coupon, the discount will only apply when the condition is fulfilled. If the coupon is expired, it won't be applied to the subscription
the Can there be another way fo apply the coupon in subscription update
What is the other way you're looking for? Currently, coupon can only be applied via API, but not on the invoice interface after updating the subscription
When creating a coupon in Stripe:
For subscriptions and customers, this setting determines the duration for which the coupon remains applicable after redemption. For one-off invoices, both "once" and "forever" coupons are accepted.
If the coupon is set to "once," and a user applies the coupon when purchasing a subscription, it is used for that transaction. If the user later updates their subscription and applies the same coupon again, will it be valid for the update as well?
Yes, once means it'll be applied on the first invoice at the time when subscription is updated or created. I'd recommend giving a try in the test mode
got error
Request req_xwwQfLVdWdfyNm: When payment_behavior is set to pending_if_incomplete, you can only pass supported params. coupon is not supported.
I see! When pending_if_incomplete is used, coupon can't be used
but that is to be used
๐ taking over for my colleague. Let me catch up.
do you have a request where it was working correctly?
.
a request ID req_xxx
the coupon in not working when updating the subscription
you said it was working before
do you have a request where that was the case?
no
want to make it work
that's why i am asking how can i do it
where did I told it was working?
but that is to be used
what did you mean by that then?
I might have misinterpreted the sentence
as my colleague mentioned coupon won't work with pending_if_incomplete
it was about
pending_if_incomplete
can you go through this statement
let's forget about the how now, and could we go back to what do you need to do?
.
this is the code
canyou csan go though this message
this i my current code and i want to apply the coupon so that user can enter the coupon while doing the payment for the subscription update