#Yashish

1 messages ยท Page 1 of 1 (latest)

dusty mauveBOT
mystic kelp
thorn sedge
#

the invoice is in fail status

mystic kelp
#

When the invoice fails, it means that the invoice has been finalised and coupon can't be applied

thorn sedge
#

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)`
mystic kelp
thorn sedge
#

can we use
allow_promotion_codes

?

mystic kelp
#

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

thorn sedge
#

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?

mystic kelp
thorn sedge
#

I want the user to enter the coupon code during the payment i do not want to enter the static value in code

mystic kelp
#

That will not be possible with invoice or existing subscription

#

A coupon can only be applied through the code

thorn sedge
#

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

mystic kelp
#

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

thorn sedge
mystic kelp
#

Your system will verify the coupon if it is valid

thorn sedge
#

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

mystic kelp
#

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

thorn sedge
#

the Can there be another way fo apply the coupon in subscription update

mystic kelp
#

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

thorn sedge
#

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?

mystic kelp
#

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

thorn sedge
#

got error
Request req_xwwQfLVdWdfyNm: When payment_behavior is set to pending_if_incomplete, you can only pass supported params. coupon is not supported.

mystic kelp
#

I see! When pending_if_incomplete is used, coupon can't be used

dusty mauveBOT
thorn sedge
#

but that is to be used

timid gull
#

๐Ÿ‘‹ taking over for my colleague. Let me catch up.

#

do you have a request where it was working correctly?

timid gull
#

a request ID req_xxx

thorn sedge
#

the coupon in not working when updating the subscription

timid gull
#

do you have a request where that was the case?

thorn sedge
#

no

timid gull
#

then you can't really say it was working before

#

right?

thorn sedge
#

want to make it work

that's why i am asking how can i do it

where did I told it was working?

timid gull
#

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

thorn sedge
#

it was about
pending_if_incomplete

thorn sedge
timid gull
#

let's forget about the how now, and could we go back to what do you need to do?

timid gull
#

this is the code

thorn sedge
#

canyou csan go though this message

timid gull
#

let's forget about the code

#

could you please write your requirement as a user story?

thorn sedge
#

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

timid gull
#

you're still talking about code

#

this is not helpful to be honest