spree_unified_payment 1.0.2 → 1.1.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.
- data/Gemfile +9 -5
- data/README.md +5 -1
- data/Versionfile +2 -1
- data/app/controllers/spree/unified_payments_controller.rb +1 -3
- data/app/models/spree/order_decorator.rb +6 -2
- data/app/models/spree/store_credit_decorator.rb +0 -1
- data/app/models/unified_payment/transaction_decorator.rb +2 -4
- data/config/routes.rb +19 -14
- data/spec/controllers/spree/unified_payments_controller_spec.rb +7 -7
- data/spec/models/spree/order_decorator_spec.rb +14 -5
- data/spec/models/spree/store_credit_decorator_spec.rb +0 -6
- data/spec/models/unified_payment/transaction_decorator_spec.rb +20 -24
- data/spec/spec_helper.rb +0 -5
- data/spree_unified_payment.gemspec +4 -4
- metadata +12 -12
data/Gemfile
CHANGED
@@ -1,14 +1,18 @@
|
|
1
1
|
source "https://rubygems.org"
|
2
|
-
gem 'rails', '
|
2
|
+
gem 'rails', '4.0.2'
|
3
3
|
gem 'mysql2'
|
4
4
|
gem 'sqlite3'
|
5
5
|
|
6
6
|
|
7
|
-
gem 'spree', :git => '
|
8
|
-
|
9
|
-
|
7
|
+
gem 'spree', :git => 'https://github.com/spree/spree.git', :tag => 'v2.1.4'
|
8
|
+
|
9
|
+
# Provides basic authentication functionality for testing parts of your engine
|
10
|
+
gem 'spree_auth_devise', github: 'spree/spree_auth_devise', :branch => '2-1-stable'
|
11
|
+
|
12
|
+
gem 'spree_wallet', :git => 'git://github.com/vinsol/spree_wallet.git', tag: '2.1.0'
|
13
|
+
|
14
|
+
gem 'unified_payment', github: 'vinsol/Unified-Payments', branch: 'upgrade_rails4'
|
10
15
|
|
11
|
-
gem 'unified_payment', :tag => 'v1.0.1'
|
12
16
|
gem 'delayed_job_active_record', :tag => 'v4.0.0'
|
13
17
|
|
14
18
|
group :test do
|
data/README.md
CHANGED
data/Versionfile
CHANGED
@@ -22,8 +22,6 @@ module Spree
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def create
|
25
|
-
# We also can extract these options is a method.
|
26
|
-
#[MK] it was decided not giving any options since we want the requested to be redirected defined methods only
|
27
25
|
response = UnifiedPayment::Transaction.create_order_at_unified(@order.total, { :approve_url => approved_unified_payments_url, :cancel_url => canceled_unified_payments_url, :decline_url => declined_unified_payments_url, :description => "Purchasing items from #{Spree::Config[:site_name]}" })
|
28
26
|
if response
|
29
27
|
@payment_url = UnifiedPayment::Transaction.extract_url_for_unified_payment(response)
|
@@ -131,7 +129,7 @@ module Spree
|
|
131
129
|
response_order = response['Order']
|
132
130
|
|
133
131
|
gateway_transaction = UnifiedPayment::Transaction.where(:gateway_session_id => response_order['SessionID'], :gateway_order_id => response_order['OrderID'], :url => response_order['URL']).first
|
134
|
-
gateway_transaction.assign_attributes(
|
132
|
+
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')
|
135
133
|
gateway_transaction.save!
|
136
134
|
|
137
135
|
@order.reserve_stock
|
@@ -47,12 +47,12 @@ Spree::Order.class_eval do
|
|
47
47
|
|
48
48
|
deliver_order_confirmation_email
|
49
49
|
|
50
|
-
self.state_changes.create(
|
50
|
+
self.state_changes.create(
|
51
51
|
previous_state: previous_states.last.to_s,
|
52
52
|
next_state: 'complete',
|
53
53
|
name: 'order' ,
|
54
54
|
user_id: self.user_id
|
55
|
-
|
55
|
+
)
|
56
56
|
end
|
57
57
|
|
58
58
|
def reserve_stock
|
@@ -64,4 +64,8 @@ Spree::Order.class_eval do
|
|
64
64
|
end
|
65
65
|
end
|
66
66
|
end
|
67
|
+
|
68
|
+
def total_eql?(amount)
|
69
|
+
total == Float(amount)
|
70
|
+
end
|
67
71
|
end
|
@@ -1,6 +1,4 @@
|
|
1
1
|
UnifiedPayment::Transaction.class_eval do
|
2
|
-
attr_accessible :status
|
3
|
-
|
4
2
|
belongs_to :order, :class_name => "Spree::Order"
|
5
3
|
belongs_to :user, :class_name => "Spree::User"
|
6
4
|
has_one :store_credit, :class_name => "Spree::StoreCredit"
|
@@ -15,7 +13,7 @@ UnifiedPayment::Transaction.class_eval do
|
|
15
13
|
after_save :release_order_inventory, :if => [:expired_at?, "expired_at_was == nil"]
|
16
14
|
|
17
15
|
def payment_valid_for_order?
|
18
|
-
!order.completed? && order.
|
16
|
+
!order.completed? && order.total_eql?(amount)
|
19
17
|
end
|
20
18
|
|
21
19
|
def order_inventory_released?
|
@@ -83,7 +81,7 @@ UnifiedPayment::Transaction.class_eval do
|
|
83
81
|
end
|
84
82
|
|
85
83
|
def complete_order
|
86
|
-
if order.
|
84
|
+
if order.total_eql?(amount)
|
87
85
|
order.next!
|
88
86
|
order.pending_payments.first.complete
|
89
87
|
end
|
data/config/routes.rb
CHANGED
@@ -1,15 +1,20 @@
|
|
1
|
-
Spree::Core::Engine.routes.
|
2
|
-
get '/unified_payments'
|
3
|
-
get '/unified_payments/new'
|
4
|
-
post '/unified_payments/create'
|
5
|
-
post '/unified_payments/canceled'
|
6
|
-
|
7
|
-
post '/unified_payments/approved'
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
1
|
+
Spree::Core::Engine.routes.draw do
|
2
|
+
get '/unified_payments' => "unified_payments#index", as: :unified_payments
|
3
|
+
get '/unified_payments/new' => "unified_payments#new", as: :new_unified_transaction
|
4
|
+
post '/unified_payments/create' => "unified_payments#create", as: :create_unified_transaction
|
5
|
+
post '/unified_payments/canceled' => "unified_payments#canceled", as: :canceled_unified_payments
|
6
|
+
get '/unified_payments/declined' => "unified_payments#declined", as: :declined_unified_payments
|
7
|
+
post '/unified_payments/approved' => "unified_payments#approved", as: :approved_unified_payments
|
8
|
+
|
9
|
+
get 'admin/unified_payments' => "admin/unified_payments#index"
|
10
|
+
get 'admin/unified_payments/receipt/:transaction_id' => "admin/unified_payments#receipt", as: :unified_payments_receipt
|
11
|
+
post 'admin/unified_payments/query_gateway' => "admin/unified_payments#query_gateway", as: :unified_payments_query_gateway
|
12
|
+
|
13
|
+
#for test
|
14
|
+
#[TODO]:uncomment this later
|
15
|
+
# get '/unified_payments/declined', :to => redirect{ |p, request| '/' }
|
16
|
+
|
17
|
+
#[TODO]:remove this later
|
18
|
+
# get '/unified_payments/approved', :to => "unified_payments#approved"
|
19
|
+
# get '/unified_payments/canceled', :to => "unified_payments#canceled"
|
15
20
|
end
|
@@ -254,7 +254,7 @@ describe Spree::UnifiedPaymentsController do
|
|
254
254
|
it { order.should_receive(:reserve_stock).and_return(true) }
|
255
255
|
it { order.should_not_receive(:next) }
|
256
256
|
it { UnifiedPayment::Transaction.should_receive(:where).with(:gateway_session_id => '12312', :gateway_order_id => '123121', :url => 'MyResponse').and_return([@transaction]) }
|
257
|
-
it { @transaction.should_receive(:assign_attributes).with({:user_id => order.user.try(:id), :payment_transaction_id => '12345678910121', :order_id => order.id, :gateway_order_status => 'CREATED', :amount => order.total, :currency => Spree::Config[:currency], :response_status => 'status', :status => 'pending'}
|
257
|
+
it { @transaction.should_receive(:assign_attributes).with({:user_id => order.user.try(:id), :payment_transaction_id => '12345678910121', :order_id => order.id, :gateway_order_status => 'CREATED', :amount => order.total, :currency => Spree::Config[:currency], :response_status => 'status', :status => 'pending'}).and_return(true) }
|
258
258
|
it { @transaction.should_receive(:save!).and_return(true) }
|
259
259
|
after { send_request }
|
260
260
|
end
|
@@ -275,7 +275,7 @@ describe Spree::UnifiedPaymentsController do
|
|
275
275
|
@card_transaction.stub(:order).and_return(order)
|
276
276
|
UnifiedPayment::Transaction.stub_chain(:where, :first).and_return(@card_transaction)
|
277
277
|
end
|
278
|
-
|
278
|
+
|
279
279
|
context 'as declined' do
|
280
280
|
describe '#declined' do
|
281
281
|
|
@@ -297,9 +297,9 @@ describe Spree::UnifiedPaymentsController do
|
|
297
297
|
after { send_request({:xmlmsg => '<Message><Hash>Mymessage</Hash><ResponseDescription>Reason</ResponseDescription></Message>'}) }
|
298
298
|
end
|
299
299
|
|
300
|
-
it 'renders
|
300
|
+
it 'renders declined template' do
|
301
301
|
send_request({:xmlmsg => '<Message><Hash>Mymessage</Hash><ResponseDescription>Reason</ResponseDescription></Message>'})
|
302
|
-
response.should render_template(:declined
|
302
|
+
response.should render_template(:declined)
|
303
303
|
end
|
304
304
|
end
|
305
305
|
end
|
@@ -368,9 +368,9 @@ describe Spree::UnifiedPaymentsController do
|
|
368
368
|
after { send_request({:xmlmsg => '<Message><Hash>Mymessage</Hash></Message>'}) }
|
369
369
|
end
|
370
370
|
|
371
|
-
it 'renders
|
371
|
+
it 'renders canceled template' do
|
372
372
|
send_request({:xmlmsg => '<Message><Hash>Mymessage</Hash></Message>'})
|
373
|
-
response.should render_template(:canceled
|
373
|
+
response.should render_template(:canceled)
|
374
374
|
end
|
375
375
|
end
|
376
376
|
end
|
@@ -500,7 +500,7 @@ describe Spree::UnifiedPaymentsController do
|
|
500
500
|
|
501
501
|
it 'renders without layout' do
|
502
502
|
send_request({:xmlmsg => '<Message><Hash>Mymessage</Hash><PurchaseAmountScr>200</PurchaseAmountScr></Message>'})
|
503
|
-
response.should render_template(:approved
|
503
|
+
response.should render_template(:approved)
|
504
504
|
end
|
505
505
|
end
|
506
506
|
end
|
@@ -15,8 +15,8 @@ describe Spree::Order do
|
|
15
15
|
UnifiedPayment::Transaction.any_instance.stub(:assign_attributes_using_xml).and_return(true)
|
16
16
|
UnifiedPayment::Transaction.any_instance.stub(:complete_order).and_return(true)
|
17
17
|
UnifiedPayment::Transaction.any_instance.stub(:notify_user_on_transaction_status).and_return(true)
|
18
|
-
@successful_card_transaction = @order.unified_transactions.create!(:status => 'successful', :payment_transaction_id => '1234')
|
19
|
-
@pending_card_transaction = @order.unified_transactions.create!(:status => 'pending', :payment_transaction_id => '1234')
|
18
|
+
@successful_card_transaction = @order.unified_transactions.create!(:status => 'successful', :payment_transaction_id => '1234', :amount => 100)
|
19
|
+
@pending_card_transaction = @order.unified_transactions.create!(:status => 'pending', :payment_transaction_id => '1234', :amount => 100)
|
20
20
|
end
|
21
21
|
|
22
22
|
it { @order.pending_card_transaction.should eq(@pending_card_transaction) }
|
@@ -131,7 +131,7 @@ describe Spree::Order do
|
|
131
131
|
@order_updater.stub(:update_payment_state).and_return(true)
|
132
132
|
@order_updater.stub(:run_hooks).and_return(true)
|
133
133
|
@state_changes = []
|
134
|
-
@state_changes.stub(:create).with({:previous_state=>'confirm', :next_state=>"complete", :name=>"order", :user_id=>user.id}
|
134
|
+
@state_changes.stub(:create).with({:previous_state=>'confirm', :next_state=>"complete", :name=>"order", :user_id=>user.id}).and_return(true)
|
135
135
|
|
136
136
|
@order.stub(:state_changes).and_return(@state_changes)
|
137
137
|
@order.stub(:previous_states).and_return([:delivery, :payment, :confirm])
|
@@ -176,7 +176,7 @@ describe Spree::Order do
|
|
176
176
|
end
|
177
177
|
|
178
178
|
it 'stores state changes' do
|
179
|
-
@state_changes.should_receive(:create).with({:previous_state=>'confirm', :next_state=>"complete", :name=>"order", :user_id=>user.id}
|
179
|
+
@state_changes.should_receive(:create).with({:previous_state=>'confirm', :next_state=>"complete", :name=>"order", :user_id=>user.id}).and_return(true)
|
180
180
|
@order.finalize!
|
181
181
|
end
|
182
182
|
|
@@ -194,7 +194,7 @@ describe Spree::Order do
|
|
194
194
|
context 'when orders last state was not confirm' do
|
195
195
|
before do
|
196
196
|
@order.stub(:previous_states).and_return([:delivery, :payment])
|
197
|
-
@state_changes.stub(:create).with({:previous_state=>"payment", :next_state=>"complete", :name=>"order", :user_id=>user.id}
|
197
|
+
@state_changes.stub(:create).with({:previous_state=>"payment", :next_state=>"complete", :name=>"order", :user_id=>user.id}).and_return(true)
|
198
198
|
end
|
199
199
|
|
200
200
|
it 'reserves stock' do
|
@@ -203,4 +203,13 @@ describe Spree::Order do
|
|
203
203
|
end
|
204
204
|
end
|
205
205
|
end
|
206
|
+
|
207
|
+
describe '#total_eql?' do
|
208
|
+
before do
|
209
|
+
@order.stub(:total).and_return(100)
|
210
|
+
end
|
211
|
+
|
212
|
+
it { @order.should be_total_eql('100') }
|
213
|
+
it { @order.should_not be_total_eql('50') }
|
214
|
+
end
|
206
215
|
end
|
@@ -1,11 +1,5 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Spree::StoreCredit do
|
4
|
-
describe 'attr-accessible' do
|
5
|
-
[:balance, :user, :transactioner, :type].each do |attribute|
|
6
|
-
it { should allow_mass_assignment_of attribute }
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
4
|
it { should belong_to(:unified_transaction).class_name('UnifiedPayment::Transaction').with_foreign_key('unified_transaction_id') }
|
11
5
|
end
|
@@ -1,16 +1,11 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe UnifiedPayment::Transaction do
|
4
|
-
|
5
|
-
[:gateway_order_status, :amount, :currency, :response_status, :pan, :response_description, :order_description, :xml_response, :status].each do |attribute|
|
6
|
-
it { should allow_mass_assignment_of attribute }
|
7
|
-
end
|
8
|
-
|
9
4
|
it { should belong_to(:user).class_name('Spree::User') }
|
10
5
|
it { should belong_to(:order).class_name('Spree::Order') }
|
11
6
|
|
12
7
|
it { should have_one(:store_credit).class_name('Spree::StoreCredit') }
|
13
|
-
let(:order) {
|
8
|
+
let(:order) { Spree::Order.create! }
|
14
9
|
let(:user) { mock_model(Spree::User) }
|
15
10
|
|
16
11
|
before do
|
@@ -28,7 +23,7 @@ describe UnifiedPayment::Transaction do
|
|
28
23
|
context 'after and before save' do
|
29
24
|
context 'pending transaction on creation' do
|
30
25
|
before do
|
31
|
-
@pending_card_transaction = UnifiedPayment::Transaction.new(:status => 'pending', :payment_transaction_id => '1234')
|
26
|
+
@pending_card_transaction = UnifiedPayment::Transaction.new(:status => 'pending', :payment_transaction_id => '1234', :amount => 100)
|
32
27
|
end
|
33
28
|
|
34
29
|
it { @pending_card_transaction.should_not_receive(:notify_user_on_transaction_status) }
|
@@ -45,7 +40,7 @@ describe UnifiedPayment::Transaction do
|
|
45
40
|
|
46
41
|
context 'pending to successful transaction' do
|
47
42
|
before do
|
48
|
-
@successful_card_transaction = UnifiedPayment::Transaction.new(:status => 'pending', :payment_transaction_id => '1234')
|
43
|
+
@successful_card_transaction = UnifiedPayment::Transaction.new(:status => 'pending', :payment_transaction_id => '1234', :amount => 100)
|
49
44
|
@successful_card_transaction.save!
|
50
45
|
@successful_card_transaction.status = 'successful'
|
51
46
|
end
|
@@ -95,7 +90,7 @@ describe UnifiedPayment::Transaction do
|
|
95
90
|
|
96
91
|
context 'pending to unsuccessful transaction' do
|
97
92
|
before do
|
98
|
-
@unsuccessful_card_transaction = UnifiedPayment::Transaction.new(:status => 'pending', :payment_transaction_id => '1234')
|
93
|
+
@unsuccessful_card_transaction = UnifiedPayment::Transaction.new(:status => 'pending', :payment_transaction_id => '1234', :amount => 100)
|
99
94
|
@unsuccessful_card_transaction.save!
|
100
95
|
@unsuccessful_card_transaction.status = 'unsuccessful'
|
101
96
|
end
|
@@ -120,8 +115,8 @@ describe UnifiedPayment::Transaction do
|
|
120
115
|
|
121
116
|
context 'expire transaction' do
|
122
117
|
before do
|
123
|
-
@pending_card_transaction = UnifiedPayment::Transaction.create!(:status => 'pending', :payment_transaction_id => '1234')
|
124
|
-
@expired_card_transaction = UnifiedPayment::Transaction.create!(:status => 'unsuccessful', :payment_transaction_id => '1234')
|
118
|
+
@pending_card_transaction = UnifiedPayment::Transaction.create!(:status => 'pending', :payment_transaction_id => '1234', :amount => 100)
|
119
|
+
@expired_card_transaction = UnifiedPayment::Transaction.create!(:status => 'unsuccessful', :payment_transaction_id => '1234', :amount => 100)
|
125
120
|
@expired_card_transaction.expired_at = Time.current
|
126
121
|
@expired_card_transaction.save!
|
127
122
|
end
|
@@ -147,8 +142,8 @@ describe UnifiedPayment::Transaction do
|
|
147
142
|
context 'scopes' do
|
148
143
|
describe 'pending' do
|
149
144
|
before do
|
150
|
-
@successful_card_transaction = UnifiedPayment::Transaction.create!(:status => 'successful', :payment_transaction_id => '1234')
|
151
|
-
@pending_card_transaction = UnifiedPayment::Transaction.create!(:status => 'pending', :payment_transaction_id => '1234')
|
145
|
+
@successful_card_transaction = UnifiedPayment::Transaction.create!(:status => 'successful', :payment_transaction_id => '1234', :amount => 100)
|
146
|
+
@pending_card_transaction = UnifiedPayment::Transaction.create!(:status => 'pending', :payment_transaction_id => '1234', :amount => 100)
|
152
147
|
end
|
153
148
|
|
154
149
|
it { UnifiedPayment::Transaction.pending.should eq([@pending_card_transaction]) }
|
@@ -169,12 +164,12 @@ describe UnifiedPayment::Transaction do
|
|
169
164
|
describe '#assign_attributes_using_xml' do
|
170
165
|
before do
|
171
166
|
UnifiedPayment::Transaction.any_instance.unstub(:assign_attributes_using_xml)
|
172
|
-
@card_transaction_with_message = UnifiedPayment::Transaction.create!(:payment_transaction_id => '123321')
|
167
|
+
@card_transaction_with_message = UnifiedPayment::Transaction.create!(:payment_transaction_id => '123321', :amount => 100)
|
173
168
|
@xml_response = '<Message><PAN>123XXX123</PAN><PurchaseAmountScr>200</PurchaseAmountScr><Currency>NGN</Currency><ResponseDescription>TestDescription</ResponseDescription><OrderStatus>OnTest</OrderStatus><OrderDescription>TestOrder</OrderDescription><Status>00</Status><MerchantTranID>12345654321</MerchantTranID><ApprovalCode>123ABC</ApprovalCode></Message>'
|
174
169
|
@card_transaction_with_message.stub(:xml_response).and_return(@xml_response)
|
175
170
|
@gateway_transaction = UnifiedPayment::Transaction.new
|
176
171
|
@card_transaction_with_message.stub(:gateway_transaction).and_return(@gateway_transaction)
|
177
|
-
@card_transaction_without_message = UnifiedPayment::Transaction.new
|
172
|
+
@card_transaction_without_message = UnifiedPayment::Transaction.new
|
178
173
|
end
|
179
174
|
|
180
175
|
describe 'method calls' do
|
@@ -201,7 +196,7 @@ describe UnifiedPayment::Transaction do
|
|
201
196
|
describe '#notify_user_on_transaction_status' do
|
202
197
|
before do
|
203
198
|
UnifiedPayment::Transaction.any_instance.unstub(:notify_user_on_transaction_status)
|
204
|
-
@card_transaction = UnifiedPayment::Transaction.new(:status => 'pending', :payment_transaction_id => '1234')
|
199
|
+
@card_transaction = UnifiedPayment::Transaction.new(:status => 'pending', :payment_transaction_id => '1234', :amount => 100)
|
205
200
|
@mailer_object = Object.new
|
206
201
|
@mailer_object.stub(:deliver!).and_return(true)
|
207
202
|
Spree::TransactionNotificationMailer.stub(:delay).and_return(Spree::TransactionNotificationMailer)
|
@@ -230,12 +225,13 @@ describe UnifiedPayment::Transaction do
|
|
230
225
|
describe '#complete_order' do
|
231
226
|
before do
|
232
227
|
UnifiedPayment::Transaction.any_instance.unstub(:complete_order)
|
233
|
-
@card_transaction = UnifiedPayment::Transaction.new(:status => 'successful', :payment_transaction_id => '1234')
|
228
|
+
@card_transaction = UnifiedPayment::Transaction.new(:status => 'successful', :payment_transaction_id => '1234', :amount => '100')
|
234
229
|
@card_transaction.stub(:order).and_return(order)
|
235
230
|
order.stub(:next!).and_return(true)
|
236
231
|
@payment = mock_model(Spree::Payment)
|
237
232
|
@payment.stub(:complete).and_return(true)
|
238
233
|
order.stub(:pending_payments).and_return([@payment])
|
234
|
+
order.stub(:total).and_return(100)
|
239
235
|
end
|
240
236
|
|
241
237
|
it { order.should_receive(:next!).and_return(true) }
|
@@ -250,7 +246,7 @@ describe UnifiedPayment::Transaction do
|
|
250
246
|
describe '#cancel_order' do
|
251
247
|
before do
|
252
248
|
UnifiedPayment::Transaction.any_instance.unstub(:cancel_order)
|
253
|
-
@card_transaction = UnifiedPayment::Transaction.new(:status => 'unsuccessful', :payment_transaction_id => '1234')
|
249
|
+
@card_transaction = UnifiedPayment::Transaction.new(:status => 'unsuccessful', :payment_transaction_id => '1234', :amount => 100)
|
254
250
|
@card_transaction.stub(:order).and_return(order)
|
255
251
|
order.stub(:release_inventory).and_return(true)
|
256
252
|
@payment = mock_model(Spree::Payment)
|
@@ -322,7 +318,7 @@ describe UnifiedPayment::Transaction do
|
|
322
318
|
before do
|
323
319
|
@time_now = DateTime.strptime('2012-03-03', '%Y-%m-%d')
|
324
320
|
Time.stub(:current).and_return(@time_now)
|
325
|
-
@card_transaction = UnifiedPayment::Transaction.new(:status => 'somestatus', :payment_transaction_id => '1234')
|
321
|
+
@card_transaction = UnifiedPayment::Transaction.new(:status => 'somestatus', :payment_transaction_id => '1234', :amount => 100)
|
326
322
|
@card_transaction.stub(:release_order_inventory).and_return(true)
|
327
323
|
end
|
328
324
|
|
@@ -339,9 +335,9 @@ describe UnifiedPayment::Transaction do
|
|
339
335
|
|
340
336
|
describe 'status checks for pening, unsuccessful and successful' do
|
341
337
|
before do
|
342
|
-
@successful_card_transaction = UnifiedPayment::Transaction.create!(:status => 'successful', :payment_transaction_id => '1234')
|
343
|
-
@pending_card_transaction = UnifiedPayment::Transaction.create!(:status => 'pending', :payment_transaction_id => '1234')
|
344
|
-
@unsuccessful_card_transaction = UnifiedPayment::Transaction.create!(:status => 'unsuccessful', :payment_transaction_id => '1234')
|
338
|
+
@successful_card_transaction = UnifiedPayment::Transaction.create!(:status => 'successful', :payment_transaction_id => '1234', :amount => 100)
|
339
|
+
@pending_card_transaction = UnifiedPayment::Transaction.create!(:status => 'pending', :payment_transaction_id => '1234', :amount => 100)
|
340
|
+
@unsuccessful_card_transaction = UnifiedPayment::Transaction.create!(:status => 'unsuccessful', :payment_transaction_id => '1234', :amount => 100)
|
345
341
|
end
|
346
342
|
|
347
343
|
it { @successful_card_transaction.pending?.should be_false }
|
@@ -420,7 +416,7 @@ describe UnifiedPayment::Transaction do
|
|
420
416
|
|
421
417
|
describe '#associate_user' do
|
422
418
|
before do
|
423
|
-
@card_transaction = UnifiedPayment::Transaction.create!(:payment_transaction_id => '123454321')
|
419
|
+
@card_transaction = UnifiedPayment::Transaction.create!(:payment_transaction_id => '123454321', :amount => 100)
|
424
420
|
@card_transaction.stub(:order).and_return(order)
|
425
421
|
order.stub(:email).and_return('test_user@baloo.com')
|
426
422
|
@card_transaction.stub(:save!).and_return(true)
|
@@ -466,7 +462,7 @@ describe UnifiedPayment::Transaction do
|
|
466
462
|
end
|
467
463
|
|
468
464
|
describe '#update_transaction_on_query' do
|
469
|
-
before { @card_transaction = UnifiedPayment::Transaction.create!(:payment_transaction_id => '123454321') }
|
465
|
+
before { @card_transaction = UnifiedPayment::Transaction.create!(:payment_transaction_id => '123454321', :amount => 100) }
|
470
466
|
|
471
467
|
context 'status is APPROVED' do
|
472
468
|
it { @card_transaction.should_receive(:assign_attributes).with(:gateway_order_status => 'APPROVED', :status => 'successful').and_return(true) }
|
data/spec/spec_helper.rb
CHANGED
@@ -17,11 +17,6 @@ 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
|
-
|
25
20
|
RSpec.configure do |config|
|
26
21
|
# ## Mock Framework
|
27
22
|
#
|
@@ -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
|
4
|
+
s.version = "1.1.0"
|
5
5
|
s.author = ["Manish Kangia", "Sushant Mittal"]
|
6
6
|
s.email = 'info@vinsol.com'
|
7
7
|
s.homepage = 'http://vinsol.com'
|
@@ -16,8 +16,8 @@ Gem::Specification.new do |s|
|
|
16
16
|
s.require_path = 'lib'
|
17
17
|
s.requirements << 'none'
|
18
18
|
|
19
|
-
s.add_dependency('spree_core', '~> 2.
|
20
|
-
s.add_dependency 'unified_payment', '1.0.
|
21
|
-
s.add_dependency 'spree_wallet', '~> 2.0
|
19
|
+
s.add_dependency('spree_core', '~> 2.1.0')
|
20
|
+
s.add_dependency 'unified_payment', '1.0.2'
|
21
|
+
s.add_dependency 'spree_wallet', '~> 2.1.0'
|
22
22
|
s.add_dependency 'delayed_job_active_record', '~> 4.0.0'
|
23
23
|
end
|
metadata
CHANGED
@@ -5,9 +5,9 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
|
+
- 1
|
8
9
|
- 0
|
9
|
-
|
10
|
-
version: 1.0.2
|
10
|
+
version: 1.1.0
|
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-03-
|
19
|
+
date: 2014-03-28 00:00:00 Z
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
22
|
name: spree_core
|
@@ -26,12 +26,12 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
hash:
|
29
|
+
hash: 11
|
30
30
|
segments:
|
31
31
|
- 2
|
32
|
+
- 1
|
32
33
|
- 0
|
33
|
-
|
34
|
-
version: 2.0.0
|
34
|
+
version: 2.1.0
|
35
35
|
type: :runtime
|
36
36
|
version_requirements: *id001
|
37
37
|
- !ruby/object:Gem::Dependency
|
@@ -42,12 +42,12 @@ dependencies:
|
|
42
42
|
requirements:
|
43
43
|
- - "="
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
hash:
|
45
|
+
hash: 19
|
46
46
|
segments:
|
47
47
|
- 1
|
48
48
|
- 0
|
49
|
-
-
|
50
|
-
version: 1.0.
|
49
|
+
- 2
|
50
|
+
version: 1.0.2
|
51
51
|
type: :runtime
|
52
52
|
version_requirements: *id002
|
53
53
|
- !ruby/object:Gem::Dependency
|
@@ -58,12 +58,12 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - ~>
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
hash:
|
61
|
+
hash: 11
|
62
62
|
segments:
|
63
63
|
- 2
|
64
|
+
- 1
|
64
65
|
- 0
|
65
|
-
|
66
|
-
version: 2.0.3
|
66
|
+
version: 2.1.0
|
67
67
|
type: :runtime
|
68
68
|
version_requirements: *id003
|
69
69
|
- !ruby/object:Gem::Dependency
|