refactor payment#purchase method, improve environment variable names

This commit is contained in:
Rishabh Saxena 2016-07-21 10:15:17 +05:30
parent c4d934d711
commit f00e051eff
8 changed files with 64 additions and 39 deletions

View file

@ -4,7 +4,7 @@ class TicketPurchasesController < ApplicationController
authorize_resource :conference_registrations, class: Registration
def create
TicketPurchase.destroy_all(user_id: current_user.id, conference_id: @conference.id, paid: false)
TicketPurchase.by_conference(@conference).unpaid.by_user(current_user).destroy_all
message = TicketPurchase.purchase(@conference, current_user, params[:tickets][0])
if message.blank?
if current_user.ticket_purchases.by_conference(@conference).unpaid.any?