#Yashish

1 messages · Page 1 of 1 (latest)

carmine juncoBOT
random hornet
#

hello! there's no way to pass a success and fail url for a hosted invoice

distant cloud
#

then how we can know whether the payment was successful or not

random hornet
#

you can listen for the invoice.paid webhook event

distant cloud
#

can there be any condition that we can keep not allow user with Overdue payments

random hornet
#

i'm sorry, but i don't understand, can you try rephrasing?

distant cloud
#

when user is redirect to hosted invoice url at that time if he does not do the payment at that time the plan moves to over due

random hornet
#

okay, what's the behaviour you expect to happen instead?

distant cloud
#

i want first the payment occur and if it is success then only plan gets updated and if payment fail or cancle by user then no update

there should not be anything like overdue

carmine juncoBOT
random hornet
distant cloud
#

can there be any way to manage this through code?

clever crow
#

No this settings is Dashboard only

distant cloud
#

here i have done the setting like

#

then on the fail transaction it should cancel the plan but this is not happening

clever crow
#

subscription ID?

distant cloud
#

sub_1N5k6PSGNnwNJbGS2VSok7aK

clever crow
#

I don't see you've set any retry schedule.

#

Can you set up one and see if the subscription is cancelled when the retry fails?

distant cloud
#

i want it to stop on the spot
instead of any retry

clever crow
#

Then you can listen to invoice.payment_failed event and manually cancel the subscription

distant cloud
#

invoice.payment_failed is is not getting called

clever crow
distant cloud
#

it is called when we modify the plan

before it is redirected to the hosted invoice url

clever crow
#

I don't understand what's the problem here, I can see there's a invoice.payment_failed in the screenshot that you shared.

distant cloud
#

2 event

#

it is being called before the payment is done

it occurs when the user modifies the subscription and redirects to the hosted invoice url

clever crow
#

the webhook events are not guaranteed to be arrived in sequence.

tiny beacon
#

@distant cloud what is 'not solved'?

tiny beacon
#

What's being called before 'payment is done'? You need to be verbose when you're describing the issue

distant cloud
#

invoice.payment_failed

tiny beacon
#

Sure, seems expected. When you modify/update the subscription we attempt to take payment for those changes reflected on a new invoice. Those payments can fail (i.e. 3DS requested), so those events would be fired

#

I'm not sure I understand why that's an issue?

distant cloud
#

subscription = subscription.modify(
subscription_id,
proration_behavior='always_invoice',
items=[subscription_item]
)

    subscription = stripe.Subscription.retrieve(subscription_id)

    invoice = stripe.Invoice.retrieve(subscription.latest_invoice)
    
    # return redirect(invoice.hosted_invoice_url)

so then in this code how we can redirect the user to the hosted invoice url before the payment failure
occure

tiny beacon
distant cloud
#

now the payment status is being change to

#

still the payment is not done the plan got change and move to overdue

tiny beacon
#

Ok, and is that not unexpected based on what you told me? You wanted to prevent an automatic payment attempt (and the failure) so you could send your customer to the hosted payment page. Did you complete the payment there?

distant cloud
#

no not completed payment there but still here the plan got changed

tiny beacon
#

Yes, because you didn't pass payment_behavior: 'pending_if_incomplete' so we apply the update regardless of whether the payment fails

distant cloud
#

when set pending_if_incomplete the invoice.payment_failed event is called

tiny beacon
#

Yep, that's how it works unfortunately. There's no way around that

distant cloud
#

but i have written some other code on payment fail then this will occur the conflict

because in plan update we will be reading the webhook call

or there is another way other than webhook call

tiny beacon
#

Then I guess you need to add some logic to your webhook handler to ignore those specific events that are triggered by a pending update

distant cloud
#

can you give me any suggestion.

carmine juncoBOT
distant cloud
#

any solution

frail aurora
#

👋 taking over for my colleague. Let me catch up.

distant cloud
#

ook

frail aurora
#

sorry for the delay

#

would you mind summarizing the question please?

distant cloud
#

`subscription = subscription.modify(
subscription_id,
proration_behavior='always_invoice',
items=[subscription_item],
payment_behavior='pending_if_incomplete'
# billing_cycle_anchor="now",
# collection_method='send_invoice',
# days_until_due=0,
)

    subscription = stripe.Subscription.retrieve(subscription_id)

    invoice = stripe.Invoice.retrieve(subscription.latest_invoice, expand=['payment_intent'])

    invoice_url = invoice.hosted_invoice_url


    return redirect(invoice_url)`

I am updating my subscription plan like this but before the user is redirected to the hosted invoice url the invoice.payment_failed event is called

frail aurora
#

I think @tiny beacon already answered this in the above messages

#

what is yet to be answered for you?

distant cloud
#

I am updating my subscription plan like this but before the user is redirected to the hosted invoice url the invoice.payment_failed event is called

can there be any other way that the invoice.payment_failed event should bot be called

frail aurora
#

already @tiny beacon answered that question

frail aurora
distant cloud
frail aurora
#

a suggestion for what exactly

#

I'm really not following

frail aurora
#

basically what @tiny beacon was trying to tell you is that when you get a subscription.updated event, if the Subscription's status is incomplete you ignore the event

distant cloud
#

but there can be a possibility that when a user update a plan and do a card payment and the transaction fails at that time also both events would be called

customer.subscription.updated
invoice.payment_failed

carmine juncoBOT
simple epoch
#

Hey! Taking over for my colleague. Let me catch up.

#

but there can be a possibility that when a user update a plan and do a card payment and the transaction fails at that time also both events would be called
Each action will trigger a corresponding event, the update Subscription action will trigger customer.subscription.updated and when the payment attempt is failed, the event invoice.payment_failed is triggered.

distant cloud
simple epoch
#

Yes that's because their was a payment attempt just after the update of the subscription. You can't change that. I think you have already got answered about this part. You need to add some logic to filter some events

distant cloud
#

but what logic

I'm am unable to get it

#

or can u suggest any other way for the plan update

simple epoch
#

The logic is to ignore invoice.payment_failed when you don't want to handle it, you need to develop some kind of logic to skip some events according to your need.

distant cloud
simple epoch
#

You judged an event to be skipped, you need to implement that logic of judging the event and skip it in your code.

distant cloud
#

ook

#

i have another dought

can there be any way to alow user to update the card details

simple epoch
#

can there be any way to alow user to update the card details
yes you can use Customer portal for this

distant cloud
#

not want to user the Customer portal

other option than this

simple epoch
#

you can use SetupIntent

distant cloud
#

will it open a stripe portal for the update?

simple epoch
#

This not using Customer portal. please follow/read the full guide and understand it.

distant cloud
#

unable to understand