spree_gateway 2.1.1 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- metadata +185 -116
- data/.gitignore +0 -14
- data/.rspec +0 -1
- data/.travis.yml +0 -22
- data/Gemfile +0 -21
- data/LICENSE +0 -26
- data/README.md +0 -68
- data/Rakefile +0 -14
- data/Versionfile +0 -12
- data/app/assets/javascripts/store/gateway/stripe.js.coffee +0 -58
- data/app/assets/javascripts/store/spree_gateway.js +0 -2
- data/app/assets/stylesheets/store/spree_gateway.css +0 -8
- 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 -48
- data/app/models/spree/gateway/authorize_net.rb +0 -16
- data/app/models/spree/gateway/authorize_net_cim.rb +0 -132
- data/app/models/spree/gateway/balanced_gateway.rb +0 -65
- data/app/models/spree/gateway/banwire.rb +0 -15
- data/app/models/spree/gateway/beanstream.rb +0 -193
- data/app/models/spree/gateway/braintree_gateway.rb +0 -147
- data/app/models/spree/gateway/card_save.rb +0 -10
- data/app/models/spree/gateway/data_cash.rb +0 -10
- data/app/models/spree/gateway/eway.rb +0 -20
- data/app/models/spree/gateway/fatzebra.rb +0 -15
- data/app/models/spree/gateway/linkpoint.rb +0 -28
- data/app/models/spree/gateway/maxipago.rb +0 -14
- data/app/models/spree/gateway/moneris.rb +0 -11
- data/app/models/spree/gateway/pay_junction.rb +0 -16
- data/app/models/spree/gateway/pay_pal_gateway.rb +0 -12
- data/app/models/spree/gateway/payflow_pro.rb +0 -17
- data/app/models/spree/gateway/paymill.rb +0 -12
- data/app/models/spree/gateway/pin_gateway.rb +0 -15
- data/app/models/spree/gateway/sage_pay.rb +0 -11
- data/app/models/spree/gateway/samurai.rb +0 -63
- data/app/models/spree/gateway/secure_pay_au.rb +0 -10
- data/app/models/spree/gateway/stripe_gateway.rb +0 -103
- data/app/models/spree/gateway/usa_epay.rb +0 -9
- data/app/models/spree/gateway/worldpay.rb +0 -91
- data/app/models/spree/skrill_transaction.rb +0 -19
- data/app/views/spree/admin/log_entries/_braintree.html.erb +0 -31
- data/app/views/spree/admin/log_entries/_stripe.html.erb +0 -28
- data/app/views/spree/admin/payments/source_forms/_quickcheckout.html.erb +0 -8
- data/app/views/spree/admin/payments/source_forms/_stripe.html.erb +0 -1
- data/app/views/spree/admin/payments/source_views/_quickcheckout.html.erb +0 -39
- data/app/views/spree/admin/payments/source_views/_stripe.html.erb +0 -1
- data/app/views/spree/checkout/payment/_quickcheckout.html.erb +0 -26
- data/app/views/spree/checkout/payment/_stripe.html.erb +0 -21
- data/config/initializers/savon.rb +0 -3
- data/config/locales/bg.yml +0 -11
- data/config/locales/de.yml +0 -11
- data/config/locales/en.yml +0 -30
- data/config/locales/sv.yml +0 -11
- data/config/routes.rb +0 -20
- 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/db/migrate/20131112133401_migrate_stripe_preferences.rb +0 -8
- data/lib/active_merchant/billing/skrill.rb +0 -18
- data/lib/generators/spree_gateway/install/install_generator.rb +0 -28
- data/lib/spree_gateway.rb +0 -3
- data/lib/spree_gateway/engine.rb +0 -42
- data/script/rails +0 -5
- data/spec/factories/payment_method_factory.rb +0 -4
- data/spec/features/stripe_checkout_spec.rb +0 -82
- 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 -289
- 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/models/savon_spec.rb +0 -9
- data/spec/spec_helper.rb +0 -56
- data/spree_gateway.gemspec +0 -28
data/script/rails
DELETED
@@ -1,82 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe "Stripe checkout" do
|
4
|
-
let!(:country) { create(:country, :states_required => true) }
|
5
|
-
let!(:state) { create(:state, :country => country) }
|
6
|
-
let!(:shipping_method) { create(:shipping_method) }
|
7
|
-
let!(:stock_location) { create(:stock_location) }
|
8
|
-
let!(:mug) { create(:product, :name => "RoR Mug") }
|
9
|
-
let!(:stripe_payment_method) do
|
10
|
-
Spree::Gateway::StripeGateway.create!(
|
11
|
-
:name => "Stripe",
|
12
|
-
:preferred_secret_key => "sk_test_VCZnDv3GLU15TRvn8i2EsaAN",
|
13
|
-
:preferred_publishable_key => "pk_test_Cuf0PNtiAkkMpTVC2gwYDMIg",
|
14
|
-
:environment => "test"
|
15
|
-
)
|
16
|
-
end
|
17
|
-
|
18
|
-
let!(:zone) { create(:zone) }
|
19
|
-
|
20
|
-
before do
|
21
|
-
user = create(:user)
|
22
|
-
|
23
|
-
order = OrderWalkthrough.up_to(:delivery)
|
24
|
-
order.stub :confirmation_required? => true
|
25
|
-
|
26
|
-
order.reload
|
27
|
-
order.user = user
|
28
|
-
order.update!
|
29
|
-
|
30
|
-
Spree::CheckoutController.any_instance.stub(:current_order => order)
|
31
|
-
Spree::CheckoutController.any_instance.stub(:try_spree_current_user => user)
|
32
|
-
Spree::CheckoutController.any_instance.stub(:skip_state_validation? => true)
|
33
|
-
|
34
|
-
visit spree.checkout_state_path(:payment)
|
35
|
-
end
|
36
|
-
|
37
|
-
# This will pass the CC data to the server and the StripeGateway class handles it
|
38
|
-
it "can process a valid payment (without JS)" do
|
39
|
-
fill_in "Card Number", :with => "4242 4242 4242 4242"
|
40
|
-
fill_in "Card Code", :with => "123"
|
41
|
-
fill_in "Expiration", :with => "01 / #{Time.now.year + 1}"
|
42
|
-
click_button "Save and Continue"
|
43
|
-
page.current_url.should include("/checkout/confirm")
|
44
|
-
click_button "Place Order"
|
45
|
-
page.should have_content("Your order has been processed successfully")
|
46
|
-
end
|
47
|
-
|
48
|
-
# This will fetch a token from Stripe.com and then pass that to the webserver.
|
49
|
-
# The server then processes the payment using that token.
|
50
|
-
it "can process a valid payment (with JS)", :js => true do
|
51
|
-
fill_in "Card Number", :with => "4242 4242 4242 4242"
|
52
|
-
# Otherwise ccType field does not get updated correctly
|
53
|
-
page.execute_script("$('.cardNumber').trigger('change')")
|
54
|
-
fill_in "Card Code", :with => "123"
|
55
|
-
fill_in "Expiration", :with => "01 / #{Time.now.year + 1}"
|
56
|
-
click_button "Save and Continue"
|
57
|
-
sleep(5) # Wait for Stripe API to return + form to submit
|
58
|
-
page.current_url.should include("/checkout/confirm")
|
59
|
-
click_button "Place Order"
|
60
|
-
page.should have_content("Your order has been processed successfully")
|
61
|
-
end
|
62
|
-
|
63
|
-
it "shows an error with an invalid credit card number", :js => true do
|
64
|
-
click_button "Save and Continue"
|
65
|
-
page.should have_content("This card number looks invalid")
|
66
|
-
end
|
67
|
-
|
68
|
-
it "shows an error with invalid security fields", :js => true do
|
69
|
-
fill_in "Card Number", :with => "4242 4242 4242 4242"
|
70
|
-
fill_in "Expiration", :with => "01 / #{Time.now.year + 1}"
|
71
|
-
click_button "Save and Continue"
|
72
|
-
page.should have_content("Your card's security code is invalid.")
|
73
|
-
end
|
74
|
-
|
75
|
-
it "shows an error with invalid expiry fields", :js => true do
|
76
|
-
fill_in "Card Number", :with => "4242 4242 4242 4242"
|
77
|
-
fill_in "Expiration", :with => "00 / #{Time.now.year + 1}"
|
78
|
-
fill_in "Card Code", :with => "123"
|
79
|
-
click_button "Save and Continue"
|
80
|
-
page.should have_content("Your card's expiration month is invalid.")
|
81
|
-
end
|
82
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Spree::Gateway::AuthorizeNetCim do
|
4
|
-
let (:gateway) { Spree::Gateway::AuthorizeNetCim.new }
|
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 be_nil
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Spree::Gateway::AuthorizeNet do
|
4
|
-
let (:gateway) { Spree::Gateway::AuthorizeNet.create!(:name => "Authorize.net") }
|
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,9 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Spree::Gateway::BalancedGateway do
|
4
|
-
let(:gateway) { Spree::Gateway::BalancedGateway.create!(:name => "Balanced") }
|
5
|
-
|
6
|
-
it "should be Balanced gateway" do
|
7
|
-
gateway.provider_class.should == ::ActiveMerchant::Billing::BalancedGateway
|
8
|
-
end
|
9
|
-
end
|
@@ -1,289 +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 => 'mastercard')
|
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
|
-
before do
|
40
|
-
@gateway.set_preference(:merchant_account_id, merchant_account_id)
|
41
|
-
end
|
42
|
-
|
43
|
-
context "with merchant_account_id empty" do
|
44
|
-
let(:merchant_account_id) { "" }
|
45
|
-
|
46
|
-
it 'should not be present in options' do
|
47
|
-
@gateway.options.keys.include?(:merchant_account_id).should be_false
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
context 'with merchant_account_id set on gateway' do
|
52
|
-
let(:merchant_account_id) { 'test' }
|
53
|
-
|
54
|
-
it 'should have a perferred_merchant_account_id' do
|
55
|
-
@gateway.preferred_merchant_account_id.should == merchant_account_id
|
56
|
-
end
|
57
|
-
|
58
|
-
it 'should have a preferences[:merchant_account_id]' do
|
59
|
-
@gateway.preferences.keys.include?(:merchant_account_id).should be_true
|
60
|
-
end
|
61
|
-
|
62
|
-
it 'should be present in options' do
|
63
|
-
@gateway.options.keys.include?(:merchant_account_id).should be_true
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
it "should be braintree gateway" do
|
69
|
-
@gateway.provider_class.should == ::ActiveMerchant::Billing::BraintreeBlueGateway
|
70
|
-
end
|
71
|
-
|
72
|
-
describe "preferences" do
|
73
|
-
it "should not include server + test_mode" do
|
74
|
-
lambda { @gateway.preferences.fetch(:server) }.should raise_error(StandardError)
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
describe "authorize" do
|
79
|
-
it "should return a success response with an authorization code" do
|
80
|
-
result = @gateway.authorize(500, @credit_card)
|
81
|
-
|
82
|
-
result.success?.should be_true
|
83
|
-
result.authorization.should match(/\A\w{6}\z/)
|
84
|
-
|
85
|
-
|
86
|
-
Braintree::Transaction::Status::Authorized.should == Braintree::Transaction.find(result.authorization).status
|
87
|
-
end
|
88
|
-
|
89
|
-
shared_examples "a valid credit card" do
|
90
|
-
it 'should work through the spree payment interface' do
|
91
|
-
Spree::Config.set :auto_capture => false
|
92
|
-
@payment.log_entries.size.should == 0
|
93
|
-
@payment.process!
|
94
|
-
@payment.log_entries.size.should == 1
|
95
|
-
@payment.response_code.should match /\A\w{6}\z/
|
96
|
-
@payment.state.should == 'pending'
|
97
|
-
transaction = ::Braintree::Transaction.find(@payment.response_code)
|
98
|
-
transaction.status.should == Braintree::Transaction::Status::Authorized
|
99
|
-
card_number = @credit_card.number[0..5] + "******" + @credit_card.number[-4..-1]
|
100
|
-
transaction.credit_card_details.masked_number.should == card_number
|
101
|
-
transaction.credit_card_details.expiration_date.should == "09/#{Time.now.year + 1}"
|
102
|
-
transaction.customer_details.first_name.should == 'John'
|
103
|
-
transaction.customer_details.last_name.should == 'Doe'
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
context "when the card is a mastercard" do
|
108
|
-
before do
|
109
|
-
@credit_card.number = '5105105105105100'
|
110
|
-
@credit_card.cc_type = 'mastercard'
|
111
|
-
@credit_card.save
|
112
|
-
end
|
113
|
-
|
114
|
-
it_behaves_like "a valid credit card"
|
115
|
-
end
|
116
|
-
|
117
|
-
context "when the card is a visa" do
|
118
|
-
before do
|
119
|
-
@credit_card.number = '4111111111111111'
|
120
|
-
@credit_card.cc_type = 'visa'
|
121
|
-
@credit_card.save
|
122
|
-
end
|
123
|
-
|
124
|
-
it_behaves_like "a valid credit card"
|
125
|
-
end
|
126
|
-
|
127
|
-
context "when the card is an amex" do
|
128
|
-
before do
|
129
|
-
@credit_card.number = '378282246310005'
|
130
|
-
@credit_card.verification_value = '1234'
|
131
|
-
@credit_card.cc_type = 'amex'
|
132
|
-
@credit_card.save
|
133
|
-
end
|
134
|
-
|
135
|
-
it_behaves_like "a valid credit card"
|
136
|
-
end
|
137
|
-
|
138
|
-
context "when the card is a JCB" do
|
139
|
-
before do
|
140
|
-
@credit_card.number = '3530111333300000'
|
141
|
-
@credit_card.cc_type = 'jcb'
|
142
|
-
@credit_card.save
|
143
|
-
end
|
144
|
-
|
145
|
-
it_behaves_like "a valid credit card"
|
146
|
-
end
|
147
|
-
|
148
|
-
context "when the card is a diners club" do
|
149
|
-
before do
|
150
|
-
@credit_card.number = '36050000000003'
|
151
|
-
@credit_card.cc_type = 'dinersclub'
|
152
|
-
@credit_card.save
|
153
|
-
end
|
154
|
-
|
155
|
-
it_behaves_like "a valid credit card"
|
156
|
-
end
|
157
|
-
end
|
158
|
-
|
159
|
-
describe "capture" do
|
160
|
-
|
161
|
-
it " should capture a previous authorization" do
|
162
|
-
@payment.process!
|
163
|
-
assert_equal 1, @payment.log_entries.size
|
164
|
-
assert_match /\A\w{6}\z/, @payment.response_code
|
165
|
-
transaction = ::Braintree::Transaction.find(@payment.response_code)
|
166
|
-
transaction.status.should == Braintree::Transaction::Status::Authorized
|
167
|
-
capture_result = @gateway.capture(@payment,:ignored_arg_credit_card, :ignored_arg_options)
|
168
|
-
capture_result.success?.should be_true
|
169
|
-
transaction = ::Braintree::Transaction.find(@payment.response_code)
|
170
|
-
transaction.status.should == Braintree::Transaction::Status::SubmittedForSettlement
|
171
|
-
end
|
172
|
-
|
173
|
-
pending "raise an error if capture fails using spree interface" do
|
174
|
-
Spree::Config.set :auto_capture => false
|
175
|
-
@payment.log_entries.size.should == 0
|
176
|
-
@payment.process!
|
177
|
-
@payment.log_entries.size.should == 1
|
178
|
-
transaction = ::Braintree::Transaction.find(@payment.response_code)
|
179
|
-
transaction.status.should == Braintree::Transaction::Status::Authorized
|
180
|
-
@payment.payment_source.capture(@payment) # as done in PaymentsController#fire
|
181
|
-
# transaction = ::Braintree::Transaction.find(@payment.response_code)
|
182
|
-
# transaction.status.should == Braintree::Transaction::Status::SubmittedForSettlement
|
183
|
-
# lambda do
|
184
|
-
# @payment.payment_source.capture(@payment)
|
185
|
-
# end.should raise_error(Spree::Core::GatewayError, "Cannot submit for settlement unless status is authorized. (91507)")
|
186
|
-
end
|
187
|
-
end
|
188
|
-
|
189
|
-
describe 'purchase' do
|
190
|
-
it 'should return a success response with an authorization code' do
|
191
|
-
result = @gateway.purchase(500, @credit_card)
|
192
|
-
result.success?.should be_true
|
193
|
-
result.authorization.should match(/\A\w{6}\z/)
|
194
|
-
Braintree::Transaction::Status::SubmittedForSettlement.should == Braintree::Transaction.find(result.authorization).status
|
195
|
-
end
|
196
|
-
|
197
|
-
it 'should work through the spree payment interface with payment profiles' do
|
198
|
-
purchase_using_spree_interface
|
199
|
-
transaction = ::Braintree::Transaction.find(@payment.response_code)
|
200
|
-
transaction.credit_card_details.token.should_not be_nil
|
201
|
-
end
|
202
|
-
|
203
|
-
it 'should work through the spree payment interface without payment profiles' do
|
204
|
-
with_payment_profiles_off do
|
205
|
-
purchase_using_spree_interface(false)
|
206
|
-
transaction = ::Braintree::Transaction.find(@payment.response_code)
|
207
|
-
transaction.credit_card_details.token.should be_nil
|
208
|
-
end
|
209
|
-
end
|
210
|
-
end
|
211
|
-
|
212
|
-
describe "credit" do
|
213
|
-
pending "should work through the spree interface" do
|
214
|
-
@payment.amount += 100.00
|
215
|
-
purchase_using_spree_interface
|
216
|
-
credit_using_spree_interface
|
217
|
-
end
|
218
|
-
end
|
219
|
-
|
220
|
-
describe "void" do
|
221
|
-
pending "should work through the spree credit_card / payment interface" do
|
222
|
-
assert_equal 0, @payment.log_entries.size
|
223
|
-
@payment.process!
|
224
|
-
assert_equal 1, @payment.log_entries.size
|
225
|
-
@payment.response_code.should match(/\A\w{6}\z/)
|
226
|
-
transaction = Braintree::Transaction.find(@payment.response_code)
|
227
|
-
transaction.status.should == Braintree::Transaction::Status::SubmittedForSettlement
|
228
|
-
@credit_card.void(@payment)
|
229
|
-
transaction = Braintree::Transaction.find(transaction.id)
|
230
|
-
transaction.status.should == Braintree::Transaction::Status::Voided
|
231
|
-
end
|
232
|
-
end
|
233
|
-
|
234
|
-
describe "update_card_number" do
|
235
|
-
it "passes through gateway_payment_profile_id" do
|
236
|
-
credit_card = { 'token' => 'testing', 'last_4' => '1234', 'masked_number' => '5555**5555' }
|
237
|
-
@gateway.update_card_number(@payment.source, credit_card)
|
238
|
-
@payment.source.gateway_payment_profile_id.should == "testing"
|
239
|
-
end
|
240
|
-
end
|
241
|
-
|
242
|
-
def credit_using_spree_interface
|
243
|
-
@payment.log_entries.size.should == 1
|
244
|
-
@payment.source.credit(@payment) # as done in PaymentsController#fire
|
245
|
-
@payment.log_entries.size.should == 2
|
246
|
-
#Let's get the payment record associated with the credit
|
247
|
-
@payment = @order.payments.last
|
248
|
-
@payment.response_code.should match(/\A\w{6}\z/)
|
249
|
-
transaction = ::Braintree::Transaction.find(@payment.response_code)
|
250
|
-
transaction.type.should == Braintree::Transaction::Type::Credit
|
251
|
-
transaction.status.should == Braintree::Transaction::Status::SubmittedForSettlement
|
252
|
-
transaction.credit_card_details.masked_number.should == "510510******5100"
|
253
|
-
transaction.credit_card_details.expiration_date.should == "09/#{Time.now.year + 1}"
|
254
|
-
transaction.customer_details.first_name.should == "John"
|
255
|
-
transaction.customer_details.last_name.should == "Doe"
|
256
|
-
end
|
257
|
-
|
258
|
-
def purchase_using_spree_interface(profile=true)
|
259
|
-
Spree::Config.set :auto_capture => true
|
260
|
-
@payment.send(:create_payment_profile) if profile
|
261
|
-
@payment.log_entries.size == 0
|
262
|
-
@payment.process! # as done in PaymentsController#create
|
263
|
-
@payment.log_entries.size == 1
|
264
|
-
@payment.response_code.should match /\A\w{6}\z/
|
265
|
-
@payment.state.should == 'completed'
|
266
|
-
transaction = ::Braintree::Transaction.find(@payment.response_code)
|
267
|
-
Braintree::Transaction::Status::SubmittedForSettlement.should == transaction.status
|
268
|
-
transaction.credit_card_details.masked_number.should == "510510******5100"
|
269
|
-
transaction.credit_card_details.expiration_date.should == "09/#{Time.now.year + 1}"
|
270
|
-
transaction.customer_details.first_name.should == 'John'
|
271
|
-
transaction.customer_details.last_name.should == 'Doe'
|
272
|
-
end
|
273
|
-
|
274
|
-
def with_payment_profiles_off(&block)
|
275
|
-
Spree::Gateway::BraintreeGateway.class_eval do
|
276
|
-
def payment_profiles_supported?
|
277
|
-
false
|
278
|
-
end
|
279
|
-
end
|
280
|
-
yield
|
281
|
-
ensure
|
282
|
-
Spree::Gateway::BraintreeGateway.class_eval do
|
283
|
-
def payment_profiles_supported?
|
284
|
-
true
|
285
|
-
end
|
286
|
-
end
|
287
|
-
end
|
288
|
-
|
289
|
-
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
|