Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Payment Detail Page with Admin #15 #234

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions app/controllers/admin/campaigns_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,17 @@ def update
end
end

def edit_payment
if ( @campaign.nil? )
@campaign = Campaign.find(params[:id])
end
if ( @payment.nil? )
@payment = Payment.find_by_ct_payment_id(params[:payment_id].strip)
end
create_breadcrumb(['Edit Payment', admin_payment_path(@payment,@campaign)])

end

def payments
# @campaign = Campaign.find(params[:id])
# page = params[:page] || 1
Expand Down
15 changes: 13 additions & 2 deletions app/controllers/admin/payments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,19 @@ class Admin::PaymentsController < ApplicationController
layout "admin"
before_filter :authenticate_user!
before_filter :verify_admin



def update_payment
#redirect_to admin_payment_url(@payment,@campaign), :flash => { :notice => "Payment Updated!" }
@payment_new = Payment.create(params[:payment])
@payment = Payment.find_by_ct_payment_id(params[:payment_id].strip)
@payment.email = @payment_new.email
@payment.fullname = @payment_new.fullname
if( @payment.save )
redirect_to admin_campaigns_payments_path(params[:id]), :flash => { :notice => "Payment Modified Successfully!"}
end
end

def refund_payment
payment = Payment.where(:ct_payment_id => params[:id]).first
if not payment
Expand All @@ -17,5 +29,4 @@ def refund_payment
logger.info({msg: 'Payment successfully refunded', ct_payment_id: params[:id]})
render :json => {ct_payment_id: params[:id], status: "refunded"}, :status => 200
end

end
82 changes: 82 additions & 0 deletions app/views/admin/campaigns/edit_payment.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<div id="admin">
<div class="container content_box clearfix">

<%= render 'admin/header', active: 'campaigns' %>

<div id="admin_campaigns">
<h4><%= @campaign.name %></h4>
<%= form_for [:admin, @payment], :url => admin_payment_update_path(@campaign,@payment.ct_payment_id) , html: { class: "payment_form", id: "admin_payment_form", method: "post" } do |f|%>
<fieldset>
<legend class="foldable"><a>Payer Information</a></legend>

<div class="foldable default_expanded">
<div class="field clearfix">
<p class="explanation">This is the payer full name as entered on checkout</p>
<label>Full Name</label>
<%= f.text_field :fullname %>
</div>
<div class="field clearfix">
<p class="explanation">This is the payer email address as entered on checkout</p>
<label>Email</label>
<%= f.text_field :email %>
</div>

</div>
</fieldset>



<fieldset>
<legend class="foldable"><a>Payment Details</a></legend>

<div class="foldable">
<div class="field clearfix">
<label>Status</label> <%= f.text_field :status, :disabled => true %>
<label>Amount</label> <%= f.text_field :amount, :disabled => true %>
<label>User Fee Amount</label> <%= f.text_field :user_fee_amount, :disabled => true %>
<label>Admin Fee Amount</label> <%= f.text_field :admin_fee_amount, :disabled => true %>
<label>Card Type</label> <%= f.text_field :card_type, :disabled => true %>
<label>Card Last Four</label> <%= f.text_field :card_last_four, :disabled => true %>
<label>Card Expiration Month</label> <%= f.text_field :card_expiration_month, :disabled => true %>
<label>Card Expiration Year</label> <%= f.text_field :card_expiration_year, :disabled => true %>
<label>Quantity</label> <%= f.text_field :quantity, :disabled => true %>
</div>
</div>
</fieldset>


<fieldset>
<legend class="foldable"><a>Address Details</a></legend>

<div class="foldable">
<div class="field clearfix">

<label>Address1</label> <%= f.text_field :address_one, :disabled => true %>
<label>Address2</label> <%= f.text_field :address_two, :disabled => true %>
<label>City</label> <%= f.text_field :city, :disabled => true %>
<label>State/Province/Region</label> <%= f.text_field :state, :disabled => true %>
<label>Postal Code</label> <%= f.text_field :postal_code, :disabled => true %>
<label>Billing Postal Code</label> <%= f.text_field :billing_postal_code, :disabled => true %>
<label>Country</label> <%= f.text_field :country, :disabled => true %>
</div>
</div>
</fieldset>

<fieldset>
<legend class="foldable"><a>Additional</a></legend>

<div class="foldable">
<div class="field clearfix">

<label>Additional Info</label> <%= f.text_area :additional_info, :disabled => true %>

</div>
</div>
</fieldset>
<%= f.submit "Save", :'class' => "btn btn-primary show_loader", :'data-loader' => "payment_form" %>
<span class="loader" data-loader="payment_form" style="display:none"></span>
<% end %>

</div>
</div>
</div>
2 changes: 1 addition & 1 deletion app/views/admin/campaigns/payments.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
<td class="user_fee_amount"><%= short_price(payment.user_fee_amount.to_f/100.0, '$', 2) %></td>
<td><%= payment.created_at.strftime("%m/%d/%Y") %></td>
<td class="status"><%= payment.status %></td>
<td class="ct_payment_id"><%= payment.ct_payment_id %></td>
<td class="ct_payment_id"><%= link_to payment.ct_payment_id, admin_payment_path(:payment_id => payment.ct_payment_id) %></td>
<td><% if ['authorized', 'charged'].include? payment.status %><a class="refund-payment" style="cursor: pointer">Refund</a><% end %></td>
<td style="width: 18px"><span class="loader" style="display: none"></span></td>
</tr>
Expand Down
45 changes: 24 additions & 21 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,43 @@
mount Ckeditor::Engine => '/ckeditor'

# PAGES
root to: 'pages#index'
root to: 'pages#index'

# USERS
devise_for :users, { path: 'account' }
devise_scope :user do
match '/user/settings', to: 'devise/registrations#edit', as: :user_settings
match '/user/settings', to: 'devise/registrations#edit', as: :user_settings
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why add all these spaces?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seems that those spaced are in the display here only and not in the edit mode

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably has to do with tabs vs spaces

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

weird i just checked it out nope they are all tabs and no extra in the code

end

# ADMIN
get '/admin', to: 'admin#admin_dashboard', as: :admin_dashboard
match '/admin/homepage', to: 'admin#admin_homepage', as: :admin_homepage
match '/admin/site-settings', to: 'admin#admin_site_settings', as: :admin_site_settings
match '/admin/customize', to: 'admin#admin_customize', as: :admin_customize
get '/admin', to: 'admin#admin_dashboard', as: :admin_dashboard
match '/admin/homepage', to: 'admin#admin_homepage', as: :admin_homepage
match '/admin/site-settings', to: 'admin#admin_site_settings', as: :admin_site_settings
match '/admin/customize', to: 'admin#admin_customize', as: :admin_customize
namespace :admin do
resources :campaigns
post '/payments/:id/refund', to: 'payments#refund_payment', as: :admin_payment_refund
post '/payments/:id/refund', to: 'payments#refund_payment', as: :admin_payment_refund
end

match '/admin/campaigns/:id/copy', to: 'admin/campaigns#copy', as: :admin_campaigns_copy
match '/admin/campaigns/:id/payments', to: 'admin/campaigns#payments', as: :admin_campaigns_payments
match '/admin/processor-setup', to: 'admin#admin_processor_setup', as: :admin_processor_setup
post '/admin/bank-setup', to: 'admin#create_admin_bank_account', as: :create_admin_bank_account
get '/admin/bank-setup', to: 'admin#admin_bank_account', as: :admin_bank_account
delete '/admin/bank-setup', to: 'admin#delete_admin_bank_account', as: :delete_admin_bank_account
match '/admin/notification-setup', to: 'admin#admin_notification_setup', as: :admin_notification_setup
match '/ajax/verify', to: 'admin#ajax_verify', as: :ajax_verify
match '/admin/campaigns/:id/copy', to: 'admin/campaigns#copy', as: :admin_campaigns_copy

match '/admin/campaigns/:id/payments', to: 'admin/campaigns#payments', as: :admin_campaigns_payments
post '/admin/campaigns/:id/payments/:payment_id', to: 'admin/payments#update_payment', as: :admin_payment_update
match '/admin/campaigns/:id/payments/:payment_id', to: 'admin/campaigns#edit_payment', as: :admin_payment
match '/admin/processor-setup', to: 'admin#admin_processor_setup', as: :admin_processor_setup
post '/admin/bank-setup', to: 'admin#create_admin_bank_account', as: :create_admin_bank_account
get '/admin/bank-setup', to: 'admin#admin_bank_account', as: :admin_bank_account
delete '/admin/bank-setup', to: 'admin#delete_admin_bank_account', as: :delete_admin_bank_account
match '/admin/notification-setup', to: 'admin#admin_notification_setup', as: :admin_notification_setup
match '/ajax/verify', to: 'admin#ajax_verify', as: :ajax_verify

# CAMPAIGNS
match '/:id/checkout/amount', to: 'campaigns#checkout_amount', as: :checkout_amount
match '/:id/checkout/payment', to: 'campaigns#checkout_payment', as: :checkout_payment
match '/:id/checkout/process', to: 'campaigns#checkout_process', as: :checkout_process
match '/:id/checkout/confirmation', to: 'campaigns#checkout_confirmation', as: :checkout_confirmation
post '/:id/checkout/error', to: 'campaigns#checkout_error', as: :checkout_error
match '/:id', to: 'campaigns#home', as: :campaign_home
match '/:id/checkout/amount', to: 'campaigns#checkout_amount', as: :checkout_amount
match '/:id/checkout/payment', to: 'campaigns#checkout_payment', as: :checkout_payment
match '/:id/checkout/process', to: 'campaigns#checkout_process', as: :checkout_process
match '/:id/checkout/confirmation', to: 'campaigns#checkout_confirmation', as: :checkout_confirmation
post '/:id/checkout/error', to: 'campaigns#checkout_error', as: :checkout_error
match '/:id', to: 'campaigns#home', as: :campaign_home


namespace :api, defaults: {format: 'json'} do
Expand Down