我试图通过条纹为教师设置付款流程,我称之为Mentor。
该过程包括将学生添加卡片详细信息后重定向到页面拾取,以便他们能够下载内容。出于某种原因,它说有一个密钥[:quid]缺失。
这是我的交易控制器:
class TransactionsController < ApplicationController
def create
mentor = Mentor.find_by!(slug: params[:slug])
token = params[:stripeToken]
begin
charge = Stripe::Charge.create(
:card => token,
:amount => (mentor.price * 100).floor,
:description => current_user.email,
:currency => 'gbp'
)
@sale = mentor.sales.create(email_user: current_user.email)
redirect_to pickup_url(guid: @sale.guid)
rescue Stripe::CardError => e
@error = e
redirect_to mentor_path(mentor), notice: @error
end
end
def pickup
@sale = Sale.find_by!(guid: params[:guid])
@mentor = @sale.mentor
end
端
这是sale.rb:
class Sale < ActiveRecord::Base
before_create :generate_guid
belongs_to :mentor
private
def generate_guid
self.guid = SecureRandom.uuid()
end
end
这是错误摘要:
答案 0 :(得分:0)
@sale = mentor.sales.create(email_user: current_user.email)
redirect_to pickup_url(quid: @sale.guid)