#Yashish
1 messages · Page 1 of 1 (latest)
hello! there's no way to pass a success and fail url for a hosted invoice
then how we can know whether the payment was successful or not
you can listen for the invoice.paid webhook event
you might want to go through this guide : https://stripe.com/docs/billing/subscriptions/webhooks#events
can there be any condition that we can keep not allow user with Overdue payments
i'm sorry, but i don't understand, can you try rephrasing?
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
okay, what's the behaviour you expect to happen instead?
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
then in your Billing settings : https://dashboard.stripe.com/settings/billing/automatic, you'll want to update/ set what happens to the Subscription / Invoice if the payment fails
can there be any way to manage this through code?
No this settings is Dashboard only
here i have done the setting like
then on the fail transaction it should cancel the plan but this is not happening
subscription ID?
sub_1N5k6PSGNnwNJbGS2VSok7aK
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?
i want it to stop on the spot
instead of any retry
Then you can listen to invoice.payment_failed event and manually cancel the subscription
invoice.payment_failed is is not getting called
https://dashboard.stripe.com/test/events/evt_1N5k9ASGNnwNJbGS7pxhFGbh this is the event , and it's successfully delivered to your webhook endpoint.
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
it is called when we modify the plan
before it is redirected to the hosted invoice url
I don't understand what's the problem here, I can see there's a invoice.payment_failed in the screenshot that you shared.
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
the webhook events are not guaranteed to be arrived in sequence.
@distant cloud what is 'not solved'?
.
What's being called before 'payment is done'? You need to be verbose when you're describing the issue
invoice.payment_failed
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?
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
I think you could pass payment_behavior: 'default_incomplete' in your modify call which will prevent automatic payment attempt: https://stripe.com/docs/api/subscriptions/update#update_subscription-payment_behavior
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
now the payment status is being change to
still the payment is not done the plan got change and move to overdue
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?
no not completed payment there but still here the plan got changed
Yes, because you didn't pass payment_behavior: 'pending_if_incomplete' so we apply the update regardless of whether the payment fails
when set pending_if_incomplete the invoice.payment_failed event is called
Yep, that's how it works unfortunately. There's no way around that
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
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
can you give me any suggestion.
any solution
👋 taking over for my colleague. Let me catch up.
ook
`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
I think @tiny beacon already answered this in the above messages
what is yet to be answered for you?
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
already @tiny beacon answered that question
please refer to this conversation
.
for this
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
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
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
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 triggercustomer.subscription.updatedand when the payment attempt is failed, the eventinvoice.payment_failedis triggered.
what about this
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
but what logic
I'm am unable to get it
or can u suggest any other way for the plan update
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.
but unable to get the logic you can see this example both the time both events would be triggered
You judged an event to be skipped, you need to implement that logic of judging the event and skip it in your code.
ook
i have another dought
can there be any way to alow user to update the card details
can there be any way to alow user to update the card details
yes you can use Customer portal for this
not want to user the Customer portal
other option than this
will it open a stripe portal for the update?
This not using Customer portal. please follow/read the full guide and understand it.
unable to understand