diff --git a/app/controllers/admin/campaigns_controller.rb b/app/controllers/admin/campaigns_controller.rb index c6360d74..bf88a0c5 100644 --- a/app/controllers/admin/campaigns_controller.rb +++ b/app/controllers/admin/campaigns_controller.rb @@ -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 diff --git a/app/controllers/admin/payments_controller.rb b/app/controllers/admin/payments_controller.rb index 297b1c9b..1e8a9480 100644 --- a/app/controllers/admin/payments_controller.rb +++ b/app/controllers/admin/payments_controller.rb @@ -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 @@ -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 diff --git a/app/views/admin/campaigns/edit_payment.html.erb b/app/views/admin/campaigns/edit_payment.html.erb new file mode 100644 index 00000000..afc896ee --- /dev/null +++ b/app/views/admin/campaigns/edit_payment.html.erb @@ -0,0 +1,82 @@ +
+
+ + <%= render 'admin/header', active: 'campaigns' %> + +
+

<%= @campaign.name %>

+ <%= 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|%> +
+ Payer Information + +
+
+

This is the payer full name as entered on checkout

+ + <%= f.text_field :fullname %> +
+
+

This is the payer email address as entered on checkout

+ + <%= f.text_field :email %> +
+ +
+
+ + + +
+ Payment Details + +
+
+ <%= f.text_field :status, :disabled => true %> + <%= f.text_field :amount, :disabled => true %> + <%= f.text_field :user_fee_amount, :disabled => true %> + <%= f.text_field :admin_fee_amount, :disabled => true %> + <%= f.text_field :card_type, :disabled => true %> + <%= f.text_field :card_last_four, :disabled => true %> + <%= f.text_field :card_expiration_month, :disabled => true %> + <%= f.text_field :card_expiration_year, :disabled => true %> + <%= f.text_field :quantity, :disabled => true %> +
+
+
+ + +
+ Address Details + +
+
+ + <%= f.text_field :address_one, :disabled => true %> + <%= f.text_field :address_two, :disabled => true %> + <%= f.text_field :city, :disabled => true %> + <%= f.text_field :state, :disabled => true %> + <%= f.text_field :postal_code, :disabled => true %> + <%= f.text_field :billing_postal_code, :disabled => true %> + <%= f.text_field :country, :disabled => true %> +
+
+
+ +
+ Additional + +
+
+ + <%= f.text_area :additional_info, :disabled => true %> + +
+
+
+ <%= f.submit "Save", :'class' => "btn btn-primary show_loader", :'data-loader' => "payment_form" %> + + <% end %> + +
+
+
\ No newline at end of file diff --git a/app/views/admin/campaigns/payments.html.erb b/app/views/admin/campaigns/payments.html.erb index 726ee0af..5fd5e5ae 100644 --- a/app/views/admin/campaigns/payments.html.erb +++ b/app/views/admin/campaigns/payments.html.erb @@ -66,7 +66,7 @@ <%= short_price(payment.user_fee_amount.to_f/100.0, '$', 2) %> <%= payment.created_at.strftime("%m/%d/%Y") %> <%= payment.status %> - <%= payment.ct_payment_id %> + <%= link_to payment.ct_payment_id, admin_payment_path(:payment_id => payment.ct_payment_id) %> <% if ['authorized', 'charged'].include? payment.status %>Refund<% end %> diff --git a/config/routes.rb b/config/routes.rb index 48144a31..dd10b0ae 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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 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