spree_gateway 2.2.0 → 2.2.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.
- checksums.yaml +4 -4
- data/.gitignore +9 -0
- data/.rspec +1 -0
- data/.travis.yml +23 -0
- data/Gemfile +5 -0
- data/Guardfile +9 -0
- data/LICENSE.md +26 -0
- data/README.md +71 -0
- data/Rakefile +15 -0
- data/Versionfile +7 -0
- data/app/assets/javascripts/spree/frontend/spree_gateway.js +3 -0
- data/app/assets/javascripts/store/gateway/stripe.js.coffee +58 -0
- data/app/assets/javascripts/store/spree_gateway.js +2 -0
- data/app/assets/stylesheets/spree/frontend/spree_gateway.css +3 -0
- data/app/controllers/spree/checkout_controller_decorator.rb +51 -0
- data/app/controllers/spree/skrill_status_controller.rb +39 -0
- data/app/models/spree/billing_integration/skrill/quick_checkout.rb +48 -0
- data/app/models/spree/gateway/authorize_net.rb +16 -0
- data/app/models/spree/gateway/authorize_net_cim.rb +132 -0
- data/app/models/spree/gateway/balanced_gateway.rb +67 -0
- data/app/models/spree/gateway/banwire.rb +15 -0
- data/app/models/spree/gateway/beanstream.rb +193 -0
- data/app/models/spree/gateway/braintree_gateway.rb +147 -0
- data/app/models/spree/gateway/card_save.rb +10 -0
- data/app/models/spree/gateway/data_cash.rb +10 -0
- data/app/models/spree/gateway/eway.rb +20 -0
- data/app/models/spree/gateway/fatzebra.rb +15 -0
- data/app/models/spree/gateway/linkpoint.rb +28 -0
- data/app/models/spree/gateway/maxipago.rb +14 -0
- data/app/models/spree/gateway/moneris.rb +10 -0
- data/app/models/spree/gateway/pay_junction.rb +16 -0
- data/app/models/spree/gateway/pay_pal_gateway.rb +12 -0
- data/app/models/spree/gateway/payflow_pro.rb +17 -0
- data/app/models/spree/gateway/paymill.rb +12 -0
- data/app/models/spree/gateway/pin_gateway.rb +15 -0
- data/app/models/spree/gateway/sage_pay.rb +11 -0
- data/app/models/spree/gateway/samurai.rb +63 -0
- data/app/models/spree/gateway/secure_pay_au.rb +10 -0
- data/app/models/spree/gateway/stripe_gateway.rb +103 -0
- data/app/models/spree/gateway/usa_epay.rb +9 -0
- data/app/models/spree/gateway/worldpay.rb +91 -0
- data/app/models/spree/skrill_transaction.rb +19 -0
- data/app/views/spree/admin/log_entries/_braintree.html.erb +31 -0
- data/app/views/spree/admin/log_entries/_stripe.html.erb +28 -0
- data/app/views/spree/admin/payments/source_forms/_quickcheckout.html.erb +8 -0
- data/app/views/spree/admin/payments/source_forms/_stripe.html.erb +1 -0
- data/app/views/spree/admin/payments/source_views/_quickcheckout.html.erb +39 -0
- data/app/views/spree/admin/payments/source_views/_stripe.html.erb +1 -0
- data/app/views/spree/checkout/payment/_quickcheckout.html.erb +26 -0
- data/app/views/spree/checkout/payment/_stripe.html.erb +21 -0
- data/config/initializers/savon.rb +3 -0
- data/config/locales/bg.yml +11 -0
- data/config/locales/de.yml +11 -0
- data/config/locales/en.yml +30 -0
- data/config/locales/sv.yml +11 -0
- data/config/routes.rb +13 -0
- data/db/migrate/20111118164631_create_skrill_transactions.rb +14 -0
- data/db/migrate/20121017004102_update_braintree_payment_method_type.rb +9 -0
- data/db/migrate/20130213222555_update_stripe_payment_method_type.rb +9 -0
- data/db/migrate/20130415222802_update_balanced_payment_method_type.rb +9 -0
- data/db/migrate/20131008221012_update_paypal_payment_method_type.rb +9 -0
- data/db/migrate/20131112133401_migrate_stripe_preferences.rb +8 -0
- data/lib/active_merchant/billing/skrill.rb +18 -0
- data/lib/generators/spree_gateway/install/install_generator.rb +28 -0
- data/lib/spree_gateway.rb +4 -0
- data/lib/spree_gateway/engine.rb +35 -0
- data/script/rails +7 -0
- data/spec/controllers/spree/checkout_controller_spec.rb +13 -0
- data/spec/controllers/spree/skrill_status_controller_spec.rb +8 -0
- data/spec/factories/payment_method_factory.rb +6 -0
- data/spec/factories/skrill_transaction_factory.rb +10 -0
- data/spec/features/stripe_checkout_spec.rb +82 -0
- data/spec/lib/active_merchant/billing_skrill_spec.rb +18 -0
- data/spec/models/billing_integration/skrill_quick_checkout_spec.rb +11 -0
- data/spec/models/gateway/authorize_net_cim_spec.rb +29 -0
- data/spec/models/gateway/authorize_net_spec.rb +23 -0
- data/spec/models/gateway/balanced_gateway_spec.rb +17 -0
- data/spec/models/gateway/banwire_spec.rb +11 -0
- data/spec/models/gateway/beanstream_spec.rb +17 -0
- data/spec/models/gateway/braintree_gateway_spec.rb +319 -0
- data/spec/models/gateway/card_save_spec.rb +11 -0
- data/spec/models/gateway/data_cache_spec.rb +11 -0
- data/spec/models/gateway/eway_spec.rb +29 -0
- data/spec/models/gateway/fatzebra_spec.rb +51 -0
- data/spec/models/gateway/linkpoint_spec.rb +62 -0
- data/spec/models/gateway/maxipago_spec.rb +17 -0
- data/spec/models/gateway/moneris_spec.rb +11 -0
- data/spec/models/gateway/pay_junction_spec.rb +23 -0
- data/spec/models/gateway/pay_pal_spec.rb +11 -0
- data/spec/models/gateway/payflow_pro_spec.rb +23 -0
- data/spec/models/gateway/paymill_spec.rb +11 -0
- data/spec/models/gateway/pin_gateway_spec.rb +56 -0
- data/spec/models/gateway/sage_pay_spec.rb +11 -0
- data/spec/models/gateway/samurai_spec.rb +17 -0
- data/spec/models/gateway/secure_pay_au_spec.rb +11 -0
- data/spec/models/gateway/stripe_gateway_spec.rb +117 -0
- data/spec/models/gateway/usa_epay_spec.rb +49 -0
- data/spec/models/gateway/worldpay_spec.rb +11 -0
- data/spec/models/savon_spec.rb +9 -0
- data/spec/models/skrill_transaction_spec.rb +9 -0
- data/spec/spec_helper.rb +49 -0
- data/spree_gateway.gemspec +40 -0
- metadata +140 -5
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Spree::Gateway::CardSave do
|
|
4
|
+
let(:gateway) { described_class.create!(name: 'CardSave') }
|
|
5
|
+
|
|
6
|
+
context '.provider_class' do
|
|
7
|
+
it 'is a CardSave gateway' do
|
|
8
|
+
expect(gateway.provider_class).to eq ::ActiveMerchant::Billing::CardSaveGateway
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Spree::Gateway::DataCash do
|
|
4
|
+
let(:gateway) { described_class.create!(name: 'DataCash') }
|
|
5
|
+
|
|
6
|
+
context '.provider_class' do
|
|
7
|
+
it 'is a DataCash gateway' do
|
|
8
|
+
expect(gateway.provider_class).to eq ::ActiveMerchant::Billing::DataCashGateway
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Spree::Gateway::Eway do
|
|
4
|
+
let(:gateway) { described_class.create!(name: 'Eway') }
|
|
5
|
+
|
|
6
|
+
context '.provider_class' do
|
|
7
|
+
it 'is a Eway gateway' do
|
|
8
|
+
expect(gateway.provider_class).to eq ::ActiveMerchant::Billing::EwayGateway
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
context '.auto_capture?' do
|
|
13
|
+
it 'supports purchase method only' do
|
|
14
|
+
expect(gateway.auto_capture?).to be_true
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
describe 'options' do
|
|
19
|
+
it 'include :test => true in when :test_mode is true' do
|
|
20
|
+
gateway.preferred_test_mode = true
|
|
21
|
+
expect(gateway.options[:test]).to be_true
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it 'does not include :test when test_mode is false' do
|
|
25
|
+
gateway.preferred_test_mode = false
|
|
26
|
+
expect(gateway.options[:test]).to be_false
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Spree::Gateway::Fatzebra do
|
|
4
|
+
|
|
5
|
+
before do
|
|
6
|
+
Spree::Gateway.update_all(active: false)
|
|
7
|
+
@gateway = Spree::Gateway::Fatzebra.create!(name: 'Fat Zebra Gateway', environment: 'sandbox', active: true)
|
|
8
|
+
@gateway.set_preference(:username, 'TEST')
|
|
9
|
+
@gateway.set_preference(:token, 'TEST')
|
|
10
|
+
@gateway.save!
|
|
11
|
+
|
|
12
|
+
country = create(:country, name: 'Australia', iso_name: 'Australia', iso3: 'AUS', iso: 'AU', numcode: 61)
|
|
13
|
+
state = create(:state, name: 'Victoria', abbr: 'VIC', country: country)
|
|
14
|
+
address = 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
|
+
|
|
26
|
+
order = create(:order_with_totals, bill_address: address, ship_address: address, last_ip_address: '127.0.0.1')
|
|
27
|
+
order.update!
|
|
28
|
+
|
|
29
|
+
credit_card = create(:credit_card,
|
|
30
|
+
verification_value: '123',
|
|
31
|
+
number: '5123456789012346',
|
|
32
|
+
month: 5,
|
|
33
|
+
year: Time.now.year + 1,
|
|
34
|
+
name: 'Ronald C Robot'
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
@payment = create(:payment, source: credit_card, order: order, payment_method: @gateway, amount: 10.00)
|
|
38
|
+
@payment.payment_method.environment = 'test'
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
it 'can purchase' do
|
|
42
|
+
@payment.purchase!
|
|
43
|
+
expect(@payment.state).to eq 'completed'
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
context '.auto_capture?' do
|
|
47
|
+
it 'return true' do
|
|
48
|
+
expect(@gateway.auto_capture?).to be_true
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Spree::Gateway::Linkpoint do
|
|
4
|
+
let(:gateway) { described_class.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
|
+
context '.provider_class' do
|
|
16
|
+
it 'is a Linkpoint gateway' do
|
|
17
|
+
expect(gateway.provider_class).to eq ::ActiveMerchant::Billing::LinkpointGateway
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
context '#authorize' do
|
|
22
|
+
it 'adds the discount to the subtotal' do
|
|
23
|
+
provider.should_receive(:authorize)
|
|
24
|
+
.with(money, credit_card, subtotal: 2, discount: 0)
|
|
25
|
+
gateway.authorize(money, credit_card, options)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
context '#purchase' do
|
|
30
|
+
it 'adds the discount to the subtotal' do
|
|
31
|
+
provider.should_receive(:purchase)
|
|
32
|
+
.with(money, credit_card, subtotal: 2, discount: 0)
|
|
33
|
+
gateway.purchase(money, credit_card, options)
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
context '#capture' do
|
|
38
|
+
let(:authorization) { double('authorization') }
|
|
39
|
+
|
|
40
|
+
it 'adds the discount to the subtotal' do
|
|
41
|
+
provider.should_receive(:capture)
|
|
42
|
+
.with(money, authorization, subtotal: 2, discount: 0)
|
|
43
|
+
gateway.capture(money, authorization, options)
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
context '#void' do
|
|
48
|
+
it 'adds the discount to the subtotal' do
|
|
49
|
+
provider.should_receive(:void)
|
|
50
|
+
.with(identification, subtotal: 2, discount: 0)
|
|
51
|
+
gateway.void(identification, options)
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
context '#credit' do
|
|
56
|
+
it 'adds the discount to the subtotal' do
|
|
57
|
+
provider.should_receive(:credit)
|
|
58
|
+
.with(money, identification, subtotal: 2, discount: 0)
|
|
59
|
+
gateway.credit(money, identification, options)
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Spree::Gateway::Maxipago do
|
|
4
|
+
let(:gateway) { described_class.create!(name: 'Maxipago') }
|
|
5
|
+
|
|
6
|
+
context '.provider_class' do
|
|
7
|
+
it 'is a Maxipago gateway' do
|
|
8
|
+
expect(subject.provider_class).to eq ::ActiveMerchant::Billing::MaxipagoGateway
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
context '.auto_capture?' do
|
|
13
|
+
it 'return true' do
|
|
14
|
+
expect(subject.auto_capture?).to be_true
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Spree::Gateway::Moneris do
|
|
4
|
+
let(:gateway) { described_class.create!(name: 'Moneris') }
|
|
5
|
+
|
|
6
|
+
context '.provider_class' do
|
|
7
|
+
it 'is a Moneris gateway' do
|
|
8
|
+
expect(gateway.provider_class).to eq ::ActiveMerchant::Billing::MonerisGateway
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Spree::Gateway::PayJunction do
|
|
4
|
+
let(:gateway) { described_class.create!(name: 'PayJunction') }
|
|
5
|
+
|
|
6
|
+
context '.provider_class' do
|
|
7
|
+
it 'is a PayJunction gateway' do
|
|
8
|
+
expect(gateway.provider_class).to eq ::ActiveMerchant::Billing::PayJunctionGateway
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
describe 'options' do
|
|
13
|
+
it 'include :test => true in when :test_mode is true' do
|
|
14
|
+
gateway.preferred_test_mode = true
|
|
15
|
+
expect(gateway.options[:test]).to be_true
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it 'does not include :test when test_mode is false' do
|
|
19
|
+
gateway.preferred_test_mode = false
|
|
20
|
+
expect(gateway.options[:test]).to be_false
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Spree::Gateway::PayPalGateway do
|
|
4
|
+
let(:gateway) { described_class.create!(name: 'PayPal') }
|
|
5
|
+
|
|
6
|
+
context '.provider_class' do
|
|
7
|
+
it 'is a PayPal gateway' do
|
|
8
|
+
expect(gateway.provider_class).to eq ::ActiveMerchant::Billing::PaypalGateway
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Spree::Gateway::PayflowPro do
|
|
4
|
+
let(:gateway) { described_class.create!(name: 'PayflowPro') }
|
|
5
|
+
|
|
6
|
+
context '.provider_class' do
|
|
7
|
+
it 'is a Payflow gateway' do
|
|
8
|
+
expect(gateway.provider_class).to eq ::ActiveMerchant::Billing::PayflowGateway
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
describe 'options' do
|
|
13
|
+
it 'include :test => true when :test_mode is true' do
|
|
14
|
+
gateway.preferred_test_mode = true
|
|
15
|
+
expect(gateway.options[:test]).to be_true
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it 'does not include :test when test_mode is false' do
|
|
19
|
+
gateway.preferred_test_mode = false
|
|
20
|
+
expect(gateway.options[:test]).to be_false
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Spree::Gateway::Paymill do
|
|
4
|
+
let(:gateway) { described_class.create!(name: 'Paymill') }
|
|
5
|
+
|
|
6
|
+
context '.provider_class' do
|
|
7
|
+
it 'is a Paymill gateway' do
|
|
8
|
+
expect(gateway.provider_class).to eq ::ActiveMerchant::Billing::PaymillGateway
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Spree::Gateway::PinGateway do
|
|
4
|
+
|
|
5
|
+
before do
|
|
6
|
+
Spree::Gateway.update_all(active: false)
|
|
7
|
+
@gateway = described_class.create!(name: 'Pin Gateway', environment: 'sandbox', active: true)
|
|
8
|
+
@gateway.set_preference(:api_key, 'W_VzkRCZSILiKWUS-dndUg')
|
|
9
|
+
@gateway.save!
|
|
10
|
+
|
|
11
|
+
country = create(:country, name: 'Australia', iso_name: 'Australia', iso3: 'AUS', iso: 'AU', numcode: 61)
|
|
12
|
+
state = create(:state, name: 'Victoria', abbr: 'VIC', country: country)
|
|
13
|
+
address = create(:address,
|
|
14
|
+
firstname: 'Ronald C',
|
|
15
|
+
lastname: 'Robot',
|
|
16
|
+
address1: '1234 My Street',
|
|
17
|
+
address2: 'Apt 1',
|
|
18
|
+
city: 'Melbourne',
|
|
19
|
+
zipcode: '3000',
|
|
20
|
+
phone: '88888888',
|
|
21
|
+
state: state,
|
|
22
|
+
country: country
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
order = create(:order_with_totals, bill_address: address, ship_address: address)
|
|
26
|
+
order.update!
|
|
27
|
+
|
|
28
|
+
credit_card = create(:credit_card,
|
|
29
|
+
verification_value: '123',
|
|
30
|
+
number: '5520000000000000',
|
|
31
|
+
month: 5,
|
|
32
|
+
year: Time.now.year + 1,
|
|
33
|
+
first_name: 'Ronald C',
|
|
34
|
+
last_name: 'Robot',
|
|
35
|
+
cc_type: 'mastercard'
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
@payment = create(:payment, source: credit_card, order: order, payment_method: @gateway, amount: 10.00)
|
|
39
|
+
@payment.payment_method.environment = 'test'
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it 'can purchase' do
|
|
43
|
+
@payment.purchase!
|
|
44
|
+
expect(@payment.state).to eq 'completed'
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# Regression test for #106
|
|
48
|
+
it 'uses auto capturing' do
|
|
49
|
+
expect(@gateway.auto_capture?).to be_true
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
it 'always uses purchase' do
|
|
53
|
+
@payment.should_receive(:purchase!)
|
|
54
|
+
@payment.process!
|
|
55
|
+
end
|
|
56
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Spree::Gateway::SagePay do
|
|
4
|
+
let(:gateway) { described_class.create!(name: 'SagePay') }
|
|
5
|
+
|
|
6
|
+
context '.provider_class' do
|
|
7
|
+
it 'is a SagePay gateway' do
|
|
8
|
+
expect(gateway.provider_class).to eq ::ActiveMerchant::Billing::SagePayGateway
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Spree::Gateway::Samurai do
|
|
4
|
+
let(:gateway) { Spree::Gateway::Samurai.create!(name: 'Samurai') }
|
|
5
|
+
|
|
6
|
+
context '.provider_class' do
|
|
7
|
+
it 'is a Samurai gateway' do
|
|
8
|
+
expect(gateway.provider_class).to eq ::ActiveMerchant::Billing::SamuraiGateway
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
context '.payment_profiles_supported?' do
|
|
13
|
+
it 'return true' do
|
|
14
|
+
expect(gateway.payment_profiles_supported?).to be_true
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Spree::Gateway::SecurePayAU do
|
|
4
|
+
let(:gateway) { described_class.create!(name: 'SecurePayAU') }
|
|
5
|
+
|
|
6
|
+
context '.provider_class' do
|
|
7
|
+
it 'is a SecurePayAU gateway' do
|
|
8
|
+
expect(gateway.provider_class).to eq ::ActiveMerchant::Billing::SecurePayAuGateway
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Spree::Gateway::StripeGateway do
|
|
4
|
+
let(:secret_key) { 'key' }
|
|
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 :secret_key, secret_key
|
|
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: secret_key,
|
|
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: secret_key,
|
|
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
|
+
after do
|
|
79
|
+
subject.purchase(19.99, 'credit card', {})
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
it 'send the payment to the provider' do
|
|
83
|
+
provider.should_receive(:purchase).with('money','cc','opts')
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
context 'authorizing' do
|
|
88
|
+
after do
|
|
89
|
+
subject.authorize(19.99, 'credit card', {})
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
it 'send the authorization to the provider' do
|
|
93
|
+
provider.should_receive(:authorize).with('money','cc','opts')
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
context 'capturing' do
|
|
98
|
+
let(:payment) do
|
|
99
|
+
double('payment').tap do |p|
|
|
100
|
+
p.stub(:amount).and_return(12.34)
|
|
101
|
+
p.stub(:response_code).and_return('response_code')
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
after do
|
|
106
|
+
subject.capture(payment, 'credit card', {})
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
it 'convert the amount to cents' do
|
|
110
|
+
provider.should_receive(:capture).with(1234,anything,anything)
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
it 'use the response code as the authorization' do
|
|
114
|
+
provider.should_receive(:capture).with(anything,'response_code',anything)
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
end
|