条带503错误 - 非法IP 127.0.0.1 webhook问题

时间:2015-01-12 06:49:43

标签: ruby-on-rails stripe-payments webhooks

我正在设置Stripe的webhook。基本上是因为它是一个订阅模式,我需要知道我是否会继续更新月份。我想通过'invoice.payment_succeeded'活动来做到这一点。

当我测试我的webhook网址时,我得到了这个:

host localhost:3000 resolves to illegal IP 127.0.0.1

我的完整终点是:

localhost:3000/hooks/receiver

路线:

get 'hooks/receiver' => "hooks#receiver"

并且钩子控制器看起来像这样:

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

有人知道如何解决这个问题吗?

2 个答案:

答案 0 :(得分:7)

您可以使用ngrok之类的东西打开本地主机到互联网 https://ngrok.com/

答案 1 :(得分:6)

您不能在Stripe中使用127.0.0.1或localhost作为webhook。 webhook涉及Stripe从其服务向您发送数据,但您的127.0.0.1不可用于Stripe,因为只有您可以访问localhost。