Tuesday, 15 September 2020

How to Cancel Subscription created thought Checkout Session Stripe API

I have created a recurring product on stripe, and creating a checkout session and it's working fine and creating a subscription for me that i can see on the dashboard.

this is my code

        checkout_session = stripe.checkout.Session.create(
            success_url=domain_url + 'success?session_id={CHECKOUT_SESSION_ID}',
            cancel_url=domain_url + 'cancelled/',
            payment_method_types=['card'],
            mode='subscription',
            line_items=[
                {
                    'quantity': 1,
                    'price': 'price_1HLDRqCHEV6ur4mXq36yVF1D',
                }
            ]
        )

I want to provide a facility to user that they can cancle their subscription that they have made through checkout session, but it can be cancelled through subscription id only, but i am not getting any subscription id from the checkout session.

How can i allow the user to cancle their subscription that they made through checkout session ?



from How to Cancel Subscription created thought Checkout Session Stripe API

No comments:

Post a Comment