Rails / Stripe – 多笔付款
我正在使用Rails和Stripe构建一个事件应用来处理付款。 我已经在我的预订页面使用了javascript,以便允许用户预订并支付多个空格而不是一次只支付一个空格。 您可以在此处看到预订页面 –
但是,在我的Stripe仪表板上,只有一个空间付款 –
如何解决此问题,以便在预订视图中显示全额付款?
这是我的控制器和视图代码 –
bookings_controller.rb
class BookingsController @event.number_of_spaces flash[:warning] = "Sorry, this event is fully booked." raise ActiveRecord::Rollback, "event is fully booked" end end if @booking.save # CHARGE THE USER WHO'S BOOKED # #{} == puts a variable into a string Stripe::Charge.create(amount: @event.price_pennies, currency: "gbp", card: @booking.stripe_token, description: "Booking number #{@booking.id}") flash[:success] = "Your place on our event has been booked" redirect_to event_path(@event) else flash[:error] = "Payment unsuccessful" render "new" end if @event.is_free? @booking.save! flash[:success] = "Your place on our event has been booked" redirect_to event_path(@event) end end private def booking_params params.require(:booking).permit(:stripe_token, :quantity) end end
booking.new.html.erb
Confirm Your Booking
Confirm number of spaces you wish to book here:
Total Amount £<span class="total" data-unit-cost="">0
/