【问题标题】:Payola Gem, getting No route matches [GET] "/payola/events"Payola Gem,没有路线匹配 [GET] "/payola/events"
【发布时间】:2017-02-21 23:19:52
【问题描述】:

我在 Rails 5.0.1 中使用 Payola-payments 1.5.1,当我尝试在 Stripe 测试模式帐户上付款时遇到以下错误: 没有路线匹配 [GET] "/payola/events" Payola 有一条到“/payola/events”的路由,该路由通向 Webhooks 控制器,但它只响应 Post 方法。这是来自 Transaction Controller 的重定向,传递的参数是 {"action"=>"new", "controller"=>"users/sessions"}

Payola 以前在我的电脑上运行良好。我能想到的唯一变化是一些 gem 更新,包括切换到 5.0.1。

以前有人遇到过这种情况吗?任何帮助将不胜感激。

【问题讨论】:

    标签: ruby-on-rails payola


    【解决方案1】:

    覆盖 Payola Engine 给出的默认路由。我像这样设置我的路线。它适用于 Rails 5.2。

      scope module: 'payola' do
        mount StripeEvent::Engine => 'payola/events', as: :payola
        post 'payola/buy/:product_class/:permalink' => 'transactions#create', as: :buy
        get 'payola/confirm/:guid' => 'transactions#show', as: :confirm
        get 'payola/status/:guid' => 'transactions#status', as: :status
        post 'payola/subscribe/:plan_class/:plan_id' => 'subscriptions#create', as: :subscribe
        get 'payola/confirm_subscription/:guid' => 'subscriptions#show', as: :confirm_subscription
        get 'payola/subscription_status/:guid' => 'subscriptions#status', as: :subscription_status
        delete 'payola/cancel_subscription/:guid' => 'subscriptions#destroy', as: :cancel_subscription
        post 'payola/change_plan/:guid' => 'subscriptions#change_plan', as: :change_subscription_plan
        post 'payola/change_quantity/:guid' => 'subscriptions#change_quantity', as: :change_subscription_quantity
        post 'payola/update_card/:guid' => 'subscriptions#update_card', as: :update_card
        post 'payola/update_customer/:id' => 'customers#update', as: :update_customer
        post 'payola/create_card/:customer_id' => 'cards#create', as: :create_card
        delete 'payola/destroy_card/:id/:customer_id' => 'cards#destroy', as: :destroy_card
      end
    

    最后,禁用 disable_with,我相信 Rails 5.0+ 默认启用该功能。它将停止 Payola 用于处理付款的 JS 表单代码。

    <%= f.submit "Submit" data: {disable_with: false} %>
    

    【讨论】:

    • 这看起来是个好方法。我现在无法真正验证它是否适用于我的情况,因为我在发布此问题几个月后停止使用 Payola。它非常适合 B2C 使用,但我在 B2B 工作,那里的销售会大量发生,2 因素确认变得有问题,否则它不适合 Payola。不过谢谢! :)
    猜你喜欢
    • 2016-11-27
    • 1970-01-01
    • 2016-06-15
    • 2011-12-11
    • 2015-09-27
    • 2015-10-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多