spree_unified_payment 1.0.0 → 1.0.1

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.
data/Gemfile CHANGED
@@ -1,13 +1,14 @@
1
1
  source "https://rubygems.org"
2
2
  gem 'rails', '3.2.16'
3
3
  gem 'mysql2'
4
+ gem 'sqlite3'
4
5
 
5
6
 
6
7
  gem 'spree', :git => 'git://github.com/spree/spree.git', :tag => 'v2.0.3'
7
8
  gem 'spree_wallet', :git => 'git://github.com/vinsol/spree_wallet.git'
8
9
  gem 'spree_auth_devise', github: 'spree/spree_auth_devise', branch: '2-0-stable'
9
10
 
10
- gem 'unified_payment', :git => "git@github.com:vinsol/Unified-Payments.git", :branch => 'master', :ref => '4ced91335fec2cf186c30b593d9a1f6083028748'
11
+ gem 'unified_payment', :tag => 'v1.0.1'
11
12
  gem 'delayed_job_active_record', :tag => 'v4.0.0'
12
13
 
13
14
  group :test do
data/Rakefile ADDED
@@ -0,0 +1,15 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ require 'rspec/core/rake_task'
5
+ require 'spree/testing_support/extension_rake'
6
+
7
+ RSpec::Core::RakeTask.new
8
+
9
+ task :default => [:spec]
10
+
11
+ desc 'Generates a dummy app for testing'
12
+ task :test_app do
13
+ ENV['LIB_NAME'] = 'spree_unified_payment'
14
+ Rake::Task['extension:test_app'].invoke
15
+ end
@@ -30,7 +30,7 @@ $(document).ready(function() {
30
30
  return self;
31
31
  }
32
32
 
33
- $('#reveal_xml').click(function() {
33
+ $('.reveal_xml').click(function() {
34
34
  ct_id = $(this).attr('data-ct-id');
35
35
  var quick_view = new ModalPopUp($("<div></div>").attr('id', 'quick_view_popup').html($("#xml_response_" + ct_id).clone()));
36
36
  $('#quick_view_popup .xml_response').removeClass('hidden');
@@ -49,7 +49,7 @@ module Spree
49
49
 
50
50
  @payment_made = @gateway_message_hash['PurchaseAmountScr'].to_f
51
51
  if @card_transaction.approved_at_gateway?
52
- if @card_transaction.amount != @payment_made
52
+ if @card_transaction.amount.to_f != @payment_made
53
53
  process_unsuccessful_transaction
54
54
  else
55
55
  process_successful_transaction
@@ -129,9 +129,7 @@ module Spree
129
129
 
130
130
  def tasks_on_gateway_create_response(response, transaction_id)
131
131
  response_order = response['Order']
132
-
133
- #[TODO_CR] Make required attributes protected and save them with without protection in the place where protection is not necessary.
134
- #[MK] Please look into this change. Could not find a good way to implement it without much hastle.
132
+
135
133
  gateway_transaction = UnifiedPayment::Transaction.where(:gateway_session_id => response_order['SessionID'], :gateway_order_id => response_order['OrderID'], :url => response_order['URL']).first
136
134
  gateway_transaction.assign_attributes({:user_id => @order.user.try(:id), :payment_transaction_id => transaction_id, :order_id => @order.id, :gateway_order_status => 'CREATED', :amount => @order.total, :currency => Spree::Config[:currency], :response_status => response["Status"], :status => 'pending'}, :without_protection => true)
137
135
  gateway_transaction.save!
@@ -1,6 +1,6 @@
1
1
  Deface::Override.new(:virtual_path => "spree/layouts/admin",
2
2
  :name => "Add Unified tab to menu",
3
3
  :insert_bottom => "[data-hook='admin_tabs'], #admin_tabs[data-hook]",
4
- :text => " <%= tab( :Unified , :url => admin_unified_payments_path) %>",
4
+ :text => " <%= tab( :UnifiedPayments , :url => admin_unified_payments_path) %>",
5
5
  :sequence => {:after => "promo_admin_tabs"},
6
6
  :disabled => false)
@@ -0,0 +1,6 @@
1
+ Deface::Override.new(:virtual_path => "spree/shared/_nav_bar",
2
+ :name => "User link to view UnifiedPayment Transactions",
3
+ :insert_before => "li#search-bar",
4
+ :partial => "spree/shared/unified_payments_link",
5
+ :disabled => false,
6
+ :original => 'eb3fa668cd98b6a1c75c36420ef1b238a1fc55ac')
@@ -2,7 +2,7 @@
2
2
 
3
3
  <% content_for :table_filter do %>
4
4
  <div data-hook="admin_orders_index_search">
5
- <%= form_for [:admin, @search], :url => unified_payments_path, :method => :get do |f| %>
5
+ <%= form_for [:admin, @search], :url => admin_unified_payments_path, :method => :get do |f| %>
6
6
  <div class="field-block alpha four columns">
7
7
  <div class="date-range-filter field">
8
8
  <%= label_tag nil, Spree.t(:date_range) %>
@@ -79,10 +79,10 @@
79
79
  <td><%= card_transaction.created_at.strftime("%d %b %Y, %I:%M%p") %></td>
80
80
  <td class="action">
81
81
  <% unless card_transaction.status == 'pending' %>
82
- <a href="javascript:void(0)" id="reveal_xml" data-ct-id=<%= card_transaction.id%>>View XML</a>
82
+ <a href="javascript:void(0)" class="reveal_xml" data-ct-id=<%= card_transaction.id%>>View XML</a>
83
83
  <div class="hidden xml_response" id="xml_response_<%= card_transaction.id %>"><%= card_transaction.xml_response %></div>
84
84
  <% unless card_transaction.store_credit.present? %>
85
- |<%= link_to "Receipt", unified_payments_receipt_path(:transaction_id => card_transaction.payment_transaction_id) %>
85
+ |<%= link_to "Receipt", admin_unified_payments_receipt_path(:transaction_id => card_transaction.payment_transaction_id) %>
86
86
  <% end %>
87
87
  <% else %>
88
88
  <%= link_to("QueryAndWallet", admin_unified_payments_query_gateway_path(:transaction_id => card_transaction.payment_transaction_id), :remote => true, confirm: "#{card_transaction.amount} will be walleted to #{card_transaction.user.try(:email) }. Are You Sure?", :method => 'post', :class => 'wallet_link') unless card_transaction.store_credit.present? %>
@@ -6,5 +6,5 @@
6
6
  $('#<%= @card_transaction.payment_transaction_id %> .gateway_order_status').text('<%= @card_transaction.gateway_order_status %>')
7
7
  <% else %>
8
8
  alert('Could not wallet the money. Got order status <%= @card_transaction.gateway_order_status %>');
9
- $('#<%= @card_transaction.payment_transaction_id %> .gateway_order_status').text('<%= @@card_transaction.gateway_order_status %>')
9
+ $('#<%= @card_transaction.payment_transaction_id %> .gateway_order_status').text('<%= @card_transaction.gateway_order_status %>')
10
10
  <% end %>
@@ -0,0 +1 @@
1
+ <li><%= link_to 'UnifiedPayment Transactions', unified_payments_path %></li>
@@ -0,0 +1,25 @@
1
+ class AddUnifiedPaymentTransactions < ActiveRecord::Migration
2
+ def change
3
+ unless UnifiedPayment::Transaction.table_exists?
4
+ create_table :unified_payment_transactions do |t|
5
+ t.integer :gateway_order_id
6
+ t.string :gateway_order_status
7
+ t.string :amount
8
+ t.string :gateway_session_id
9
+ t.string :url
10
+ t.string :merchant_id
11
+ t.string :currency
12
+ t.string :order_description
13
+ t.string :response_status
14
+ t.string :response_description
15
+ t.string :pan
16
+ t.string :approval_code
17
+ t.text :xml_response
18
+ t.timestamps
19
+ end
20
+
21
+ add_index :unified_payment_transactions, [:gateway_order_id, :gateway_session_id], name: :order_session_index
22
+ add_index :unified_payment_transactions, :response_status
23
+ end
24
+ end
25
+ end
@@ -9,7 +9,6 @@ describe Spree::UnifiedPaymentsController do
9
9
  before(:each) do
10
10
  user.stub(:generate_spree_api_key!).and_return(true)
11
11
  user.stub(:last_incomplete_spree_order).and_return(order)
12
- Spree::Config[:site_name] = "MyTestSite"
13
12
  controller.stub(:spree_current_user).and_return(user)
14
13
  controller.stub(:current_order).and_return(order)
15
14
  end
@@ -142,8 +141,8 @@ describe Spree::UnifiedPaymentsController do
142
141
  before do
143
142
  session[:transaction_id] = '12345678910121'
144
143
  @gateway_response = Object.new
145
- UnifiedPayment::Transaction.stub(:create_order_at_unified).with(order.total, {:approve_url=>"http://test.host/unified_payments/approved", :cancel_url=>"http://test.host/unified_payments/canceled", :decline_url=>"http://test.host/unified_payments/declined", :description=>"Purchasing items from MyTestSite"}).and_return(@gateway_response)
146
- UnifiedPayment::Transaction.stub(:extract_url_for_unified_payment).with(@gateway_response).and_return('www.MyTestSite.com')
144
+ UnifiedPayment::Transaction.stub(:create_order_at_unified).with(order.total, {:approve_url=>"http://test.host/unified_payments/approved", :cancel_url=>"http://test.host/unified_payments/canceled", :decline_url=>"http://test.host/unified_payments/declined", :description=>"Purchasing items from #{Spree::Config[:site_name]}"}).and_return(@gateway_response)
145
+ UnifiedPayment::Transaction.stub(:extract_url_for_unified_payment).with(@gateway_response).and_return("www.#{Spree::Config[:site_name]}.com")
147
146
  controller.stub(:tasks_on_gateway_create_response).with(@gateway_response, '12345678910121').and_return(true)
148
147
  end
149
148
 
@@ -175,8 +174,8 @@ describe Spree::UnifiedPaymentsController do
175
174
  context 'when an order is successfully created at gateway' do
176
175
 
177
176
  describe 'method calls' do
178
- it { UnifiedPayment::Transaction.should_receive(:create_order_at_unified).with(order.total, {:approve_url=>"http://test.host/unified_payments/approved", :cancel_url=>"http://test.host/unified_payments/canceled", :decline_url=>"http://test.host/unified_payments/declined", :description=>"Purchasing items from MyTestSite"}).and_return(@gateway_response) }
179
- it { UnifiedPayment::Transaction.should_receive(:extract_url_for_unified_payment).with(@gateway_response).and_return('www.MyTestSite.com') }
177
+ it { UnifiedPayment::Transaction.should_receive(:create_order_at_unified).with(order.total, {:approve_url=>"http://test.host/unified_payments/approved", :cancel_url=>"http://test.host/unified_payments/canceled", :decline_url=>"http://test.host/unified_payments/declined", :description=>"Purchasing items from #{Spree::Config[:site_name]}"}).and_return(@gateway_response) }
178
+ it { UnifiedPayment::Transaction.should_receive(:extract_url_for_unified_payment).with(@gateway_response).and_return("www.#{Spree::Config[:site_name]}.com") }
180
179
  it { controller.should_receive(:tasks_on_gateway_create_response).with(@gateway_response, '12345678910121').and_return(true) }
181
180
 
182
181
  after { send_request }
@@ -185,17 +184,17 @@ describe Spree::UnifiedPaymentsController do
185
184
  describe 'assigns' do
186
185
  it 'payment_url' do
187
186
  send_request
188
- assigns(:payment_url).should eq("www.MyTestSite.com")
187
+ assigns(:payment_url).should eq("www.#{Spree::Config[:site_name]}.com")
189
188
  end
190
189
  end
191
190
  end
192
191
 
193
192
  context 'when order not created at gateway' do
194
193
 
195
- before { UnifiedPayment::Transaction.stub(:create_order_at_unified).with(order.total, {:approve_url=>"http://test.host/unified_payments/approved", :cancel_url=>"http://test.host/unified_payments/canceled", :decline_url=>"http://test.host/unified_payments/declined", :description=>"Purchasing items from MyTestSite"}).and_return(false) }
194
+ before { UnifiedPayment::Transaction.stub(:create_order_at_unified).with(order.total, {:approve_url=>"http://test.host/unified_payments/approved", :cancel_url=>"http://test.host/unified_payments/canceled", :decline_url=>"http://test.host/unified_payments/declined", :description=>"Purchasing items from #{Spree::Config[:site_name]}"}).and_return(false) }
196
195
 
197
196
  describe 'method calls' do
198
- it { UnifiedPayment::Transaction.should_receive(:create_order_at_unified).with(order.total, {:approve_url=>"http://test.host/unified_payments/approved", :cancel_url=>"http://test.host/unified_payments/canceled", :decline_url=>"http://test.host/unified_payments/declined", :description=>"Purchasing items from MyTestSite"}).and_return(false) }
197
+ it { UnifiedPayment::Transaction.should_receive(:create_order_at_unified).with(order.total, {:approve_url=>"http://test.host/unified_payments/approved", :cancel_url=>"http://test.host/unified_payments/canceled", :decline_url=>"http://test.host/unified_payments/declined", :description=>"Purchasing items from #{Spree::Config[:site_name]}"}).and_return(false) }
199
198
  it { UnifiedPayment::Transaction.should_not_receive(:extract_url_for_unified_payment) }
200
199
  it { controller.should_not_receive(:tasks_on_gateway_create_response) }
201
200
 
@@ -219,7 +218,7 @@ describe Spree::UnifiedPaymentsController do
219
218
  before { send_request }
220
219
 
221
220
  it { flash[:error].should be_nil }
222
- it { response.body.should eq("$('#confirm_payment').hide();top.location.href = 'www.MyTestSite.com'") }
221
+ it { response.body.should eq("$('#confirm_payment').hide();top.location.href = 'www.#{Spree::Config[:site_name]}.com'") }
223
222
  end
224
223
  end
225
224
  end
@@ -236,8 +235,8 @@ describe Spree::UnifiedPaymentsController do
236
235
  order.stub(:next).and_return(true)
237
236
  @gateway_response = {'Status' => 'status', 'Order' => { 'SessionID' => '12312', 'OrderID' => '123121', 'URL' => 'MyResponse'}}
238
237
  @transaction = UnifiedPayment::Transaction.new
239
- UnifiedPayment::Transaction.stub(:create_order_at_unified).with(order.total, {:approve_url=>"http://test.host/unified_payments/approved", :cancel_url=>"http://test.host/unified_payments/canceled", :decline_url=>"http://test.host/unified_payments/declined", :description=>"Purchasing items from MyTestSite"}).and_return(@gateway_response)
240
- UnifiedPayment::Transaction.stub(:extract_url_for_unified_payment).with(@gateway_response).and_return('www.MyTestSite.com')
238
+ UnifiedPayment::Transaction.stub(:create_order_at_unified).with(order.total, {:approve_url=>"http://test.host/unified_payments/approved", :cancel_url=>"http://test.host/unified_payments/canceled", :decline_url=>"http://test.host/unified_payments/declined", :description=>"Purchasing items from #{Spree::Config[:site_name]}"}).and_return(@gateway_response)
239
+ UnifiedPayment::Transaction.stub(:extract_url_for_unified_payment).with(@gateway_response).and_return("www.#{Spree::Config[:site_name]}.com")
241
240
  UnifiedPayment::Transaction.stub(:where).with(:gateway_session_id => '12312', :gateway_order_id => '123121', :url => 'MyResponse').and_return([@transaction])
242
241
  @transaction.stub(:save!).and_return(true)
243
242
  end
@@ -320,8 +320,8 @@ describe UnifiedPayment::Transaction do
320
320
 
321
321
  describe 'abort!' do
322
322
  before do
323
- @time_now = Time.now
324
- Time.stub(:now).and_return(@time_now)
323
+ @time_now = DateTime.strptime('2012-03-03', '%Y-%m-%d')
324
+ Time.stub(:current).and_return(@time_now)
325
325
  @card_transaction = UnifiedPayment::Transaction.new(:status => 'somestatus', :payment_transaction_id => '1234')
326
326
  @card_transaction.stub(:release_order_inventory).and_return(true)
327
327
  end
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # This file is copied to spec/ when you run 'rails generate rspec:install'
2
2
  ENV["RAILS_ENV"] ||= 'test'
3
- require File.expand_path("../../config/environment", __FILE__)
3
+ require File.expand_path("../dummy/config/environment", __FILE__)
4
4
  require 'rspec/rails'
5
5
  # require 'rspec/autorun'
6
6
 
@@ -17,6 +17,11 @@ require 'database_cleaner'
17
17
  # If you are not using ActiveRecord, you can remove this line.
18
18
  # ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration)
19
19
 
20
+ #Allow attr_access for test environment
21
+ UnifiedPayment::Transaction.class_eval do
22
+ attr_accessible :payment_transaction_id
23
+ end
24
+
20
25
  RSpec.configure do |config|
21
26
  # ## Mock Framework
22
27
  #
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.platform = Gem::Platform::RUBY
3
3
  s.name = "spree_unified_payment"
4
- s.version = "1.0.0"
4
+ s.version = "1.0.1"
5
5
  s.author = ["Manish Kangia", "Sushant Mittal"]
6
6
  s.email = 'info@vinsol.com'
7
7
  s.homepage = 'http://vinsol.com'
@@ -17,7 +17,7 @@ Gem::Specification.new do |s|
17
17
  s.requirements << 'none'
18
18
 
19
19
  s.add_dependency('spree_core', '~> 2.0.0')
20
- s.add_dependency 'unified_payment', '1.0.0'
20
+ s.add_dependency 'unified_payment', '1.0.1'
21
21
  s.add_dependency 'spree_wallet', '~> 2.0.3'
22
22
  s.add_dependency 'delayed_job_active_record', '~> 4.0.0'
23
23
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spree_unified_payment
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 0
10
- version: 1.0.0
9
+ - 1
10
+ version: 1.0.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Manish Kangia
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2014-02-27 00:00:00 Z
19
+ date: 2014-03-04 00:00:00 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  name: spree_core
@@ -42,12 +42,12 @@ dependencies:
42
42
  requirements:
43
43
  - - "="
44
44
  - !ruby/object:Gem::Version
45
- hash: 23
45
+ hash: 21
46
46
  segments:
47
47
  - 1
48
48
  - 0
49
- - 0
50
- version: 1.0.0
49
+ - 1
50
+ version: 1.0.1
51
51
  type: :runtime
52
52
  version_requirements: *id002
53
53
  - !ruby/object:Gem::Dependency
@@ -96,6 +96,7 @@ files:
96
96
  - Gemfile
97
97
  - LICENSE
98
98
  - README.md
99
+ - Rakefile
99
100
  - Versionfile
100
101
  - app/assets/javascripts/admin/spree_unified_payment.js
101
102
  - app/assets/stylesheets/store/spree_unified_payment.css
@@ -112,10 +113,12 @@ files:
112
113
  - app/models/spree/user_decorator.rb
113
114
  - app/models/unified_payment/transaction_decorator.rb
114
115
  - app/overrides/add_unified_tabs_to_admin_menu.rb
116
+ - app/overrides/add_user_view_link_for_transactions.rb
115
117
  - app/views/spree/admin/unified_payments/index.html.erb
116
118
  - app/views/spree/admin/unified_payments/query_gateway.js.erb
117
119
  - app/views/spree/admin/unified_payments/receipt.html.erb
118
120
  - app/views/spree/checkout/payment/_unifiedpaymentmethod.html.erb
121
+ - app/views/spree/shared/_unified_payments_link.html.erb
119
122
  - app/views/spree/transaction_notification_mailer/send_mail.html.erb
120
123
  - app/views/spree/unified_payments/approved.html.erb
121
124
  - app/views/spree/unified_payments/canceled.html.erb
@@ -127,6 +130,7 @@ files:
127
130
  - app/views/spree/unified_payments/new.js.erb
128
131
  - config/initializers/constants.rb
129
132
  - config/routes.rb
133
+ - db/migrate/20131101092408_add_unified_payment_transactions.rb
130
134
  - db/migrate/20140120075553_add_transaction_fields_to_unified_payment_transactions.rb
131
135
  - db/migrate/20140120081453_add_unified_transaction_id_to_spree_store_credits.rb
132
136
  - lib/generators/spree_unified_payment/install/install_generator.rb