#Rohit89
1 messages · Page 1 of 1 (latest)
Yes, customer.subscription.updated events are fired in such a scenario. Documented here:
https://stripe.com/docs/customer-management/integrate-customer-portal#webhooks
`# frozen_string_literal: true
module Webhooks
class StripeController < ApplicationController
skip_before_action :verify_authenticity_token
skip_before_action :authenticate_user!
def initialize
super
@endpoint_secret = ENV["STRIPE_SIGNING_SECRET"]
end
def webhook
payload = request.body.read
sig_header = request.env["HTTP_STRIPE_SIGNATURE"]
begin
event = ::Stripe::Webhook.construct_event(
payload, sig_header, @endpoint_secret
)
rescue JSON::ParserError => e
# Invalid payload
Bugsnag.notify "Invalid payload received on Stripe Webhook", info: { error: e }
return head 400
rescue Stripe::SignatureVerificationError => e
# Invalid signature
# for QA and development envs, this is most likely because the event was meant for different environment
# we'll acknowledge this request to prevent it from being repeated by Stripe
return head 204 unless Rails.env.production?
Bugsnag.notify "Invalid payload signature received on Stripe Webhook", info: { error: e }
return head 400
end
stripe_object = event.data.object
# Handle the event
case event.type
when "charge.succeeded"
when "customer.subscription.created", "customer.subscription.updated"
end
if event.type == "customer.subscription.updated"
redirect_to root_path, status: 200
else
head 200
end
end
end
end`
if event.type == "customer.subscription.updated"
redirect_to root_path, status: 200
else
head 200
end
added this way, but not working
it remain on portal
I am on billing portal which open from my website. When I update a plan, it should redirect to root path of my app
but user remains on billing portal
The only redirect option is for "return to X" which you can configure:
https://stripe.com/docs/customer-management/configure-portal#customize-the-portal
There no redirect immediately after update function available
i see