条带付款错误无法找到带有' id' = @ product.id的产品

时间:2017-05-31 16:49:12

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

每次我测试Stripe时都会给出错误:

Couldn't find Product with 'id'=@product.id

这是我的付款管理员:

class PaymentsController < ApplicationController
    def create
      @product = Product.find(params[:product_id])
      @user = current_user
      token = params[:stripeToken]
      # Create the charge on Stripe's servers - this will charge the user's card
      begin
        charge = Stripe::Charge.create(
          amount:  product.price, # amount in cents, again
          currency: "usd",
          source: token,
          description: params[:stripeEmail]
        )
      rescue Stripe::CardError => e
        # The card has been declined
      end
      redirect_to product_path(@product), notice: "Payment processed successfully!"
    end
end

0 个答案:

没有答案