spree_bcash 0.0.2 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/Rakefile +29 -1
 - data/app/controllers/spree/bcash_controller.rb +20 -0
 - data/app/models/spree/bcash_notification.rb +24 -0
 - data/app/models/spree/order_decorator.rb +10 -0
 - data/app/overrides/replace_payment_info.rb +1 -1
 - data/app/views/spree/checkout/payment/_order_details_bcash.html.erb +6 -3
 - data/config/routes.rb +3 -0
 - data/db/migrate/20130420180360_create_spree_bcash_notifications.rb +12 -0
 - data/lib/generators/spree_bcash/install/install_generator.rb +21 -0
 - data/lib/spree_bcash/version.rb +1 -1
 - data/spree_bcash.gemspec +1 -1
 - metadata +9 -4
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: f465996d9a4a9d92f9e09d22c8db2f2572702844
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 05ab6a96ae14819ea7d2267220f008b96cac9a1d
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 52b51b2d79ed8a47fd6d6ad6fc1616330f803715175d728b2d55770c06cbebb2340d05ae8288c5963ea9164de1f668647e002f248e878b10eb82be1000ac898c
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: dc57cebfe2c4f4dcabab8ed46995c19c180b92eb95e493bc88d0fb21b4c2f4b18e8c2acccf7e01907f201c81732d90d3df5de59bcace9ec853c26cbf3352df7b
         
     | 
    
        data/Rakefile
    CHANGED
    
    | 
         @@ -1 +1,29 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require  
     | 
| 
      
 1 
     | 
    
         
            +
            require 'rake'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'rake/testtask'
         
     | 
| 
      
 3 
     | 
    
         
            +
            require 'rake/packagetask'
         
     | 
| 
      
 4 
     | 
    
         
            +
            require 'rubygems/package_task'
         
     | 
| 
      
 5 
     | 
    
         
            +
            require 'rspec/core/rake_task'
         
     | 
| 
      
 6 
     | 
    
         
            +
            require 'spree/core/testing_support/common_rake'
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            RSpec::Core::RakeTask.new
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
            task :default => [:spec]
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
            spec = eval(File.read('spree_bcash.gemspec'))
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
            Gem::PackageTask.new(spec) do |p|
         
     | 
| 
      
 15 
     | 
    
         
            +
              p.gem_spec = spec
         
     | 
| 
      
 16 
     | 
    
         
            +
            end
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
            desc "Release to gemcutter"
         
     | 
| 
      
 19 
     | 
    
         
            +
            task :release => :package do
         
     | 
| 
      
 20 
     | 
    
         
            +
              require 'rake/gemcutter'
         
     | 
| 
      
 21 
     | 
    
         
            +
              Rake::Gemcutter::Tasks.new(spec).define
         
     | 
| 
      
 22 
     | 
    
         
            +
              Rake::Task['gem:push'].invoke
         
     | 
| 
      
 23 
     | 
    
         
            +
            end
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
            desc "Generates a dummy app for testing"
         
     | 
| 
      
 26 
     | 
    
         
            +
            task :test_app do
         
     | 
| 
      
 27 
     | 
    
         
            +
              ENV['LIB_NAME'] = 'spree_bcash'
         
     | 
| 
      
 28 
     | 
    
         
            +
              Rake::Task['common:test_app'].invoke
         
     | 
| 
      
 29 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,20 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module Spree
         
     | 
| 
      
 2 
     | 
    
         
            +
              class BcashController < BaseController
         
     | 
| 
      
 3 
     | 
    
         
            +
                protect_from_forgery :except => [:notify]
         
     | 
| 
      
 4 
     | 
    
         
            +
                skip_before_filter :restriction_access
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
                def notify
         
     | 
| 
      
 7 
     | 
    
         
            +
                  notification = Spree::BcashNotification.create_from_params(params)
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
                  if notification.cod_status == "1"
         
     | 
| 
      
 10 
     | 
    
         
            +
                    Order.transaction do
         
     | 
| 
      
 11 
     | 
    
         
            +
                      @order = Spree::Order.find_by_number(notification.id_pedido)
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
                      @order.payment.complete
         
     | 
| 
      
 14 
     | 
    
         
            +
                    end
         
     | 
| 
      
 15 
     | 
    
         
            +
                  end
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
                  redirect_to order_path(id: notification.id_pedido)
         
     | 
| 
      
 18 
     | 
    
         
            +
                end
         
     | 
| 
      
 19 
     | 
    
         
            +
              end
         
     | 
| 
      
 20 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,24 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module Spree
         
     | 
| 
      
 2 
     | 
    
         
            +
              class BcashNotification < ActiveRecord::Base
         
     | 
| 
      
 3 
     | 
    
         
            +
                belongs_to :order
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
                attr_protected
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
                def self.create_from_params(params)
         
     | 
| 
      
 8 
     | 
    
         
            +
                  notification = ::Bcash::Notification.new(params)
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
                  notify = self.find_by_id_transaction(notification.id_transacao)
         
     | 
| 
      
 11 
     | 
    
         
            +
                  if notify
         
     | 
| 
      
 12 
     | 
    
         
            +
                    notify.update_attributes(status: notification.status.force_encoding("iso-8859-1"))
         
     | 
| 
      
 13 
     | 
    
         
            +
                  else
         
     | 
| 
      
 14 
     | 
    
         
            +
                    self.create!(
         
     | 
| 
      
 15 
     | 
    
         
            +
                      order_id: Order.find_by_number(notification.id_pedido).id,
         
     | 
| 
      
 16 
     | 
    
         
            +
                      id_transaction: notification.id_transacao,
         
     | 
| 
      
 17 
     | 
    
         
            +
                      status: notification.status.force_encoding("iso-8859-1")
         
     | 
| 
      
 18 
     | 
    
         
            +
                    )
         
     | 
| 
      
 19 
     | 
    
         
            +
                  end
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
                  notification
         
     | 
| 
      
 22 
     | 
    
         
            +
                end
         
     | 
| 
      
 23 
     | 
    
         
            +
              end
         
     | 
| 
      
 24 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -1,7 +1,17 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            Spree::Order.class_eval do
         
     | 
| 
      
 2 
     | 
    
         
            +
              has_one :bcash_notification
         
     | 
| 
       2 
3 
     | 
    
         | 
| 
       3 
4 
     | 
    
         
             
              def self.bcash_payment_method
         
     | 
| 
       4 
5 
     | 
    
         
             
                Spree::PaymentMethod.where(type: "Spree::PaymentMethod::BcashMethod").first
         
     | 
| 
       5 
6 
     | 
    
         
             
              end
         
     | 
| 
       6 
7 
     | 
    
         | 
| 
      
 8 
     | 
    
         
            +
              def self.options_for_bcash(order, request)
         
     | 
| 
      
 9 
     | 
    
         
            +
                url_retorno = request.host_with_port + "/bcash/notify"
         
     | 
| 
      
 10 
     | 
    
         
            +
                {
         
     | 
| 
      
 11 
     | 
    
         
            +
                  :url_retorno => url_retorno,
         
     | 
| 
      
 12 
     | 
    
         
            +
                  :id_pedido => order.number,
         
     | 
| 
      
 13 
     | 
    
         
            +
                  :email_loja => Spree::Order.bcash_payment_method.preferred_email  
         
     | 
| 
      
 14 
     | 
    
         
            +
                }
         
     | 
| 
      
 15 
     | 
    
         
            +
              end
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
       7 
17 
     | 
    
         
             
            end
         
     | 
| 
         @@ -1,5 +1,8 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            <br />
         
     | 
| 
       2 
1 
     | 
    
         
             
            <%if @order.payment_method.instance_of? Spree::PaymentMethod::BcashMethod%>
         
     | 
| 
       3 
     | 
    
         
            -
            	 
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
      
 2 
     | 
    
         
            +
            	<%if @order.payment.completed?%>
         
     | 
| 
      
 3 
     | 
    
         
            +
            		Seu pagamento foi processado com sucesso!
         
     | 
| 
      
 4 
     | 
    
         
            +
            	<%else%>
         
     | 
| 
      
 5 
     | 
    
         
            +
            		Clique no botão abaixo para fazer seu pagamento usando o Bcash
         
     | 
| 
      
 6 
     | 
    
         
            +
            		<%= Bcash::Payment.new(@order.payment_method.package(@order.payment), Spree::Order.options_for_bcash(@order, request)).html%>	
         
     | 
| 
      
 7 
     | 
    
         
            +
            	<%end%>
         
     | 
| 
       5 
8 
     | 
    
         
             
            <%end%>
         
     | 
    
        data/config/routes.rb
    ADDED
    
    
| 
         @@ -0,0 +1,21 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module SpreeBcash
         
     | 
| 
      
 2 
     | 
    
         
            +
              module Generators
         
     | 
| 
      
 3 
     | 
    
         
            +
                class InstallGenerator < Rails::Generators::Base
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
                  def add_migrations
         
     | 
| 
      
 6 
     | 
    
         
            +
                    run 'bundle exec rake railties:install:migrations FROM=spree_bcash'
         
     | 
| 
      
 7 
     | 
    
         
            +
                  end
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
                  def run_migrations
         
     | 
| 
      
 10 
     | 
    
         
            +
                    question = ask "Would you like to run the migrations now? [Y/n]"
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                    if question == "" || question.downcase == "y"
         
     | 
| 
      
 13 
     | 
    
         
            +
                      run 'bundle exec rake db:migrate'
         
     | 
| 
      
 14 
     | 
    
         
            +
                    else
         
     | 
| 
      
 15 
     | 
    
         
            +
                      puts "Skiping rake db:migrate, don't forget to run it!"
         
     | 
| 
      
 16 
     | 
    
         
            +
                    end
         
     | 
| 
      
 17 
     | 
    
         
            +
                  end
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
                end
         
     | 
| 
      
 20 
     | 
    
         
            +
              end
         
     | 
| 
      
 21 
     | 
    
         
            +
            end
         
     | 
    
        data/lib/spree_bcash/version.rb
    CHANGED
    
    
    
        data/spree_bcash.gemspec
    CHANGED
    
    | 
         @@ -18,7 +18,7 @@ Gem::Specification.new do |s| 
     | 
|
| 
       18 
18 
     | 
    
         
             
              s.executables   = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
         
     | 
| 
       19 
19 
     | 
    
         
             
              s.require_paths = ["lib"]
         
     | 
| 
       20 
20 
     | 
    
         | 
| 
       21 
     | 
    
         
            -
              s.add_dependency 'bcash', '~>0. 
     | 
| 
      
 21 
     | 
    
         
            +
              s.add_dependency 'bcash', '~> 2.0.0'
         
     | 
| 
       22 
22 
     | 
    
         
             
              s.add_dependency 'spree_core'
         
     | 
| 
       23 
23 
     | 
    
         | 
| 
       24 
24 
     | 
    
         
             
              # specify any dependencies here; for example:
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: spree_bcash
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.0 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.5.0
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Matheus Caceres
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2013-04- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2013-04-23 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: bcash
         
     | 
| 
         @@ -16,14 +16,14 @@ dependencies: 
     | 
|
| 
       16 
16 
     | 
    
         
             
                requirements:
         
     | 
| 
       17 
17 
     | 
    
         
             
                - - ~>
         
     | 
| 
       18 
18 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       19 
     | 
    
         
            -
                    version: 0. 
     | 
| 
      
 19 
     | 
    
         
            +
                    version: 2.0.0
         
     | 
| 
       20 
20 
     | 
    
         
             
              type: :runtime
         
     | 
| 
       21 
21 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       22 
22 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       23 
23 
     | 
    
         
             
                requirements:
         
     | 
| 
       24 
24 
     | 
    
         
             
                - - ~>
         
     | 
| 
       25 
25 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       26 
     | 
    
         
            -
                    version: 0. 
     | 
| 
      
 26 
     | 
    
         
            +
                    version: 2.0.0
         
     | 
| 
       27 
27 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       28 
28 
     | 
    
         
             
              name: spree_core
         
     | 
| 
       29 
29 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
         @@ -62,12 +62,17 @@ files: 
     | 
|
| 
       62 
62 
     | 
    
         
             
            - .gitignore
         
     | 
| 
       63 
63 
     | 
    
         
             
            - Gemfile
         
     | 
| 
       64 
64 
     | 
    
         
             
            - Rakefile
         
     | 
| 
      
 65 
     | 
    
         
            +
            - app/controllers/spree/bcash_controller.rb
         
     | 
| 
      
 66 
     | 
    
         
            +
            - app/models/spree/bcash_notification.rb
         
     | 
| 
       65 
67 
     | 
    
         
             
            - app/models/spree/bcash_payment.rb
         
     | 
| 
       66 
68 
     | 
    
         
             
            - app/models/spree/order_decorator.rb
         
     | 
| 
       67 
69 
     | 
    
         
             
            - app/models/spree/payment_method/bcash_method.rb
         
     | 
| 
       68 
70 
     | 
    
         
             
            - app/overrides/replace_payment_info.rb
         
     | 
| 
       69 
71 
     | 
    
         
             
            - app/views/spree/checkout/payment/_bcashmethod.html.erb
         
     | 
| 
       70 
72 
     | 
    
         
             
            - app/views/spree/checkout/payment/_order_details_bcash.html.erb
         
     | 
| 
      
 73 
     | 
    
         
            +
            - config/routes.rb
         
     | 
| 
      
 74 
     | 
    
         
            +
            - db/migrate/20130420180360_create_spree_bcash_notifications.rb
         
     | 
| 
      
 75 
     | 
    
         
            +
            - lib/generators/spree_bcash/install/install_generator.rb
         
     | 
| 
       71 
76 
     | 
    
         
             
            - lib/spree_bcash.rb
         
     | 
| 
       72 
77 
     | 
    
         
             
            - lib/spree_bcash/engine.rb
         
     | 
| 
       73 
78 
     | 
    
         
             
            - lib/spree_bcash/version.rb
         
     |