spree_gateway 2.0.1 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- metadata +35 -93
- data/.gitignore +0 -14
- data/.rspec +0 -1
- data/.travis.yml +0 -22
- data/Gemfile +0 -14
- data/LICENSE +0 -26
- data/README.md +0 -68
- data/Rakefile +0 -14
- data/Versionfile +0 -12
- data/app/controllers/spree/checkout_controller_decorator.rb +0 -51
- data/app/controllers/spree/skrill_status_controller.rb +0 -39
- data/app/models/spree/billing_integration/skrill/quick_checkout.rb +0 -52
- data/app/models/spree/gateway/authorize_net.rb +0 -18
- data/app/models/spree/gateway/authorize_net_cim.rb +0 -134
- data/app/models/spree/gateway/balanced_gateway.rb +0 -68
- data/app/models/spree/gateway/banwire.rb +0 -16
- data/app/models/spree/gateway/beanstream.rb +0 -195
- data/app/models/spree/gateway/braintree_gateway.rb +0 -143
- data/app/models/spree/gateway/card_save.rb +0 -12
- data/app/models/spree/gateway/data_cash.rb +0 -12
- data/app/models/spree/gateway/eway.rb +0 -22
- data/app/models/spree/gateway/fatzebra.rb +0 -17
- data/app/models/spree/gateway/klarna.rb +0 -0
- data/app/models/spree/gateway/linkpoint.rb +0 -30
- data/app/models/spree/gateway/moneris.rb +0 -13
- data/app/models/spree/gateway/pay_junction.rb +0 -18
- data/app/models/spree/gateway/pay_pal_gateway.rb +0 -14
- data/app/models/spree/gateway/payflow_pro.rb +0 -19
- data/app/models/spree/gateway/paymill.rb +0 -15
- data/app/models/spree/gateway/pin_gateway.rb +0 -18
- data/app/models/spree/gateway/sage_pay.rb +0 -13
- data/app/models/spree/gateway/samurai.rb +0 -65
- data/app/models/spree/gateway/secure_pay_au.rb +0 -10
- data/app/models/spree/gateway/stripe_gateway.rb +0 -94
- data/app/models/spree/gateway/usa_epay.rb +0 -11
- data/app/models/spree/gateway/worldpay.rb +0 -96
- data/app/models/spree/payment_decorator.rb +0 -3
- data/app/models/spree/skrill_transaction.rb +0 -21
- data/app/views/spree/admin/payments/source_forms/_quickcheckout.html.erb +0 -8
- data/app/views/spree/admin/payments/source_views/_quickcheckout.html.erb +0 -39
- data/app/views/spree/checkout/payment/_quickcheckout.html.erb +0 -26
- data/config/locales/bg.yml +0 -11
- data/config/locales/de.yml +0 -11
- data/config/locales/en.yml +0 -11
- data/config/locales/sv.yml +0 -11
- data/config/routes.rb +0 -13
- data/db/migrate/20111118164631_create_skrill_transactions.rb +0 -14
- data/db/migrate/20121017004102_update_braintree_payment_method_type.rb +0 -9
- data/db/migrate/20130213222555_update_stripe_payment_method_type.rb +0 -9
- data/db/migrate/20130415222802_update_balanced_payment_method_type.rb +0 -9
- data/db/migrate/20131008221012_update_paypal_payment_method_type.rb +0 -9
- data/lib/active_merchant/billing/skrill.rb +0 -18
- data/lib/generators/spree_gateway/install/install_generator.rb +0 -28
- data/lib/spree_gateway/engine.rb +0 -41
- data/lib/spree_gateway.rb +0 -3
- data/script/rails +0 -5
- data/spec/factories/payment_method_factory.rb +0 -4
- data/spec/models/gateway/authorize_net_cim_spec.rb +0 -17
- data/spec/models/gateway/authorize_net_spec.rb +0 -17
- data/spec/models/gateway/balanced_gateway_spec.rb +0 -9
- data/spec/models/gateway/banwire_spec.rb +0 -9
- data/spec/models/gateway/braintree_gateway_spec.rb +0 -284
- data/spec/models/gateway/eway_spec.rb +0 -17
- data/spec/models/gateway/fatzebra_spec.rb +0 -47
- data/spec/models/gateway/linkpoint_spec.rb +0 -60
- data/spec/models/gateway/pay_junction_spec.rb +0 -17
- data/spec/models/gateway/payflow_pro_spec.rb +0 -17
- data/spec/models/gateway/pin_gateway_spec.rb +0 -57
- data/spec/models/gateway/stripe_gateway_spec.rb +0 -122
- data/spec/models/gateway/usa_epay_spec.rb +0 -38
- data/spec/spec_helper.rb +0 -34
- data/spree_gateway.gemspec +0 -26
@@ -1,284 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Spree::Gateway::BraintreeGateway do
|
4
|
-
|
5
|
-
before(:each) do
|
6
|
-
Spree::Gateway.update_all :active => false
|
7
|
-
@gateway = Spree::Gateway::BraintreeGateway.create!(:name => "Braintree Gateway", :environment => "sandbox", :active => true)
|
8
|
-
|
9
|
-
@gateway.set_preference(:environment, "sandbox" )
|
10
|
-
@gateway.set_preference(:merchant_id, "zbn5yzq9t7wmwx42" )
|
11
|
-
@gateway.set_preference(:public_key, "ym9djwqpkxbv3xzt")
|
12
|
-
@gateway.set_preference(:private_key, "4ghghkyp2yy6yqc8")
|
13
|
-
@gateway.save!
|
14
|
-
|
15
|
-
with_payment_profiles_off do
|
16
|
-
@country = FactoryGirl.create(:country, :name => "United States", :iso_name => "UNITED STATES", :iso3 => "USA", :iso => "US", :numcode => 840)
|
17
|
-
@state = FactoryGirl.create(:state, :name => "Maryland", :abbr => "MD", :country => @country)
|
18
|
-
@address = FactoryGirl.create(:address,
|
19
|
-
:firstname => 'John',
|
20
|
-
:lastname => 'Doe',
|
21
|
-
:address1 => '1234 My Street',
|
22
|
-
:address2 => 'Apt 1',
|
23
|
-
:city => 'Washington DC',
|
24
|
-
:zipcode => '20123',
|
25
|
-
:phone => '(555)555-5555',
|
26
|
-
:state => @state,
|
27
|
-
:country => @country
|
28
|
-
)
|
29
|
-
@order = FactoryGirl.create(:order_with_totals, :bill_address => @address, :ship_address => @address)
|
30
|
-
@order.update!
|
31
|
-
@credit_card = FactoryGirl.create(:credit_card, :verification_value => '123', :number => '5105105105105100', :month => 9, :year => Time.now.year + 1, :first_name => 'John', :last_name => 'Doe', :cc_type => 'master')
|
32
|
-
@payment = FactoryGirl.create(:payment, :source => @credit_card, :order => @order, :payment_method => @gateway, :amount => 10.00)
|
33
|
-
@payment.payment_method.environment = "test"
|
34
|
-
end
|
35
|
-
|
36
|
-
end
|
37
|
-
|
38
|
-
describe 'merchant_account_id' do
|
39
|
-
context 'with merchant_account_id set on gateway' do
|
40
|
-
let(:merchant_account_id) { 'test' }
|
41
|
-
|
42
|
-
before do
|
43
|
-
@gateway.set_preference(:merchant_account_id, merchant_account_id)
|
44
|
-
end
|
45
|
-
|
46
|
-
it 'should have a perferred_merchant_account_id' do
|
47
|
-
@gateway.preferred_merchant_account_id.should == merchant_account_id
|
48
|
-
end
|
49
|
-
|
50
|
-
it 'should have a preferences[:merchant_account_id]' do
|
51
|
-
@gateway.preferences.keys.include?(:merchant_account_id).should be_true
|
52
|
-
end
|
53
|
-
|
54
|
-
it 'should adjust options to include merchant_account_id' do
|
55
|
-
options = {}
|
56
|
-
@gateway.should_receive(:adjust_billing_address).once
|
57
|
-
@gateway.send(:adjust_options_for_braintree, double, options)
|
58
|
-
options['merchant_account_id'].should == merchant_account_id
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
it "should be braintree gateway" do
|
64
|
-
@gateway.provider_class.should == ::ActiveMerchant::Billing::BraintreeBlueGateway
|
65
|
-
end
|
66
|
-
|
67
|
-
describe "preferences" do
|
68
|
-
it "should not include server + test_mode" do
|
69
|
-
lambda { @gateway.preferences.fetch(:server) }.should raise_error(StandardError)
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
describe "authorize" do
|
74
|
-
it "should return a success response with an authorization code" do
|
75
|
-
result = @gateway.authorize(500, @credit_card)
|
76
|
-
|
77
|
-
result.success?.should be_true
|
78
|
-
result.authorization.should match(/\A\w{6}\z/)
|
79
|
-
|
80
|
-
|
81
|
-
Braintree::Transaction::Status::Authorized.should == Braintree::Transaction.find(result.authorization).status
|
82
|
-
end
|
83
|
-
|
84
|
-
shared_examples "a valid credit card" do
|
85
|
-
it 'should work through the spree payment interface' do
|
86
|
-
Spree::Config.set :auto_capture => false
|
87
|
-
@payment.log_entries.size.should == 0
|
88
|
-
@payment.process!
|
89
|
-
@payment.log_entries.size.should == 1
|
90
|
-
@payment.response_code.should match /\A\w{6}\z/
|
91
|
-
@payment.state.should == 'pending'
|
92
|
-
transaction = ::Braintree::Transaction.find(@payment.response_code)
|
93
|
-
transaction.status.should == Braintree::Transaction::Status::Authorized
|
94
|
-
card_number = @credit_card.number[0..5] + "******" + @credit_card.number[-4..-1]
|
95
|
-
transaction.credit_card_details.masked_number.should == card_number
|
96
|
-
transaction.credit_card_details.expiration_date.should == "09/#{Time.now.year + 1}"
|
97
|
-
transaction.customer_details.first_name.should == 'John'
|
98
|
-
transaction.customer_details.last_name.should == 'Doe'
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
context "when the card is a mastercard" do
|
103
|
-
before do
|
104
|
-
@credit_card.number = '5105105105105100'
|
105
|
-
@credit_card.cc_type = 'master'
|
106
|
-
@credit_card.save
|
107
|
-
end
|
108
|
-
|
109
|
-
it_behaves_like "a valid credit card"
|
110
|
-
end
|
111
|
-
|
112
|
-
context "when the card is a visa" do
|
113
|
-
before do
|
114
|
-
@credit_card.number = '4111111111111111'
|
115
|
-
@credit_card.cc_type = 'visa'
|
116
|
-
@credit_card.save
|
117
|
-
end
|
118
|
-
|
119
|
-
it_behaves_like "a valid credit card"
|
120
|
-
end
|
121
|
-
|
122
|
-
context "when the card is an amex" do
|
123
|
-
before do
|
124
|
-
@credit_card.number = '378282246310005'
|
125
|
-
@credit_card.verification_value = '1234'
|
126
|
-
@credit_card.cc_type = 'american_express'
|
127
|
-
@credit_card.save
|
128
|
-
end
|
129
|
-
|
130
|
-
it_behaves_like "a valid credit card"
|
131
|
-
end
|
132
|
-
|
133
|
-
context "when the card is a JCB" do
|
134
|
-
before do
|
135
|
-
@credit_card.number = '3530111333300000'
|
136
|
-
@credit_card.cc_type = 'jcb'
|
137
|
-
@credit_card.save
|
138
|
-
end
|
139
|
-
|
140
|
-
it_behaves_like "a valid credit card"
|
141
|
-
end
|
142
|
-
|
143
|
-
context "when the card is a diners club" do
|
144
|
-
before do
|
145
|
-
@credit_card.number = '36050000000003'
|
146
|
-
@credit_card.cc_type = 'diners_club'
|
147
|
-
@credit_card.save
|
148
|
-
end
|
149
|
-
|
150
|
-
it_behaves_like "a valid credit card"
|
151
|
-
end
|
152
|
-
end
|
153
|
-
|
154
|
-
describe "capture" do
|
155
|
-
|
156
|
-
it " should capture a previous authorization" do
|
157
|
-
@payment.process!
|
158
|
-
assert_equal 1, @payment.log_entries.size
|
159
|
-
assert_match /\A\w{6}\z/, @payment.response_code
|
160
|
-
transaction = ::Braintree::Transaction.find(@payment.response_code)
|
161
|
-
transaction.status.should == Braintree::Transaction::Status::Authorized
|
162
|
-
capture_result = @gateway.capture(@payment,:ignored_arg_credit_card, :ignored_arg_options)
|
163
|
-
capture_result.success?.should be_true
|
164
|
-
transaction = ::Braintree::Transaction.find(@payment.response_code)
|
165
|
-
transaction.status.should == Braintree::Transaction::Status::SubmittedForSettlement
|
166
|
-
end
|
167
|
-
|
168
|
-
pending "raise an error if capture fails using spree interface" do
|
169
|
-
Spree::Config.set :auto_capture => false
|
170
|
-
@payment.log_entries.size.should == 0
|
171
|
-
@payment.process!
|
172
|
-
@payment.log_entries.size.should == 1
|
173
|
-
transaction = ::Braintree::Transaction.find(@payment.response_code)
|
174
|
-
transaction.status.should == Braintree::Transaction::Status::Authorized
|
175
|
-
@payment.payment_source.capture(@payment) # as done in PaymentsController#fire
|
176
|
-
# transaction = ::Braintree::Transaction.find(@payment.response_code)
|
177
|
-
# transaction.status.should == Braintree::Transaction::Status::SubmittedForSettlement
|
178
|
-
# lambda do
|
179
|
-
# @payment.payment_source.capture(@payment)
|
180
|
-
# end.should raise_error(Spree::Core::GatewayError, "Cannot submit for settlement unless status is authorized. (91507)")
|
181
|
-
end
|
182
|
-
end
|
183
|
-
|
184
|
-
describe 'purchase' do
|
185
|
-
it 'should return a success response with an authorization code' do
|
186
|
-
result = @gateway.purchase(500, @credit_card)
|
187
|
-
result.success?.should be_true
|
188
|
-
result.authorization.should match(/\A\w{6}\z/)
|
189
|
-
Braintree::Transaction::Status::SubmittedForSettlement.should == Braintree::Transaction.find(result.authorization).status
|
190
|
-
end
|
191
|
-
|
192
|
-
it 'should work through the spree payment interface with payment profiles' do
|
193
|
-
purchase_using_spree_interface
|
194
|
-
transaction = ::Braintree::Transaction.find(@payment.response_code)
|
195
|
-
transaction.credit_card_details.token.should_not be_nil
|
196
|
-
end
|
197
|
-
|
198
|
-
it 'should work through the spree payment interface without payment profiles' do
|
199
|
-
with_payment_profiles_off do
|
200
|
-
purchase_using_spree_interface(false)
|
201
|
-
transaction = ::Braintree::Transaction.find(@payment.response_code)
|
202
|
-
transaction.credit_card_details.token.should be_nil
|
203
|
-
end
|
204
|
-
end
|
205
|
-
end
|
206
|
-
|
207
|
-
describe "credit" do
|
208
|
-
pending "should work through the spree interface" do
|
209
|
-
@payment.amount += 100.00
|
210
|
-
purchase_using_spree_interface
|
211
|
-
credit_using_spree_interface
|
212
|
-
end
|
213
|
-
end
|
214
|
-
|
215
|
-
describe "void" do
|
216
|
-
pending "should work through the spree credit_card / payment interface" do
|
217
|
-
assert_equal 0, @payment.log_entries.size
|
218
|
-
@payment.process!
|
219
|
-
assert_equal 1, @payment.log_entries.size
|
220
|
-
@payment.response_code.should match(/\A\w{6}\z/)
|
221
|
-
transaction = Braintree::Transaction.find(@payment.response_code)
|
222
|
-
transaction.status.should == Braintree::Transaction::Status::SubmittedForSettlement
|
223
|
-
@credit_card.void(@payment)
|
224
|
-
transaction = Braintree::Transaction.find(transaction.id)
|
225
|
-
transaction.status.should == Braintree::Transaction::Status::Voided
|
226
|
-
end
|
227
|
-
end
|
228
|
-
|
229
|
-
describe "update_card_number" do
|
230
|
-
it "passes through gateway_payment_profile_id" do
|
231
|
-
credit_card = { 'token' => 'testing', 'last_4' => '1234', 'masked_number' => '5555**5555' }
|
232
|
-
@gateway.update_card_number(@payment.source, credit_card)
|
233
|
-
@payment.source.gateway_payment_profile_id.should == "testing"
|
234
|
-
end
|
235
|
-
end
|
236
|
-
|
237
|
-
def credit_using_spree_interface
|
238
|
-
@payment.log_entries.size.should == 1
|
239
|
-
@payment.source.credit(@payment) # as done in PaymentsController#fire
|
240
|
-
@payment.log_entries.size.should == 2
|
241
|
-
#Let's get the payment record associated with the credit
|
242
|
-
@payment = @order.payments.last
|
243
|
-
@payment.response_code.should match(/\A\w{6}\z/)
|
244
|
-
transaction = ::Braintree::Transaction.find(@payment.response_code)
|
245
|
-
transaction.type.should == Braintree::Transaction::Type::Credit
|
246
|
-
transaction.status.should == Braintree::Transaction::Status::SubmittedForSettlement
|
247
|
-
transaction.credit_card_details.masked_number.should == "510510******5100"
|
248
|
-
transaction.credit_card_details.expiration_date.should == "09/#{Time.now.year + 1}"
|
249
|
-
transaction.customer_details.first_name.should == "John"
|
250
|
-
transaction.customer_details.last_name.should == "Doe"
|
251
|
-
end
|
252
|
-
|
253
|
-
def purchase_using_spree_interface(profile=true)
|
254
|
-
Spree::Config.set :auto_capture => true
|
255
|
-
@payment.send(:create_payment_profile) if profile
|
256
|
-
@payment.log_entries.size == 0
|
257
|
-
@payment.process! # as done in PaymentsController#create
|
258
|
-
@payment.log_entries.size == 1
|
259
|
-
@payment.response_code.should match /\A\w{6}\z/
|
260
|
-
@payment.state.should == 'completed'
|
261
|
-
transaction = ::Braintree::Transaction.find(@payment.response_code)
|
262
|
-
Braintree::Transaction::Status::SubmittedForSettlement.should == transaction.status
|
263
|
-
transaction.credit_card_details.masked_number.should == "510510******5100"
|
264
|
-
transaction.credit_card_details.expiration_date.should == "09/#{Time.now.year + 1}"
|
265
|
-
transaction.customer_details.first_name.should == 'John'
|
266
|
-
transaction.customer_details.last_name.should == 'Doe'
|
267
|
-
end
|
268
|
-
|
269
|
-
def with_payment_profiles_off(&block)
|
270
|
-
Spree::Gateway::BraintreeGateway.class_eval do
|
271
|
-
def payment_profiles_supported?
|
272
|
-
false
|
273
|
-
end
|
274
|
-
end
|
275
|
-
yield
|
276
|
-
ensure
|
277
|
-
Spree::Gateway::BraintreeGateway.class_eval do
|
278
|
-
def payment_profiles_supported?
|
279
|
-
true
|
280
|
-
end
|
281
|
-
end
|
282
|
-
end
|
283
|
-
|
284
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Spree::Gateway::Eway do
|
4
|
-
let (:gateway) { Spree::Gateway::Eway.create!(:name => "Eway") }
|
5
|
-
|
6
|
-
describe "options" do
|
7
|
-
it "should include :test => true in when :test_mode is true" do
|
8
|
-
gateway.preferred_test_mode = true
|
9
|
-
gateway.options[:test].should == true
|
10
|
-
end
|
11
|
-
|
12
|
-
it "should not include :test when test_mode is false" do
|
13
|
-
gateway.preferred_test_mode = false
|
14
|
-
gateway.options[:test].should == false
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,47 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Spree::Gateway::Fatzebra do
|
4
|
-
|
5
|
-
before(:each) do
|
6
|
-
Spree::Gateway.update_all :active => false
|
7
|
-
@gateway = Spree::Gateway::Fatzebra.create!(:name => "Fat Zebra Gateway", :environment => "sandbox", :active => true)
|
8
|
-
|
9
|
-
@gateway.set_preference(:username, "TEST")
|
10
|
-
@gateway.set_preference(:token, "TEST")
|
11
|
-
@gateway.save!
|
12
|
-
|
13
|
-
@country = FactoryGirl.create(:country, :name => "Australia", :iso_name => "Australia", :iso3 => "AUS", :iso => "AU", :numcode => 61)
|
14
|
-
@state = FactoryGirl.create(:state, :name => "Victoria", :abbr => "VIC", :country => @country)
|
15
|
-
@address = FactoryGirl.create(:address,
|
16
|
-
:firstname => 'Ronald C',
|
17
|
-
:lastname => 'Robot',
|
18
|
-
:address1 => '1234 My Street',
|
19
|
-
:address2 => 'Apt 1',
|
20
|
-
:city => 'Melbourne',
|
21
|
-
:zipcode => '3000',
|
22
|
-
:phone => '88888888',
|
23
|
-
:state => @state,
|
24
|
-
:country => @country
|
25
|
-
)
|
26
|
-
@order = FactoryGirl.create(:order_with_totals, :bill_address => @address, :ship_address => @address, :last_ip_address => "127.0.0.1")
|
27
|
-
@order.update!
|
28
|
-
@credit_card = FactoryGirl.create(:credit_card,
|
29
|
-
:verification_value => '123',
|
30
|
-
:number => '5123456789012346',
|
31
|
-
:month => 5,
|
32
|
-
:year => Time.now.year + 1,
|
33
|
-
:first_name => 'Ronald C',
|
34
|
-
:last_name => 'Robot'
|
35
|
-
)
|
36
|
-
@payment = FactoryGirl.create(:payment,
|
37
|
-
:source => @credit_card,
|
38
|
-
:order => @order,
|
39
|
-
:payment_method => @gateway, :amount => 10.00)
|
40
|
-
@payment.payment_method.environment = "test"
|
41
|
-
end
|
42
|
-
|
43
|
-
it "can purchase" do
|
44
|
-
@payment.purchase!
|
45
|
-
@payment.state.should == 'completed'
|
46
|
-
end
|
47
|
-
end
|
@@ -1,60 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Spree::Gateway::Linkpoint do
|
4
|
-
let(:gateway) { Spree::Gateway::Linkpoint.create!(:name => "Linkpoint") }
|
5
|
-
let(:provider) { double('provider') }
|
6
|
-
let(:money) { double('money') }
|
7
|
-
let(:credit_card) { double('credit_card') }
|
8
|
-
let(:identification) { double('identification') }
|
9
|
-
let(:options) { { subtotal: 3, discount: -1 } }
|
10
|
-
|
11
|
-
before do
|
12
|
-
gateway.provider_class.stub(new: provider)
|
13
|
-
end
|
14
|
-
|
15
|
-
it "should be Linkpoint gateway" do
|
16
|
-
gateway.provider_class.should == ::ActiveMerchant::Billing::LinkpointGateway
|
17
|
-
end
|
18
|
-
|
19
|
-
describe "#authorize" do
|
20
|
-
it "adds the discount to the subtotal" do
|
21
|
-
provider.should_receive(:authorize)
|
22
|
-
.with(money, credit_card, subtotal: 2, discount: 0)
|
23
|
-
gateway.authorize(money, credit_card, options)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
describe "#purchase" do
|
28
|
-
it "adds the discount to the subtotal" do
|
29
|
-
provider.should_receive(:purchase)
|
30
|
-
.with(money, credit_card, subtotal: 2, discount: 0)
|
31
|
-
gateway.purchase(money, credit_card, options)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
describe "#capture" do
|
36
|
-
let(:authorization) { double('authorization') }
|
37
|
-
|
38
|
-
it "adds the discount to the subtotal" do
|
39
|
-
provider.should_receive(:capture)
|
40
|
-
.with(money, authorization, subtotal: 2, discount: 0)
|
41
|
-
gateway.capture(money, authorization, options)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
describe "#void" do
|
46
|
-
it "adds the discount to the subtotal" do
|
47
|
-
provider.should_receive(:void)
|
48
|
-
.with(identification, subtotal: 2, discount: 0)
|
49
|
-
gateway.void(identification, options)
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
describe "#credit" do
|
54
|
-
it "adds the discount to the subtotal" do
|
55
|
-
provider.should_receive(:credit)
|
56
|
-
.with(money, identification, subtotal: 2, discount: 0)
|
57
|
-
gateway.credit(money, identification, options)
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Spree::Gateway::PayJunction do
|
4
|
-
let (:gateway) { Spree::Gateway::PayJunction.create!(:name => "PayJunction") }
|
5
|
-
|
6
|
-
describe "options" do
|
7
|
-
it "should include :test => true in when :test_mode is true" do
|
8
|
-
gateway.preferred_test_mode = true
|
9
|
-
gateway.options[:test].should == true
|
10
|
-
end
|
11
|
-
|
12
|
-
it "should not include :test when test_mode is false" do
|
13
|
-
gateway.preferred_test_mode = false
|
14
|
-
gateway.options[:test].should == false
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Spree::Gateway::PayflowPro do
|
4
|
-
let (:gateway) { Spree::Gateway::PayflowPro.create!(:name => "PayflowPro") }
|
5
|
-
|
6
|
-
describe "options" do
|
7
|
-
it "should include :test => true when :test_mode is true" do
|
8
|
-
gateway.preferred_test_mode = true
|
9
|
-
gateway.options[:test].should == true
|
10
|
-
end
|
11
|
-
|
12
|
-
it "should not include :test when test_mode is false" do
|
13
|
-
gateway.preferred_test_mode = false
|
14
|
-
gateway.options[:test].should == false
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,57 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Spree::Gateway::PinGateway do
|
4
|
-
|
5
|
-
before(:each) do
|
6
|
-
Spree::Gateway.update_all :active => false
|
7
|
-
@gateway = Spree::Gateway::PinGateway.create!(:name => "Pin Gateway", :environment => "sandbox", :active => true)
|
8
|
-
|
9
|
-
@gateway.set_preference(:api_key, "W_VzkRCZSILiKWUS-dndUg" )
|
10
|
-
@gateway.save!
|
11
|
-
|
12
|
-
@country = FactoryGirl.create(:country, :name => "Australia", :iso_name => "Australia", :iso3 => "AUS", :iso => "AU", :numcode => 61)
|
13
|
-
@state = FactoryGirl.create(:state, :name => "Victoria", :abbr => "VIC", :country => @country)
|
14
|
-
@address = FactoryGirl.create(:address,
|
15
|
-
:firstname => 'Ronald C',
|
16
|
-
:lastname => 'Robot',
|
17
|
-
:address1 => '1234 My Street',
|
18
|
-
:address2 => 'Apt 1',
|
19
|
-
:city => 'Melbourne',
|
20
|
-
:zipcode => '3000',
|
21
|
-
:phone => '88888888',
|
22
|
-
:state => @state,
|
23
|
-
:country => @country
|
24
|
-
)
|
25
|
-
@order = FactoryGirl.create(:order_with_totals, :bill_address => @address, :ship_address => @address)
|
26
|
-
@order.update!
|
27
|
-
@credit_card = FactoryGirl.create(:credit_card,
|
28
|
-
:verification_value => '123',
|
29
|
-
:number => '5520000000000000',
|
30
|
-
:month => 5,
|
31
|
-
:year => Time.now.year + 1,
|
32
|
-
:first_name => 'Ronald C',
|
33
|
-
:last_name => 'Robot',
|
34
|
-
:cc_type => 'master'
|
35
|
-
)
|
36
|
-
@payment = FactoryGirl.create(:payment,
|
37
|
-
:source => @credit_card,
|
38
|
-
:order => @order,
|
39
|
-
:payment_method => @gateway, :amount => 10.00)
|
40
|
-
@payment.payment_method.environment = "test"
|
41
|
-
end
|
42
|
-
|
43
|
-
it "can purchase" do
|
44
|
-
@payment.purchase!
|
45
|
-
@payment.state.should == 'completed'
|
46
|
-
end
|
47
|
-
|
48
|
-
# Regression test for #106
|
49
|
-
it "uses auto capturing" do
|
50
|
-
expect(@gateway.auto_capture?).to be_true
|
51
|
-
end
|
52
|
-
|
53
|
-
it "always uses purchase" do
|
54
|
-
@payment.should_receive(:purchase!)
|
55
|
-
@payment.process!
|
56
|
-
end
|
57
|
-
end
|
@@ -1,122 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Spree::Gateway::StripeGateway do
|
4
|
-
let(:login) { 'nothing' }
|
5
|
-
let(:email) { 'customer@example.com' }
|
6
|
-
|
7
|
-
let(:payment) {
|
8
|
-
double('Spree::Payment',
|
9
|
-
source: double('Source', gateway_customer_profile_id: nil).as_null_object,
|
10
|
-
order: double('Spree::Order',
|
11
|
-
email: email,
|
12
|
-
bill_address: bill_address
|
13
|
-
)
|
14
|
-
)
|
15
|
-
}
|
16
|
-
|
17
|
-
let(:provider) do
|
18
|
-
double('provider').tap do |p|
|
19
|
-
p.stub(:purchase)
|
20
|
-
p.stub(:authorize)
|
21
|
-
p.stub(:capture)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
before do
|
26
|
-
subject.set_preference :login, login
|
27
|
-
subject.stub(:options_for_purchase_or_auth).and_return(['money','cc','opts'])
|
28
|
-
subject.stub(:provider).and_return provider
|
29
|
-
end
|
30
|
-
|
31
|
-
describe '#create_profile' do
|
32
|
-
context 'with an order that has a bill address' do
|
33
|
-
let(:bill_address) {
|
34
|
-
double('Spree::Address',
|
35
|
-
address1: '123 Happy Road',
|
36
|
-
address2: 'Apt 303',
|
37
|
-
city: 'Suzarac',
|
38
|
-
zipcode: '95671',
|
39
|
-
state: double('Spree::State', name: 'Oregon'),
|
40
|
-
country: double('Spree::Country', name: 'United States')
|
41
|
-
)
|
42
|
-
}
|
43
|
-
|
44
|
-
it 'stores the bill address with the provider' do
|
45
|
-
subject.provider.should_receive(:store).with(payment.source, {
|
46
|
-
email: email,
|
47
|
-
login: login,
|
48
|
-
|
49
|
-
address: {
|
50
|
-
address1: '123 Happy Road',
|
51
|
-
address2: 'Apt 303',
|
52
|
-
city: 'Suzarac',
|
53
|
-
zip: '95671',
|
54
|
-
state: 'Oregon',
|
55
|
-
country: 'United States'
|
56
|
-
}
|
57
|
-
}).and_return double.as_null_object
|
58
|
-
|
59
|
-
subject.create_profile payment
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
context 'with an order that does not have a bill address' do
|
64
|
-
let(:bill_address) { nil }
|
65
|
-
|
66
|
-
it 'does not store a bill address with the provider' do
|
67
|
-
subject.provider.should_receive(:store).with(payment.source, {
|
68
|
-
email: email,
|
69
|
-
login: login,
|
70
|
-
}).and_return double.as_null_object
|
71
|
-
|
72
|
-
subject.create_profile payment
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
context 'purchasing' do
|
78
|
-
|
79
|
-
after(:each) do
|
80
|
-
subject.purchase(19.99, 'credit card', {})
|
81
|
-
end
|
82
|
-
|
83
|
-
it 'should send the payment to the provider' do
|
84
|
-
provider.should_receive(:purchase).with('money','cc','opts')
|
85
|
-
end
|
86
|
-
|
87
|
-
end
|
88
|
-
|
89
|
-
context 'authorizing' do
|
90
|
-
|
91
|
-
after(:each) do
|
92
|
-
subject.authorize(19.99, 'credit card', {})
|
93
|
-
end
|
94
|
-
|
95
|
-
it 'should send the authorization to the provider' do
|
96
|
-
provider.should_receive(:authorize).with('money','cc','opts')
|
97
|
-
end
|
98
|
-
|
99
|
-
end
|
100
|
-
|
101
|
-
context 'capturing' do
|
102
|
-
|
103
|
-
let(:payment) do
|
104
|
-
double('payment').tap do |p|
|
105
|
-
p.stub(:amount).and_return(12.34)
|
106
|
-
p.stub(:response_code).and_return('response_code')
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
after(:each) do
|
111
|
-
subject.capture(payment, 'credit card', {})
|
112
|
-
end
|
113
|
-
|
114
|
-
it 'should convert the amount to cents' do
|
115
|
-
provider.should_receive(:capture).with(1234,anything,anything)
|
116
|
-
end
|
117
|
-
|
118
|
-
it 'should use the response code as the authorization' do
|
119
|
-
provider.should_receive(:capture).with(anything,'response_code',anything)
|
120
|
-
end
|
121
|
-
end
|
122
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Spree::Gateway::UsaEpay do
|
4
|
-
|
5
|
-
before(:each) do
|
6
|
-
Spree::Gateway.update_all :active => false
|
7
|
-
@gateway = Spree::Gateway::UsaEpay.create!(:name => "USA EPay Gateway", :environment => "sandbox", :active => true)
|
8
|
-
|
9
|
-
@gateway.set_preference(:login, "0r19zQBdp5nS8i3t4hFxz0di13yf56q1" )
|
10
|
-
@gateway.save!
|
11
|
-
|
12
|
-
@country = create(:country, :name => "United States", :iso_name => "UNITED STATES", :iso3 => "USA", :iso => "US", :numcode => 840)
|
13
|
-
@state = create(:state, :name => "Maryland", :abbr => "MD", :country => @country)
|
14
|
-
@address = create(:address,
|
15
|
-
:firstname => 'John',
|
16
|
-
:lastname => 'Doe',
|
17
|
-
:address1 => '1234 My Street',
|
18
|
-
:address2 => 'Apt 1',
|
19
|
-
:city => 'Washington DC',
|
20
|
-
:zipcode => '20123',
|
21
|
-
:phone => '(555)555-5555',
|
22
|
-
:state => @state,
|
23
|
-
:country => @country
|
24
|
-
)
|
25
|
-
@order = create(:order_with_totals, :bill_address => @address, :ship_address => @address)
|
26
|
-
@order.update!
|
27
|
-
@credit_card = create(:credit_card, :verification_value => '123', :number => '4111111111111111', :month => 9, :year => Time.now.year + 1, :first_name => 'John', :last_name => 'Doe')
|
28
|
-
@payment = create(:payment, :source => @credit_card, :order => @order, :payment_method => @gateway, :amount => 10.00)
|
29
|
-
@payment.payment_method.environment = "test"
|
30
|
-
end
|
31
|
-
|
32
|
-
describe "purchasing" do
|
33
|
-
it "can purchase a payment" do
|
34
|
-
pending "Broken due to USA EPay missing a source key."
|
35
|
-
@payment.purchase!.should be_true
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|