Rails上带有条纹的多个计划&没有客户付款来源

时间:2017-06-21 20:24:14

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

StripeRails设置了Devise。它工作得很漂亮,但有三个错误。

首先,我想实施两个不同的计划。一旦他们使用Pay With Stripe按钮选择它,Stripe就可以让客户支付他们每月选择的计划。

第二个问题:当我进入/charges/new路径时,它的工作效果非常好,并显示了计划。但是,当我转到/charges路径时,它会给我This customer has no attached payment source的错误。

第三个问题:用户应该从/users/new转到/charges/new。这不会发生。

我如何解决所有这些错误?

这是我的charges_controller.rb

 class ChargesController < ApplicationController
      before_filter :authenticate_user!

      def new
      end

      def update
      end

      def create
           token = params[:stripeToken]

           customer = Stripe::Customer.create(
                source: token,
                plan: 2020,
                email: current_user.email,
            )

            current_user.subscribed = true
            current_user.stripeid = customer.id
            current_user.save

            redirect_to profile_path
      end
 end

这是我的routes.rb文件:

 Rails.application.routes.draw do
      devise_for :users, controllers: {registrations: "registrations"}, path_names: { sign_in: "login", sign_out: "logout", registration: "signup", sign_up: "cmon_lemme_in_guys" }
      resources :things
      resources :charges, only: [:new, :create]

      get "charges", to: "charges#create"

      authenticated :user do
           root "things#profile"
           get "profile", to: "things#profile"
       end

      root "index#welcome"
      get "license/terms"
 end

0 个答案:

没有答案