nimbleshop_cod 0.0.1.rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +11 -0
- data/app/assets/images/nimbleshop_cod/cod_small.png +0 -0
- data/app/controllers/nimbleshop_cod/cods_controller.rb +28 -0
- data/app/controllers/nimbleshop_cod/payments_controller.rb +18 -0
- data/app/helpers/nimbleshop_cod/exposed_helper.rb +37 -0
- data/app/models/nimbleshop_cod/cod.rb +4 -0
- data/app/views/nimbleshop_cod/cods/_edit.html.erb +29 -0
- data/app/views/nimbleshop_cod/cods/_form.html.erb +26 -0
- data/app/views/nimbleshop_cod/payments/_new.html.erb +22 -0
- data/config/routes.rb +4 -0
- data/lib/nimbleshop_cod/engine.rb +17 -0
- data/lib/nimbleshop_cod/gateway.rb +4 -0
- data/lib/nimbleshop_cod/processor.rb +18 -0
- data/lib/nimbleshop_cod/version.rb +3 -0
- data/lib/nimbleshop_cod.rb +6 -0
- data/lib/tasks/nimbleshop_cod_tasks.rake +23 -0
- metadata +62 -0
data/README.md
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
# nimbleshop_cod extension
|
2
|
+
|
3
|
+
This is Cash on delivery ( cod ) extension for [nimbleShop](http://nimbleShop.org) .
|
4
|
+
|
5
|
+
# Documentation
|
6
|
+
|
7
|
+
Documentation is available at [http://nimbleshop.org/](http://nimbleShop.org) .
|
8
|
+
|
9
|
+
# License
|
10
|
+
|
11
|
+
nimbleshop_cod uses [MIT license](http://www.opensource.org/licenses/mit-license.php) .
|
Binary file
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module NimbleshopCod
|
2
|
+
|
3
|
+
class CodsController < ::Admin::PaymentMethodsController
|
4
|
+
|
5
|
+
before_filter :load_payment_method
|
6
|
+
|
7
|
+
def destroy
|
8
|
+
respond_to do |format|
|
9
|
+
if @payment_method.destroy
|
10
|
+
format.js {
|
11
|
+
flash[:notice] = 'Cash on delivery record was successfully deleted'
|
12
|
+
render js: "window.location = '/admin/payment_methods'"
|
13
|
+
}
|
14
|
+
else
|
15
|
+
format.js { render js: 'Cash on delivery record could not be deleted. Please try again later.' }
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def load_payment_method
|
23
|
+
@payment_method = NimbleshopCod::Cod.first
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module NimbleshopCod
|
2
|
+
class PaymentsController < ::ActionController::Base
|
3
|
+
|
4
|
+
def create
|
5
|
+
order = Order.find_by_id(session[:order_id])
|
6
|
+
order.update_attributes(payment_method: NimbleshopCod::Cod.first)
|
7
|
+
order.pending
|
8
|
+
|
9
|
+
respond_to do |format|
|
10
|
+
format.html do
|
11
|
+
redirect_to nimbleshop_simply.order_path(order)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module NimbleshopCod
|
2
|
+
module ExposedHelper
|
3
|
+
|
4
|
+
def nimbleshop_cod_next_payment_processing_action(order)
|
5
|
+
if order.pending?
|
6
|
+
link_to 'Mark payment as received', purchase_payment_admin_order_path(order), method: :put, class: 'btn btn-success'
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def nimbleshop_cod_small_image(options = {} )
|
11
|
+
image_tag 'engines/nimbleshop_cod/cod_small.png', {alt: 'cod icon'}.merge(options)
|
12
|
+
end
|
13
|
+
|
14
|
+
def nimbleshop_cod_big_image
|
15
|
+
image_tag 'engines/nimbleshop_cod/cod_big.png', alt: 'cod logo'
|
16
|
+
end
|
17
|
+
|
18
|
+
def nimbleshop_cod_available_payment_options_icons
|
19
|
+
return nil # do not display any payment option icon for cash on delivery
|
20
|
+
end
|
21
|
+
|
22
|
+
def nimbleshop_cod_payment_form(order)
|
23
|
+
return unless NimbleshopCod::Cod.first
|
24
|
+
render partial: '/nimbleshop_cod/payments/new', locals: { order: order }
|
25
|
+
end
|
26
|
+
|
27
|
+
def nimbleshop_cod_crud_form
|
28
|
+
return unless NimbleshopCod::Cod.first
|
29
|
+
render partial: '/nimbleshop_cod/cods/edit'
|
30
|
+
end
|
31
|
+
|
32
|
+
def nimbleshop_cod_icon_for_order_payment(order)
|
33
|
+
nimbleshop_cod_small_image( height: '13px' )
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
<div class='payment-method-engine-well'>
|
2
|
+
|
3
|
+
<div>
|
4
|
+
<h2> Cash on delivery </h2>
|
5
|
+
|
6
|
+
<div class='edit_link'>
|
7
|
+
<%= link_to nimbleshop_cod.cod_path, confirm: 'Do you really want to delete Cash on delivery payment method',
|
8
|
+
class: 'nimbleshop-payment-method-delete',
|
9
|
+
method: :delete,
|
10
|
+
remote: true do %>
|
11
|
+
<i class='icon-remove icon-white'></i>
|
12
|
+
<% end %>
|
13
|
+
</div>
|
14
|
+
<div class='clear'></div>
|
15
|
+
</div>
|
16
|
+
|
17
|
+
</div>
|
18
|
+
|
19
|
+
<script>
|
20
|
+
$(function(){
|
21
|
+
|
22
|
+
$('#nimbleshop-cod-payment-method-edit').toggle(function(){
|
23
|
+
$('#nimbleshop-cod-form-well').show();
|
24
|
+
}, function(){
|
25
|
+
$('#nimbleshop-cod-form-well').hide();
|
26
|
+
});
|
27
|
+
|
28
|
+
})
|
29
|
+
</script>
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<div class='well nimbleshop-payment-method-form-well' id='nimbleshop-cod-form-well' style='display:none;'>
|
2
|
+
|
3
|
+
<%= form_for NimbleshopSplitable::Splitable.first, url: '/nimbleshop_cod/cod',
|
4
|
+
remote: true,
|
5
|
+
html: { method: 'put',
|
6
|
+
id: 'nimbleshop-cod-form',
|
7
|
+
class: 'nimbleshop-payment-method-form form-horizontal'} do |f| %>
|
8
|
+
|
9
|
+
<fieldset>
|
10
|
+
<div class="control-group">
|
11
|
+
<div class="controls">
|
12
|
+
<label class='checkbox'>
|
13
|
+
<%= f.check_box :mode, {}, 'test', 'production' %> Enable test mode
|
14
|
+
</label>
|
15
|
+
</div>
|
16
|
+
</div>
|
17
|
+
|
18
|
+
</fieldset>
|
19
|
+
|
20
|
+
<div class="form-actions">
|
21
|
+
<%= f.submit('Submit', class: 'btn btn-primary') %>
|
22
|
+
|
23
|
+
<%= link_to t(:cancel), nimbleshop_splitable.splitable_path, class: 'cancel btn' %>
|
24
|
+
</div>
|
25
|
+
<% end %>
|
26
|
+
</div>
|
@@ -0,0 +1,22 @@
|
|
1
|
+
<label class='radio'>
|
2
|
+
<%= radio_button_tag 'payment_choice', 'cod' %>
|
3
|
+
<%= nimbleshop_cod_small_image %>
|
4
|
+
</label>
|
5
|
+
|
6
|
+
<%= form_for NimbleshopCod::Cod.new, url: nimbleshop_cod.payment_path, html: { id: 'cod-payment-form', class: 'form-horizontal' } do |f| %>
|
7
|
+
<% end %>
|
8
|
+
|
9
|
+
<%= javascript_tag do %>
|
10
|
+
$(function() {
|
11
|
+
$("input#payment_choice_cod:radio").change(function() {
|
12
|
+
var $this, val;
|
13
|
+
$this = $(this);
|
14
|
+
val = $this.val();
|
15
|
+
|
16
|
+
if (val === "cod") {
|
17
|
+
$("form#cod-payment-form").submit();
|
18
|
+
}
|
19
|
+
|
20
|
+
});
|
21
|
+
});
|
22
|
+
<% end %>
|
data/config/routes.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
module NimbleshopCod
|
2
|
+
class Engine < ::Rails::Engine
|
3
|
+
|
4
|
+
isolate_namespace NimbleshopCod
|
5
|
+
|
6
|
+
config.to_prepare do
|
7
|
+
::NimbleshopCod::Cod
|
8
|
+
end
|
9
|
+
|
10
|
+
initializer 'nimbleshop_cod_engine.action_controller' do |app|
|
11
|
+
ActiveSupport.on_load :action_controller do
|
12
|
+
helper NimbleshopCod::ExposedHelper
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module NimbleshopCod
|
2
|
+
class Processor < ::Processor::Base
|
3
|
+
|
4
|
+
attr_reader :order, :payment_method, :errors
|
5
|
+
|
6
|
+
def initialize(order)
|
7
|
+
@errors = []
|
8
|
+
@order = order
|
9
|
+
@payment_method = NimbleshopCod::Cod.first
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def do_purchase(options = {})
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
namespace :nimbleshop_cod do
|
2
|
+
|
3
|
+
desc 'load cash on delivery record'
|
4
|
+
task :load_record => :environment do
|
5
|
+
|
6
|
+
if NimbleshopCod::Cod.find_by_permalink('cash-on-delivery')
|
7
|
+
puts "Cod record already exists"
|
8
|
+
else
|
9
|
+
NimbleshopCod::Cod.create!( { name: 'Cash on delivery', permalink: 'cash-on-delivery' })
|
10
|
+
puts "Cash on delivery record was successfuly created"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
desc 'copies images from engine to main rails application'
|
15
|
+
task :copy_images do
|
16
|
+
engine_name = 'nimbleshop_cod'
|
17
|
+
origin = File.expand_path('../../app/assets/images', File.dirname(__FILE__))
|
18
|
+
destination = Rails.root.join('app', 'assets', 'images', 'engines', engine_name)
|
19
|
+
FileUtils.mkdir_p(destination) if !File.exist?(destination)
|
20
|
+
Dir[File.join(origin, '**/*')].each { |file| FileUtils.cp(file, File.join(destination) ) unless File.directory?(file) }
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: nimbleshop_cod
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1.rc1
|
5
|
+
prerelease: 6
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Neeraj Singh
|
9
|
+
- Megpha
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2012-07-03 00:00:00.000000000 Z
|
14
|
+
dependencies: []
|
15
|
+
description: Provides Cash on delivery feature to nimbleshop
|
16
|
+
email:
|
17
|
+
- neeraj@BigBinary.com
|
18
|
+
executables: []
|
19
|
+
extensions: []
|
20
|
+
extra_rdoc_files: []
|
21
|
+
files:
|
22
|
+
- app/assets/images/nimbleshop_cod/cod_small.png
|
23
|
+
- app/controllers/nimbleshop_cod/cods_controller.rb
|
24
|
+
- app/controllers/nimbleshop_cod/payments_controller.rb
|
25
|
+
- app/helpers/nimbleshop_cod/exposed_helper.rb
|
26
|
+
- app/models/nimbleshop_cod/cod.rb
|
27
|
+
- app/views/nimbleshop_cod/cods/_edit.html.erb
|
28
|
+
- app/views/nimbleshop_cod/cods/_form.html.erb
|
29
|
+
- app/views/nimbleshop_cod/payments/_new.html.erb
|
30
|
+
- config/routes.rb
|
31
|
+
- lib/nimbleshop_cod/engine.rb
|
32
|
+
- lib/nimbleshop_cod/gateway.rb
|
33
|
+
- lib/nimbleshop_cod/processor.rb
|
34
|
+
- lib/nimbleshop_cod/version.rb
|
35
|
+
- lib/nimbleshop_cod.rb
|
36
|
+
- lib/tasks/nimbleshop_cod_tasks.rake
|
37
|
+
- README.md
|
38
|
+
homepage: http://nimbleShop.org
|
39
|
+
licenses: []
|
40
|
+
post_install_message:
|
41
|
+
rdoc_options: []
|
42
|
+
require_paths:
|
43
|
+
- lib
|
44
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
45
|
+
none: false
|
46
|
+
requirements:
|
47
|
+
- - ! '>='
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0'
|
50
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
52
|
+
requirements:
|
53
|
+
- - ! '>'
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: 1.3.1
|
56
|
+
requirements: []
|
57
|
+
rubyforge_project:
|
58
|
+
rubygems_version: 1.8.23
|
59
|
+
signing_key:
|
60
|
+
specification_version: 3
|
61
|
+
summary: Cash on delivery extension for nimbleshop
|
62
|
+
test_files: []
|