solidus_gateway 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +1 -0
- data/.travis.yml +23 -0
- data/Gemfile +9 -0
- data/LICENSE.md +26 -0
- data/README.md +38 -0
- data/Rakefile +21 -0
- data/app/models/spree/billing_integration/skrill/quick_checkout.rb +48 -0
- data/app/models/spree/gateway/authorize_net.rb +31 -0
- data/app/models/spree/gateway/authorize_net_cim.rb +201 -0
- data/app/models/spree/gateway/balanced_gateway.rb +65 -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 +184 -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/linkpoint.rb +28 -0
- data/app/models/spree/gateway/maxipago.rb +14 -0
- data/app/models/spree/gateway/migs.rb +11 -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 +18 -0
- data/app/models/spree/gateway/paymill.rb +12 -0
- data/app/models/spree/gateway/pin_gateway.rb +60 -0
- data/app/models/spree/gateway/sage_pay.rb +11 -0
- data/app/models/spree/gateway/secure_pay_au.rb +10 -0
- data/app/models/spree/gateway/spreedly_core_gateway.rb +10 -0
- data/app/models/spree/gateway/stripe_gateway.rb +126 -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/bin/rails +7 -0
- data/circle.yml +6 -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 +12 -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/assets/javascripts/spree/frontend/solidus_gateway.js +1 -0
- data/lib/assets/stylesheets/spree/frontend/solidus_gateway.css +3 -0
- data/lib/controllers/frontend/spree/checkout_controller_decorator.rb +51 -0
- data/lib/controllers/frontend/spree/skrill_status_controller.rb +39 -0
- data/lib/generators/solidus_gateway/install/install_generator.rb +28 -0
- data/lib/solidus_gateway.rb +4 -0
- data/lib/spree_gateway/engine.rb +67 -0
- data/lib/views/backend/spree/admin/log_entries/_braintree.html.erb +31 -0
- data/lib/views/backend/spree/admin/log_entries/_stripe.html.erb +28 -0
- data/lib/views/backend/spree/admin/payments/source_forms/_quickcheckout.html.erb +8 -0
- data/lib/views/backend/spree/admin/payments/source_forms/_stripe.html.erb +1 -0
- data/lib/views/backend/spree/admin/payments/source_views/_quickcheckout.html.erb +39 -0
- data/lib/views/backend/spree/admin/payments/source_views/_stripe.html.erb +1 -0
- data/lib/views/frontend/spree/checkout/payment/_quickcheckout.html.erb +26 -0
- data/lib/views/frontend/spree/checkout/payment/_stripe.html.erb +80 -0
- data/solidus_gateway.gemspec +33 -0
- data/spec/factories/skrill_factory.rb +6 -0
- data/spec/features/stripe_checkout_spec.rb +78 -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 +437 -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/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 +55 -0
- data/spec/models/gateway/sage_pay_spec.rb +11 -0
- data/spec/models/gateway/secure_pay_au_spec.rb +11 -0
- data/spec/models/gateway/stripe_gateway_spec.rb +200 -0
- data/spec/models/gateway/usa_epay_spec.rb +49 -0
- data/spec/models/gateway/worldpay_spec.rb +11 -0
- data/spec/models/skrill_transaction_spec.rb +9 -0
- data/spec/spec_helper.rb +50 -0
- metadata +317 -0
@@ -0,0 +1,16 @@
|
|
1
|
+
module Spree
|
2
|
+
class Gateway::PayJunction < Gateway
|
3
|
+
preference :login, :string
|
4
|
+
preference :password, :string
|
5
|
+
|
6
|
+
def provider_class
|
7
|
+
ActiveMerchant::Billing::PayJunctionGateway
|
8
|
+
end
|
9
|
+
|
10
|
+
def options_with_test_preference
|
11
|
+
options_without_test_preference.merge(:test => self.preferred_test_mode)
|
12
|
+
end
|
13
|
+
|
14
|
+
alias_method_chain :options, :test_preference
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Spree
|
2
|
+
class Gateway::PayPalGateway < Gateway
|
3
|
+
preference :login, :string
|
4
|
+
preference :password, :string
|
5
|
+
preference :signature, :string
|
6
|
+
preference :currency_code, :string
|
7
|
+
|
8
|
+
def provider_class
|
9
|
+
ActiveMerchant::Billing::PaypalGateway
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Spree
|
2
|
+
class Gateway::PayflowPro < Gateway
|
3
|
+
preference :login, :string
|
4
|
+
preference :password, :password
|
5
|
+
preference :partner, :string
|
6
|
+
|
7
|
+
def provider_class
|
8
|
+
ActiveMerchant::Billing::PayflowGateway
|
9
|
+
end
|
10
|
+
|
11
|
+
def options_with_test_preference
|
12
|
+
options_without_test_preference.merge(:test => self.preferred_test_mode)
|
13
|
+
end
|
14
|
+
|
15
|
+
alias_method_chain :options, :test_preference
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module Spree
|
2
|
+
class Gateway::PinGateway < Gateway
|
3
|
+
preference :api_key, :string
|
4
|
+
preference :currency, :string, :default => 'AUD'
|
5
|
+
|
6
|
+
def provider_class
|
7
|
+
ActiveMerchant::Billing::PinGateway
|
8
|
+
end
|
9
|
+
|
10
|
+
def purchase(money, creditcard, options = {})
|
11
|
+
super(money, creditcard.try(:gateway_customer_profile_id) || creditcard.try(:gateway_payment_profile_id) || creditcard, options)
|
12
|
+
end
|
13
|
+
|
14
|
+
def create_profile(payment)
|
15
|
+
if payment.source.gateway_customer_profile_id.nil?
|
16
|
+
response = provider.store(payment.source, options_for_payment(payment))
|
17
|
+
|
18
|
+
if response.success?
|
19
|
+
payment.source.update_attributes!(:gateway_customer_profile_id => response.authorization)
|
20
|
+
|
21
|
+
cc = response.params['response']['card']
|
22
|
+
payment.source.update_attributes!(:gateway_payment_profile_id => cc['token']) if cc
|
23
|
+
else
|
24
|
+
payment.send(:gateway_error, response.message)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
# Pin does not appear to support authorizing transactions yet
|
30
|
+
def auto_capture?
|
31
|
+
true
|
32
|
+
end
|
33
|
+
|
34
|
+
def payment_profiles_supported?
|
35
|
+
true
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
def options_for_payment(p)
|
41
|
+
o = Hash.new
|
42
|
+
o[:email] = p.order.email
|
43
|
+
|
44
|
+
if p.order.bill_address
|
45
|
+
bill_addr = p.order.bill_address
|
46
|
+
|
47
|
+
o[:billing_address] = {
|
48
|
+
address1: bill_addr.address1,
|
49
|
+
city: bill_addr.city,
|
50
|
+
state: bill_addr.state ? bill_addr.state.name : bill_addr.state_name,
|
51
|
+
country: bill_addr.country.iso3,
|
52
|
+
zip: bill_addr.zipcode
|
53
|
+
}
|
54
|
+
end
|
55
|
+
|
56
|
+
return o
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,126 @@
|
|
1
|
+
module Spree
|
2
|
+
class Gateway::StripeGateway < Gateway
|
3
|
+
preference :secret_key, :string
|
4
|
+
preference :publishable_key, :string
|
5
|
+
|
6
|
+
CARD_TYPE_MAPPING = {
|
7
|
+
'American Express' => 'american_express',
|
8
|
+
'Diners Club' => 'diners_club',
|
9
|
+
'Visa' => 'visa'
|
10
|
+
}
|
11
|
+
|
12
|
+
def method_type
|
13
|
+
'stripe'
|
14
|
+
end
|
15
|
+
|
16
|
+
def provider_class
|
17
|
+
ActiveMerchant::Billing::StripeGateway
|
18
|
+
end
|
19
|
+
|
20
|
+
def payment_profiles_supported?
|
21
|
+
true
|
22
|
+
end
|
23
|
+
|
24
|
+
def purchase(money, creditcard, gateway_options)
|
25
|
+
provider.purchase(*options_for_purchase_or_auth(money, creditcard, gateway_options))
|
26
|
+
end
|
27
|
+
|
28
|
+
def authorize(money, creditcard, gateway_options)
|
29
|
+
provider.authorize(*options_for_purchase_or_auth(money, creditcard, gateway_options))
|
30
|
+
end
|
31
|
+
|
32
|
+
def capture(money, response_code, gateway_options)
|
33
|
+
provider.capture(money, response_code, gateway_options)
|
34
|
+
end
|
35
|
+
|
36
|
+
def credit(money, creditcard, response_code, gateway_options)
|
37
|
+
provider.refund(money, response_code, {})
|
38
|
+
end
|
39
|
+
|
40
|
+
def void(response_code, creditcard, gateway_options)
|
41
|
+
provider.void(response_code, {})
|
42
|
+
end
|
43
|
+
|
44
|
+
def cancel(response_code)
|
45
|
+
provider.void(response_code, {})
|
46
|
+
end
|
47
|
+
|
48
|
+
def create_profile(payment)
|
49
|
+
return unless payment.source.gateway_customer_profile_id.nil?
|
50
|
+
options = {
|
51
|
+
email: payment.order.email,
|
52
|
+
login: preferred_secret_key,
|
53
|
+
}.merge! address_for(payment)
|
54
|
+
|
55
|
+
source = update_source!(payment.source)
|
56
|
+
if source.number.blank? && source.gateway_payment_profile_id.present?
|
57
|
+
creditcard = source.gateway_payment_profile_id
|
58
|
+
else
|
59
|
+
creditcard = source
|
60
|
+
end
|
61
|
+
|
62
|
+
response = provider.store(creditcard, options)
|
63
|
+
if response.success?
|
64
|
+
payment.source.update_attributes!({
|
65
|
+
cc_type: payment.source.cc_type, # side-effect of update_source!
|
66
|
+
gateway_customer_profile_id: response.params['id'],
|
67
|
+
gateway_payment_profile_id: response.params['default_source'] || response.params['default_card']
|
68
|
+
})
|
69
|
+
|
70
|
+
else
|
71
|
+
payment.send(:gateway_error, response.message)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
private
|
76
|
+
|
77
|
+
# In this gateway, what we call 'secret_key' is the 'login'
|
78
|
+
def options
|
79
|
+
options = super
|
80
|
+
options.merge(:login => preferred_secret_key)
|
81
|
+
end
|
82
|
+
|
83
|
+
def options_for_purchase_or_auth(money, creditcard, gateway_options)
|
84
|
+
options = {}
|
85
|
+
options[:description] = "Spree Order ID: #{gateway_options[:order_id]}"
|
86
|
+
options[:currency] = gateway_options[:currency]
|
87
|
+
|
88
|
+
if customer = creditcard.gateway_customer_profile_id
|
89
|
+
options[:customer] = customer
|
90
|
+
end
|
91
|
+
if token_or_card_id = creditcard.gateway_payment_profile_id
|
92
|
+
# The Stripe ActiveMerchant gateway supports passing the token directly as the creditcard parameter
|
93
|
+
# The Stripe ActiveMerchant gateway supports passing the customer_id and credit_card id
|
94
|
+
# https://github.com/Shopify/active_merchant/issues/770
|
95
|
+
creditcard = token_or_card_id
|
96
|
+
end
|
97
|
+
return money, creditcard, options
|
98
|
+
end
|
99
|
+
|
100
|
+
def address_for(payment)
|
101
|
+
{}.tap do |options|
|
102
|
+
if address = payment.order.bill_address
|
103
|
+
options.merge!(address: {
|
104
|
+
address1: address.address1,
|
105
|
+
address2: address.address2,
|
106
|
+
city: address.city,
|
107
|
+
zip: address.zipcode
|
108
|
+
})
|
109
|
+
|
110
|
+
if country = address.country
|
111
|
+
options[:address].merge!(country: country.name)
|
112
|
+
end
|
113
|
+
|
114
|
+
if state = address.state
|
115
|
+
options[:address].merge!(state: state.name)
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
def update_source!(source)
|
122
|
+
source.cc_type = CARD_TYPE_MAPPING[source.cc_type] if CARD_TYPE_MAPPING.include?(source.cc_type)
|
123
|
+
source
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
module Spree
|
2
|
+
class Gateway::Worldpay < Gateway
|
3
|
+
preference :login, :string
|
4
|
+
preference :password, :string
|
5
|
+
preference :currency, :string, :default => 'GBP'
|
6
|
+
preference :installation_id, :string
|
7
|
+
|
8
|
+
preference :american_express_login, :string
|
9
|
+
preference :discover_login, :string
|
10
|
+
preference :jcb_login, :string
|
11
|
+
preference :mastercard_login, :string
|
12
|
+
preference :maestro_login, :string
|
13
|
+
preference :visa_login, :string
|
14
|
+
|
15
|
+
def provider_class
|
16
|
+
ActiveMerchant::Billing::WorldpayGateway
|
17
|
+
end
|
18
|
+
|
19
|
+
def purchase(money, credit_card, options = {})
|
20
|
+
provider = credit_card_provider(credit_card, options)
|
21
|
+
provider.purchase(money, credit_card, options)
|
22
|
+
end
|
23
|
+
|
24
|
+
def authorize(money, credit_card, options = {})
|
25
|
+
provider = credit_card_provider(credit_card, options)
|
26
|
+
provider.authorize(money, credit_card, options)
|
27
|
+
end
|
28
|
+
|
29
|
+
def capture(money, authorization, options = {})
|
30
|
+
provider = credit_card_provider(auth_credit_card(authorization), options)
|
31
|
+
provider.capture(money, authorization, options)
|
32
|
+
end
|
33
|
+
|
34
|
+
def refund(money, authorization, options = {})
|
35
|
+
provider = credit_card_provider(auth_credit_card(authorization), options)
|
36
|
+
provider.refund(money, authorization, options)
|
37
|
+
end
|
38
|
+
|
39
|
+
def credit(money, authorization, options = {})
|
40
|
+
refund(money, authorization, options)
|
41
|
+
end
|
42
|
+
|
43
|
+
def void(authorization, options = {})
|
44
|
+
provider = credit_card_provider(auth_credit_card(authorization), options)
|
45
|
+
provider.void(authorization, options)
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def options_for_card(credit_card, options)
|
51
|
+
options[:login] = login_for_card(credit_card)
|
52
|
+
options = options().merge( options )
|
53
|
+
end
|
54
|
+
|
55
|
+
def auth_credit_card(authorization)
|
56
|
+
Spree::Payment.find_by_response_code(authorization).source
|
57
|
+
end
|
58
|
+
|
59
|
+
def credit_card_provider(credit_card, options = {})
|
60
|
+
gateway_options = options_for_card(credit_card, options)
|
61
|
+
gateway_options.delete :login if gateway_options.has_key?(:login) and gateway_options[:login].nil?
|
62
|
+
gateway_options[:currency] = self.preferred_currency
|
63
|
+
gateway_options[:inst_id] = self.preferred_installation_id
|
64
|
+
ActiveMerchant::Billing::Base.gateway_mode = gateway_options[:server].to_sym
|
65
|
+
@provider = provider_class.new(gateway_options)
|
66
|
+
end
|
67
|
+
|
68
|
+
def login_for_card(card)
|
69
|
+
case card.brand
|
70
|
+
when 'american_express'
|
71
|
+
choose_login preferred_american_express_login
|
72
|
+
when 'discover'
|
73
|
+
choose_login preferred_discover_login
|
74
|
+
when 'jcb'
|
75
|
+
choose_login preferred_jcb_login
|
76
|
+
when 'maestro'
|
77
|
+
choose_login preferred_maestro_login
|
78
|
+
when 'master'
|
79
|
+
choose_login preferred_mastercard_login
|
80
|
+
when 'visa'
|
81
|
+
choose_login preferred_visa_login
|
82
|
+
else
|
83
|
+
preferred_login
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def choose_login(login)
|
88
|
+
return login ? login : preferred_login
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Spree
|
2
|
+
class SkrillTransaction < ActiveRecord::Base
|
3
|
+
has_many :payments, :as => :source
|
4
|
+
|
5
|
+
def actions
|
6
|
+
[]
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.create_from_postback(params)
|
10
|
+
SkrillTransaction.create(:email => params[:pay_from_email],
|
11
|
+
:amount => params[:mb_amount],
|
12
|
+
:currency => params[:mb_currency],
|
13
|
+
:transaction_id => params[:mb_transaction_id],
|
14
|
+
:customer_id => params[:customer_id],
|
15
|
+
:payment_type => params[:payment_type])
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|