#Yashish

1 messages · Page 1 of 1 (latest)

marble matrixBOT
queen shadow
#

👋 happy to help

#

unfortunately that's not possible

#

you can use the Customer Billing Portal instead

minor fractal
#

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.

minor fractal
queen shadow
#

I'm afraid nothing has changed since the last time I answered your question @minor fractal

minor fractal
#

but unable to find the solution which i can implement

queen shadow
#

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

minor fractal
#

but non of them are working as i want

queen shadow
#

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

queen shadow
minor fractal
#

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.

queen shadow
#

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

minor fractal
#

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

queen shadow
#

this works for creating a subscription

#

it doesn't work for updating an exsiting one

minor fractal
#

it means there is no solution regarding it

queen shadow
#

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

minor fractal
#

aI do not want to use checkout I want to implement the similar functionality like success url for updating subscription payments

queen shadow
#

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

minor fractal
#

ok then can you guide me in implementing the functionality or the path

queen shadow
#

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

minor fractal
#

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

queen shadow
#

this is called the Hosted Invoice Page

marble matrixBOT
queen shadow
#

this page doesn't allow redirection

queen shadow
#

also this approach updates the subscription

#

before the payment

#

which is not what you're trying to do

minor fractal
#

but the subscription is not changed

#

i had tried this

queen shadow
#

it is actually

minor fractal
#

payment_behavior='pending_if_incomplete'

queen shadow
#

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

minor fractal
#

but it is not updated

queen shadow
#

but that doesn't mean the subscription can be reverted back as if the change didn't happen

queen shadow
minor fractal
#

yes there is no change in the stripe regarding that
if from the redirected url user does not do any payment

queen shadow
#

just a quick question, why do you need the redirection?

minor fractal
#

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

queen shadow
#

the only way to have the redirection then is to use Payment Element on your website

#

and pay the invoice.payment_intent

minor fractal
#

unable to understand properly can you explain more briefly

queen shadow
#

each invoice has a Payment Intent.

minor fractal
#

how we can verify that the payment is for the specific subscription and user

through metadata?

queen shadow
#

the PaymentIntent is linked to the Invoice which is linked to the subscription

#

and all are linked to the customer

minor fractal
silent stone
#

The Payment Intent will be on the latest_invoice. Pass the expand param to your .modify call

minor fractal
#

from the payment intent what to do?

minor fractal
#

sorry i am unable to understand the whole process

do i need to do coding in js?

silent stone
#

Yes you need front-end JS code to confirm the payment and allow the customer to complete auth if requested