I'm working on setting up a webhook from Stripe. Essentially because it's a subscription model and I need to know if I shall keep on renewing the month or not. I'd like to do that through the event 'invoice.payment_succeeded'.
When I test my webhook url in stripe I get this:
host localhost:3000 resolves to illegal IP 127.0.0.1
my full endpoint is:
localhost:3000/hooks/receiver
route:
get 'hooks/receiver' => "hooks#receiver"
and the hooks controller looks like this:
class HooksController < ApplicationController
require 'json'
Stripe.api_key
def receiver
data_json = JSON.parse request.body.read
p data_json['data']['object']['customer']
if data_json[:type] == 'invoice.payment_succeded'
make_active(data_event)
end
if data_json[:type] == 'invoice.payment_failed'
# something make_inactive(data_event)
end
end
def make_active(data_event)
@user = User.find_by_customer_token(data['data']['object']['customer'])
@status = @user.statuses.pluck(:list_id).presence || -1
Resque.enqueue(ScheduleTweets, @user.token, @user.id, @status)
end
def make_inactive(data_event)
end
end
Does anybody know how to fix this?
You cannot use 127.0.0.1 or localhost as a webhook in Stripe. A webhook involves Stripe sending data from their serves to yours, but your 127.0.0.1 isn't available to Stripe since only you can access localhost.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With