sja*_*sja 4 ruby-on-rails webhooks stripe-payments
我正在设置Stripe的webhook.基本上是因为它是一个订阅模式,我需要知道我是否会继续更新月份.我想通过'invoice.payment_succeeded'活动来做到这一点.
当我用条纹测试我的webhook网址时,我得到了这个:
host localhost:3000 resolves to illegal IP 127.0.0.1
Run Code Online (Sandbox Code Playgroud)
我的完整终点是:
localhost:3000/hooks/receiver
Run Code Online (Sandbox Code Playgroud)
路线:
get 'hooks/receiver' => "hooks#receiver"
Run Code Online (Sandbox Code Playgroud)
钩子控制器看起来像这样:
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
Run Code Online (Sandbox Code Playgroud)
有人知道如何解决这个问题吗?
您不能在Stripe中使用127.0.0.1或localhost作为webhook.webhook涉及Stripe从其服务向您发送数据,但Stripe无法使用您的127.0.0.1,因为只有您可以访问localhost.
| 归档时间: |
|
| 查看次数: |
1455 次 |
| 最近记录: |