Paypal working and a few minor fixes
This commit is contained in:
@@ -237,7 +237,7 @@ class ApplicationController < LinguaFrancaApplicationController
|
||||
session[:confirm_uid] = user.id
|
||||
|
||||
# send the confirmation email and make sure it get sent as quickly as possible
|
||||
UserMailer.send_mail! :email_confirmation do
|
||||
UserMailer.send_mail :email_confirmation do
|
||||
EmailConfirmation.create(user_id: user.id, expiry: expiry, url: url)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -545,6 +545,44 @@ class ConferencesController < ApplicationController
|
||||
if form_step
|
||||
if form_step.to_s =~ /^prev_(.+)$/
|
||||
@register_template = steps[steps.find_index($1.to_sym) - 1]
|
||||
elsif form_step == :paypal_confirm
|
||||
if @registration.present? && @registration.payment_confirmation_token == params[:confirmation_token]
|
||||
|
||||
# if ENV['RAILS_ENV'] == 'test'
|
||||
# @amount = YAML.load(@registration.payment_info)[:amount]
|
||||
# else
|
||||
@amount = PayPal!.details(params[:token]).amount.total
|
||||
# testing this does't work in test but it works in devo and prod
|
||||
@registration.payment_info = {:payer_id => params[:PayerID], :token => params[:token], :amount => @amount}.to_yaml
|
||||
# end
|
||||
|
||||
@amount = (@amount * 100).to_i.to_s.gsub(/^(.*)(\d\d)$/, '\1.\2')
|
||||
|
||||
@registration.save!
|
||||
@register_template = :paypal_confirm
|
||||
end
|
||||
@register_template = :paypal_confirm
|
||||
elsif form_step == :paypal_confirmed
|
||||
#@register_template = :paypal_confirm
|
||||
info = YAML.load(@registration.payment_info)
|
||||
@amount = nil
|
||||
status = nil
|
||||
if ENV['RAILS_ENV'] == 'test'
|
||||
status = info[:status]
|
||||
@amount = info[:amount]
|
||||
else
|
||||
paypal = PayPal!.checkout!(info[:token], info[:payer_id], PayPalRequest(info[:amount]))
|
||||
status = paypal.payment_info.first.payment_status
|
||||
@amount = paypal.payment_info.first.amount.total
|
||||
end
|
||||
if status == 'Completed'
|
||||
@registration.registration_fees_paid ||= 0
|
||||
@registration.registration_fees_paid += @amount
|
||||
@registration.save!
|
||||
else
|
||||
@errors = :incomplete
|
||||
@register_template = :payment
|
||||
end
|
||||
else
|
||||
|
||||
case form_step
|
||||
@@ -607,13 +645,15 @@ class ConferencesController < ApplicationController
|
||||
|
||||
if amount > 0
|
||||
@registration.payment_confirmation_token = ENV['RAILS_ENV'] == 'test' ? 'token' : Digest::SHA256.hexdigest(rand(Time.now.to_f * 1000000).to_i.to_s)
|
||||
# @registration.save
|
||||
@registration.save
|
||||
|
||||
host = "#{request.protocol}#{request.host_with_port}"
|
||||
response = PayPal!.setup(
|
||||
PayPalRequest(amount),
|
||||
register_paypal_confirm_url(@this_conference.slug, :paypal_confirm, @registration.payment_confirmation_token),
|
||||
register_paypal_confirm_url(@this_conference.slug, :paypal_cancel, @registration.payment_confirmation_token)
|
||||
register_paypal_confirm_url(@this_conference.slug, :paypal_cancel, @registration.payment_confirmation_token),
|
||||
noshipping: true,
|
||||
version: 204
|
||||
)
|
||||
if ENV['RAILS_ENV'] != 'test'
|
||||
redirect_to response.redirect_uri
|
||||
@@ -651,7 +691,7 @@ class ConferencesController < ApplicationController
|
||||
|
||||
@register_template ||= (params[:step] || current_step).to_sym
|
||||
|
||||
if logged_in?
|
||||
if logged_in? && @register_template != :paypal_confirm
|
||||
# if we're logged in
|
||||
if !steps.include?(@register_template)
|
||||
# and we are not viewing a valid step
|
||||
|
||||
@@ -5,6 +5,6 @@
|
||||
%h2.primary=location(@conference.organizations.first.locations.first)
|
||||
.secondary
|
||||
= date_span(@conference.start_date.to_date, @conference.end_date.to_date)
|
||||
%img{src: @conference.poster.full.url || image_path('default_poster.jpg'), role: :presentation, alt: ''}
|
||||
%img{src: @conference.poster.full.url || image_path('default_poster.jpg'), role: :presentation, alt: (_'images.conference.poster', vars: { conference_title: @conference.title })}
|
||||
- content_for :og_image do
|
||||
= @conference.poster.full.url || image_path('default_poster.jpg')
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
= columns(medium: 12) do
|
||||
%h2=_'articles.conference_registration.headings.Payment'
|
||||
%p=_'articles.conference_registration.paragraphs.Payment', 'Thank you for completing your registration. We\'ll see you at Bike!Bike! Payment is by donation and can be done now or upon arrival but to help us fund the conference, we ask that you pay the registration donation as soon as you can.'
|
||||
- if @registration.registration_fees_paid.present?
|
||||
%p
|
||||
%strong=_'articles.conference_registration.paragraphs.Payment_Made', :p, vars: { fees_paid: @registration.registration_fees_paid }
|
||||
= _'articles.conference_registration.paragraphs.Payment_Add'
|
||||
- else
|
||||
%p=_'articles.conference_registration.paragraphs.Payment', :p
|
||||
= columns(large: 9, push: 1) do
|
||||
= form_tag register_path(@this_conference.slug), :class => :payment do
|
||||
= hidden_field_tag :button, :payment
|
||||
|
||||
Reference in New Issue
Block a user