improve Stripe error rescue. modify tests.
This commit is contained in:
parent
52c30af642
commit
1f9338735c
6 changed files with 43 additions and 36 deletions
|
|
@ -17,14 +17,17 @@ class PaymentsController < ApplicationController
|
|||
@unpaid_ticket_purchases = current_user.ticket_purchases.unpaid.by_conference(@conference)
|
||||
@total_amount_to_pay = Ticket.total_price(@conference, current_user, paid: false)
|
||||
|
||||
@payment = Payment.new payment_params.merge(user: current_user, conference: @conference)
|
||||
@payment.purchase
|
||||
@payment.save
|
||||
@payment = Payment.new payment_params.merge(amount: @total_amount_to_pay.cents,
|
||||
user: current_user,
|
||||
conference: @conference)
|
||||
|
||||
update_purchased_ticket_purchases
|
||||
|
||||
redirect_to conference_conference_registration_path(@conference.short_title), flash:
|
||||
{ success: 'Thanks! You have purchased your tickets successfully.' }
|
||||
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.' }
|
||||
else
|
||||
render :new
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue