#Yashish
1 messages · Page 1 of 1 (latest)
👋 happy to help
unfortunately that's not possible
you can use the Customer Billing Portal instead
for updating user's subscription can we implement any success url for accepting the payment for the subscription update if the payment is successful then user is redirected again to my website.
i do not want to use customer portal
I'm afraid nothing has changed since the last time I answered your question @minor fractal
but unable to find the solution which i can implement
or the numerous threads where my colleagues have answered the same question over and over again
I'm pretty sure that not changing the input would not change the output
it's very deterministic
we gave you several options, all you have to do now is to choose one and implement it
but non of them are working as i want
sorry I'm being very firm and strict but we can't spend weeks and weeks dealing with the same question over and over again
then unfortunately we don't actually have a solution that could work for you
just once can you tell me that it can be possible or not
i can explain the situation
?
When a user wants to update their subscription, they will be redirected to a Stripe page. If the payment for the subscription is successful, the user's subscription will be updated and they will be redirected back to my website. However, if the payment fails, no action will be taken and the subscription will not be updated. It is important to ensure that the subscription is not updated until the payment process is successfully completed. Once the payment is done, the user will be redirected back to my website.
When a user wants to update their subscription, they will be redirected to a Stripe page.
this is not possible
unless it's the Customer Billing Portal
once we agree on this, we can move to finding another solution for you
while creating the subscription we are using
stripe_session = stripe.checkout.Session.create( success_url=domain + '/payments/stripe-success?session_id={CHECKOUT_SESSION_ID}', cancel_url=domain + '/payments/stripe-failed/', mode='subscription', line_items=[{ 'price': plan.id, 'quantity': 1, }], # customer_email=user_id.email, customer_email='nm_mon@gmail.com', metadata={'user_id': (request.user).id, 'plan_id': subscription_plan.id, 'plan_name': subscription_plan.plan_name }, ) return redirect(stripe_session.url)
in this user is redirected back to the my website
this works for creating a subscription
it doesn't work for updating an exsiting one
it means there is no solution regarding it
not the way you are expecting it to work
there are workarounds and stuff that you can develop yourself to make it work, but you're determined to use Checkout when in fact Checkout does not support your use case
aI do not want to use checkout I want to implement the similar functionality like success url for updating subscription payments
you're going about this in the wrong way
you're defining the behavior that you're expecting
instead of defining what is your use case and seeing what is possible to do
you're limiting yourself by putting unnecessary constraints
ok then can you guide me in implementing the functionality or the path
the only way to have your customer confirm the payment for the subscription upgrade before updating the subscription is by using the upcoming invoice API
you can start by calculating what amount should your customer pay https://stripe.com/docs/billing/invoices/subscription#previewing
I have been using this
`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
# return redirect(invoice_url)`
but in this after payment user is not redirected to my website
this is called the Hosted Invoice Page
this page doesn't allow redirection
then should i try this?
also this approach updates the subscription
before the payment
which is not what you're trying to do
it is actually
payment_behavior='pending_if_incomplete'
subscription = subscription.modify(
subscription_id,
proration_behavior='always_invoice',
items=[subscription_item],
payment_behavior='pending_if_incomplete',
)
this modifies the subscription
yes it will put it in a pending state if there's no payment method
but it is not updated
but that doesn't mean the subscription can be reverted back as if the change didn't happen
it depends on what you mean by "not updated"
yes there is no change in the stripe regarding that
if from the redirected url user does not do any payment
just a quick question, why do you need the redirection?
in my implementation my TL wants it to perform like that for user convience so that user not need to manually go back to my website
the only way to have the redirection then is to use Payment Element on your website
and pay the invoice.payment_intent
unable to understand properly can you explain more briefly
each invoice has a Payment Intent.
you can use its client_secret with this approach https://stripe.com/docs/payments/accept-a-payment?platform=web&ui=elements
how we can verify that the payment is for the specific subscription and user
through metadata?
the PaymentIntent is linked to the Invoice which is linked to the subscription
and all are linked to the customer
,need to create a different payment intent or from this invoice json want to extract it
The Payment Intent will be on the latest_invoice. Pass the expand param to your .modify call
from the payment intent what to do?
sorry i am unable to understand the whole process
do i need to do coding in js?
Yes you need front-end JS code to confirm the payment and allow the customer to complete auth if requested