【问题标题】:Stripe 503 error - illegal IP 127.0.0.1 webhook problemsStripe 503 错误 - 非法 IP 127.0.0.1 webhook 问题
【发布时间】:2015-03-09 21:47:24
【问题描述】:

我正在从 Stripe 设置一个 webhook。本质上是因为它是一种订阅模式,我需要知道我是否会继续更新这个月。我想通过事件“invoice.payment_succeeded”来做到这一点。

当我在条纹中测试我的 webhook url 时,我得到了这个:

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

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

【问题讨论】:

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


    【解决方案1】:

    您不能在 Stripe 中使用 127.0.0.1 或 localhost 作为 webhook。 Webhook 涉及 Stripe 将数据从他们的服务发送到您的服务,但您的 127.0.0.1 对 Stripe 不可用,因为只有您可以访问 localhost。

    【讨论】:

      【解决方案2】:

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

      【讨论】:

        猜你喜欢
        • 2017-06-08
        • 2019-08-13
        • 2021-11-28
        • 2020-08-03
        • 2020-01-08
        • 2020-10-14
        • 1970-01-01
        • 2016-03-09
        • 2021-04-03
        相关资源
        最近更新 更多