diff --git a/app/assets/images/OSEM_ICON.jpg b/app/assets/images/OSEM_ICON.jpg deleted file mode 100644 index 6a52c3b0..00000000 Binary files a/app/assets/images/OSEM_ICON.jpg and /dev/null differ diff --git a/app/controllers/payments_controller.rb b/app/controllers/payments_controller.rb index 121e0c4b..d637f1f5 100644 --- a/app/controllers/payments_controller.rb +++ b/app/controllers/payments_controller.rb @@ -21,8 +21,8 @@ class PaymentsController < ApplicationController if @payment.purchase && @payment.save update_purchased_ticket_purchases - redirect_to conference_conference_registration_path(@conference.short_title), flash: - { success: 'Thanks! You have purchased your tickets successfully.' } + redirect_to conference_conference_registration_path(@conference.short_title), + notice: 'Thanks! You have purchased your tickets successfully.' else @total_amount_to_pay = Ticket.total_price(@conference, current_user, paid: false) @unpaid_ticket_purchases = current_user.ticket_purchases.unpaid.by_conference(@conference) diff --git a/app/controllers/ticket_purchases_controller.rb b/app/controllers/ticket_purchases_controller.rb index 43f6d09a..4a334a08 100644 --- a/app/controllers/ticket_purchases_controller.rb +++ b/app/controllers/ticket_purchases_controller.rb @@ -8,9 +8,11 @@ class TicketPurchasesController < ApplicationController message = TicketPurchase.purchase(@conference, current_user, params[:tickets][0]) if message.blank? if current_user.ticket_purchases.by_conference(@conference).unpaid.any? - redirect_to new_conference_payment_path, notice: 'Please pay here to purchase tickets.' + redirect_to new_conference_payment_path, + notice: 'Please pay here to purchase tickets.' else - redirect_to conference_conference_registration_path(@conference.short_title) + redirect_to conference_tickets_path(@conference.short_title), + error: 'Please purchase atleast one ticket to continue.' end else redirect_to conference_conference_registration_path(@conference.short_title), diff --git a/app/models/ability.rb b/app/models/ability.rb index 74b1e47d..d986c1b0 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -81,7 +81,7 @@ class Ability can :index, Ticket can :manage, TicketPurchase, user_id: user.id - can [:new], Payment, user_id: user.id + can [:new, :create], Payment, user_id: user.id can [:create, :destroy], Subscription, user_id: user.id diff --git a/app/views/conference_registrations/show.html.haml b/app/views/conference_registrations/show.html.haml index 24923d07..9debda28 100644 --- a/app/views/conference_registrations/show.html.haml +++ b/app/views/conference_registrations/show.html.haml @@ -109,7 +109,7 @@ You haven't bought any tickets. = link_to 'Please buy some tickets to support us!', conference_tickets_path(@conference.short_title) %p - (Your registration won't be complete without buying a ticket) + (Your participation won't be valid without buying a ticket) .row .col-md-12 diff --git a/app/views/payments/_payment.html.haml b/app/views/payments/_payment.html.haml index a8de023f..953d8334 100644 --- a/app/views/payments/_payment.html.haml +++ b/app/views/payments/_payment.html.haml @@ -26,8 +26,8 @@ = humanized_money_with_symbol @total_amount_to_pay %script.stripe-button{ src: "https://checkout.stripe.com/checkout.js", data: { amount: @total_amount_to_pay.cents, + email: current_user.email, currency: @total_amount_to_pay.currency, - image: image_url('OSEM_ICON.jpg'), name: ENV['OSEM_NAME'] || 'OSEM', description: "book your tickets", key: Rails.application.secrets.stripe_publishable_key, diff --git a/app/views/tickets/index.html.haml b/app/views/tickets/index.html.haml index 8f80e1ac..f9fa9a5e 100644 --- a/app/views/tickets/index.html.haml +++ b/app/views/tickets/index.html.haml @@ -42,4 +42,4 @@ .col-md-13 %p.text-muted.text-center %small - * Buying a ticket is mandatory. Your registration will not complete until you buy a ticket. + * Buying a ticket is mandatory. Your participation will not be valid until you buy a ticket. diff --git a/config/initializers/stripe.rb b/config/initializers/stripe.rb index 22ff8359..fe10a25c 100644 --- a/config/initializers/stripe.rb +++ b/config/initializers/stripe.rb @@ -1,6 +1 @@ -Rails.configuration.stripe = { - :publishable_key => ENV['STRIPE_PUBLISHABLE_KEY'] || Rails.application.secrets.stripe_publishable_key, - :secret_key => ENV['STRIPE_SECRET_KEY'] || Rails.application.secrets.stripe_secret_key -} - -Stripe.api_key = Rails.configuration.stripe[:secret_key] +Stripe.api_key = Rails.application.secret.stripe_secret_key diff --git a/spec/models/ability_spec.rb b/spec/models/ability_spec.rb index 720aec33..df12e8b9 100644 --- a/spec/models/ability_spec.rb +++ b/spec/models/ability_spec.rb @@ -105,6 +105,9 @@ describe 'User' do it{ should be_able_to(:index, Ticket) } it{ should be_able_to(:manage, TicketPurchase.new(user_id: user.id)) } + it{ should be_able_to(:new, Payment.new(user_id: user.id)) } + it{ should be_able_to(:create, Payment.new(user_id: user.id)) } + it{ should be_able_to(:create, Subscription.new(user_id: user.id)) } it{ should be_able_to(:destroy, subscription) }