Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: add missing callbacks #231

Merged

Conversation

4nd2in
Copy link
Contributor

@4nd2in 4nd2in commented Jul 14, 2024

  • Add the following callbacks:
    • checkout.session.async_payment_failed
    • checkout.session.async_payment_succeeded
    • customer.subscription.paused
    • customer.subscription.pending_update_applied
    • customer.subscription.pending_update_expired
    • customer.subscription.resumed
    • invoice.deleted
    • invoice.finalization_failed
    • invoice.overdue
    • invoice.will_be_due
  • Fix request handling in rack versions >= 3.1 where Request#[] is deprecated (undefined method `[]' for an instance of ActionDispatch::Request #230)

@4nd2in 4nd2in changed the title Feature: add missing webhook callbacks Feature: add missing callbacks Jul 14, 2024
@light-flight
Copy link
Contributor

Great job! Waiting for your fix to be merged

Copy link
Owner

@tansengming tansengming left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the PR! Once you remove the change to def retrieve_stripe_event(request) this looks good to go.

@@ -8,7 +8,7 @@ def dispatch_stripe_event(request)
end

def retrieve_stripe_event(request)
id = request['id']
id = request.params[:id]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @4nd2in can you split this change to it's own PR please? We might have to figure out a way to deal with this for rack versions that still use the old way.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, let me help.
stripe-rails supports rails '>= 5.1'
https://github.com/tansengming/stripe-rails/blob/master/stripe-rails.gemspec#L17

So rails 5.1.7 requires rack '~> 2.0'
https://github.com/rails/rails/blob/5-1-stable/actionpack/actionpack.gemspec#L29

I installed rack 2.0.1 locally. Created simple app:

# config.ru

app = Proc.new do |env|
  request = Rack::Request.new(env)
  [200, {}, [request.params['id']]]
end

run app

Run puma
http://localhost:9292/?id=12
gives me correct result.

Note that using a symbol for id does not work in this example!

So older versions of rack support request.params['id']. We do not need to do anything.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created separate PR
#232

@tansengming
Copy link
Owner

callbacks verified on https://docs.stripe.com/api/events/types

Copy link
Owner

@tansengming tansengming left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good thanks for the help @4nd2in !

@tansengming tansengming merged commit fb05080 into tansengming:master Aug 9, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants