change camel case variable to ruby style.

This commit is contained in:
Rishabh Saxena 2016-07-29 00:34:03 +05:30
parent 1f9338735c
commit 112d2c6fff
3 changed files with 23 additions and 24 deletions

View file

@ -14,10 +14,11 @@ class PaymentsController < ApplicationController
end
def create
@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(amount: @total_amount_to_pay.cents,
@payment = Payment.new payment_params.merge(stripe_customer_email: params[:stripeEmail],
stripe_customer_token: params[:stripeToken],
amount: @total_amount_to_pay.cents,
user: current_user,
conference: @conference)
@ -26,6 +27,7 @@ class PaymentsController < ApplicationController
redirect_to conference_conference_registration_path(@conference.short_title), flash:
{ success: 'Thanks! You have purchased your tickets successfully.' }
else
@unpaid_ticket_purchases = current_user.ticket_purchases.unpaid.by_conference(@conference)
render :new
end
end
@ -33,7 +35,7 @@ class PaymentsController < ApplicationController
private
def payment_params
params.permit :stripeEmail, :stripeToken
params.permit :stripe_customer_email, :stripe_customer_token
end
def update_purchased_ticket_purchases

View file

@ -3,8 +3,8 @@ class Payment < ActiveRecord::Base
belongs_to :user
belongs_to :conference
attr_accessor :stripeEmail
attr_accessor :stripeToken
attr_accessor :stripe_customer_email
attr_accessor :stripe_customer_token
validates :status, presence: true
validates :amount, presence: true, numericality: { greater_than: 0 }
@ -22,26 +22,24 @@ class Payment < ActiveRecord::Base
end
def purchase
begin
customer = Stripe::Customer.create email: stripeEmail,
source: stripeToken,
description: user.name
customer = Stripe::Customer.create email: stripe_customer_email,
source: stripe_customer_token,
description: user.name
gateway_response = Stripe::Charge.create customer: customer.id,
receipt_email: stripeEmail,
description: 'ticket purchases',
amount: amount_to_pay,
currency: conference.tickets.first.price_currency
gateway_response = Stripe::Charge.create customer: customer.id,
receipt_email: stripe_customer_email,
description: 'ticket purchases',
amount: amount_to_pay,
currency: conference.tickets.first.price_currency
self.last4 = gateway_response[:source][:last4]
self.authorization_code = gateway_response[:id]
self.status = 'success'
true
self.last4 = gateway_response[:source][:last4]
self.authorization_code = gateway_response[:id]
self.status = 'success'
true
rescue => error
errors.add(:base, error.message)
self.status = 'failure'
false
end
rescue => error
errors.add(:base, error.message)
self.status = 'failure'
false
end
end

View file

@ -1,5 +1,4 @@
.div
.col-md-12.table-responsive
%table.table.table-hover
%thead