spree_first_data_gge4 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +14 -0
  3. data/.rspec +1 -0
  4. data/Gemfile +7 -0
  5. data/LICENSE +26 -0
  6. data/README.md +39 -0
  7. data/Rakefile +21 -0
  8. data/app/assets/javascripts/spree/backend/spree_first_data_gge4.js +2 -0
  9. data/app/assets/javascripts/spree/frontend/spree_first_data_gge4.js +2 -0
  10. data/app/assets/stylesheets/spree/backend/spree_first_data_gge4.css +4 -0
  11. data/app/assets/stylesheets/spree/frontend/spree_first_data_gge4.css +4 -0
  12. data/app/models/spree/billing_integration.rb +21 -0
  13. data/app/models/spree/billing_integration/skrill/quick_checkout.rb +48 -0
  14. data/app/models/spree/gateway/authorize_net_cim.rb +213 -0
  15. data/app/models/spree/gateway/firstdata_e4.rb +12 -0
  16. data/app/models/spree/gateway/worldpay.rb +91 -0
  17. data/app/models/spree/skrill_transaction.rb +19 -0
  18. data/bin/rails +7 -0
  19. data/config/locales/en.yml +5 -0
  20. data/config/routes.rb +13 -0
  21. data/db/migrate/20111118164631_create_skrill_transactions.rb +13 -0
  22. data/db/migrate/20121017004102_update_braintree_payment_method_type.rb +9 -0
  23. data/db/migrate/20130213222555_update_stripe_payment_method_type.rb +9 -0
  24. data/db/migrate/20130415222802_update_balanced_payment_method_type.rb +9 -0
  25. data/db/migrate/20131008221012_update_paypal_payment_method_type.rb +9 -0
  26. data/db/migrate/20131112133401_migrate_stripe_preferences.rb +8 -0
  27. data/db/migrate/20150507111350_add_first_datae4_field_to_payment_method.rb +9 -0
  28. data/lib/active_merchant/billing/skrill.rb +18 -0
  29. data/lib/assets/javascripts/spree/frontend/spree_gateway.js +1 -0
  30. data/lib/assets/stylesheets/spree/frontend/spree_gateway.css +3 -0
  31. data/lib/controllers/frontend/spree/checkout_controller_decorator.rb +51 -0
  32. data/lib/controllers/frontend/spree/skrill_status_controller.rb +39 -0
  33. data/lib/generators/spree_first_data_gge4/install/install_generator.rb +31 -0
  34. data/lib/spree_first_data_gge4.rb +4 -0
  35. data/lib/spree_first_data_gge4/engine.rb +20 -0
  36. data/lib/spree_first_data_gge4/factories.rb +6 -0
  37. data/lib/views/backend/spree/admin/log_entries/_braintree.html.erb +31 -0
  38. data/lib/views/backend/spree/admin/log_entries/_stripe.html.erb +28 -0
  39. data/lib/views/backend/spree/admin/payments/source_forms/_quickcheckout.html.erb +8 -0
  40. data/lib/views/backend/spree/admin/payments/source_forms/_stripe.html.erb +1 -0
  41. data/lib/views/backend/spree/admin/payments/source_views/_quickcheckout.html.erb +39 -0
  42. data/lib/views/backend/spree/admin/payments/source_views/_stripe.html.erb +1 -0
  43. data/lib/views/frontend/spree/checkout/payment/_quickcheckout.html.erb +26 -0
  44. data/lib/views/frontend/spree/checkout/payment/_stripe.html.erb +90 -0
  45. data/spec/spec_helper.rb +87 -0
  46. data/spree_first_data_gge4.gemspec +39 -0
  47. metadata +270 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4d1e67b68700d741e339b31ded55d0dd7cb44cd9
4
+ data.tar.gz: cc6cd1406fcab82ee5e9656b8bcf600cbafd9e44
5
+ SHA512:
6
+ metadata.gz: 267a78fd9fe0a7ae711366b5062d066693171cdab8a81c5c4150a9b41bfb47972f78ba1a5f2632ec7bc8509ddb82a23741ef275516d5da4245c181afd545050c
7
+ data.tar.gz: 8ee7d1314833bd23e71a2fa70aaa9102ea2472c11ddf0ee0ef440d8457ef2e76866ae1e258f75bbaaedf2548b64dc96a174ccff22637434ed61c742db42630e4
@@ -0,0 +1,14 @@
1
+ \#*
2
+ *~
3
+ .#*
4
+ .DS_Store
5
+ .idea
6
+ .project
7
+ .sass-cache
8
+ coverage
9
+ Gemfile.lock
10
+ tmp
11
+ nbproject
12
+ pkg
13
+ *.swp
14
+ spec/dummy
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'spree', github: 'spree/spree', branch: '3-0-stable'
4
+ # Provides basic authentication functionality for testing parts of your engine
5
+ gem 'spree_auth_devise', github: 'spree/spree_auth_devise', branch: '3-0-stable'
6
+
7
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,26 @@
1
+ Copyright (c) 2015 [name of plugin creator]
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without modification,
5
+ are permitted provided that the following conditions are met:
6
+
7
+ * Redistributions of source code must retain the above copyright notice,
8
+ this list of conditions and the following disclaimer.
9
+ * Redistributions in binary form must reproduce the above copyright notice,
10
+ this list of conditions and the following disclaimer in the documentation
11
+ and/or other materials provided with the distribution.
12
+ * Neither the name Spree nor the names of its contributors may be used to
13
+ endorse or promote products derived from this software without specific
14
+ prior written permission.
15
+
16
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
20
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,39 @@
1
+ SpreeFirstDataGge4
2
+ ==================
3
+
4
+ Introduction goes here.
5
+
6
+ Installation
7
+ ------------
8
+
9
+ Add spree_first_data_gge4 to your Gemfile:
10
+
11
+ ```ruby
12
+ gem 'spree_first_data_gge4'
13
+ ```
14
+
15
+ Bundle your dependencies and run the installation generator:
16
+
17
+ ```shell
18
+ bundle
19
+ bundle exec rails g spree_first_data_gge4:install
20
+ ```
21
+
22
+ Testing
23
+ -------
24
+
25
+ First bundle your dependencies, then run `rake`. `rake` will default to building the dummy app if it does not exist, then it will run specs. The dummy app can be regenerated by using `rake test_app`.
26
+
27
+ ```shell
28
+ bundle
29
+ bundle exec rake
30
+ ```
31
+
32
+ When testing your applications integration with this extension you may use it's factories.
33
+ Simply add this require statement to your spec_helper:
34
+
35
+ ```ruby
36
+ require 'spree_first_data_gge4/factories'
37
+ ```
38
+
39
+ Copyright (c) 2015 [name of extension creator], released under the New BSD License
@@ -0,0 +1,21 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ require 'rspec/core/rake_task'
5
+ require 'spree/testing_support/extension_rake'
6
+
7
+ RSpec::Core::RakeTask.new
8
+
9
+ task :default do
10
+ if Dir["spec/dummy"].empty?
11
+ Rake::Task[:test_app].invoke
12
+ Dir.chdir("../../")
13
+ end
14
+ Rake::Task[:spec].invoke
15
+ end
16
+
17
+ desc 'Generates a dummy app for testing'
18
+ task :test_app do
19
+ ENV['LIB_NAME'] = 'spree_first_data_gge4'
20
+ Rake::Task['extension:test_app'].invoke
21
+ end
@@ -0,0 +1,2 @@
1
+ // Placeholder manifest file.
2
+ // the installer will append this file to the app vendored assets here: vendor/assets/javascripts/spree/backend/all.js'
@@ -0,0 +1,2 @@
1
+ // Placeholder manifest file.
2
+ // the installer will append this file to the app vendored assets here: vendor/assets/javascripts/spree/frontend/all.js'
@@ -0,0 +1,4 @@
1
+ /*
2
+ Placeholder manifest file.
3
+ the installer will append this file to the app vendored assets here: 'vendor/assets/stylesheets/spree/backend/all.css'
4
+ */
@@ -0,0 +1,4 @@
1
+ /*
2
+ Placeholder manifest file.
3
+ the installer will append this file to the app vendored assets here: 'vendor/assets/stylesheets/spree/frontend/all.css'
4
+ */
@@ -0,0 +1,21 @@
1
+ module Spree
2
+ class BillingIntegration < PaymentMethod
3
+ validates :name, presence: true
4
+
5
+ preference :server, :string, default: 'test'
6
+ preference :test_mode, :boolean, default: true
7
+
8
+ def provider
9
+ integration_options = options
10
+ ActiveMerchant::Billing::Base.integration_mode = integration_options[:server].to_sym
11
+ integration_options[:test] = true if integration_options[:test_mode]
12
+ @provider ||= provider_class.new(integration_options)
13
+ end
14
+
15
+ def options
16
+ options_hash = {}
17
+ preferences.each { |key, value| options_hash[key.to_sym] = value }
18
+ options_hash
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,48 @@
1
+ module Spree
2
+ class BillingIntegration::Skrill::QuickCheckout < BillingIntegration
3
+ preference :merchant_id, :string
4
+ preference :language, :string, :default => 'EN'
5
+ preference :currency, :string, :default => 'EUR'
6
+ preference :payment_options, :string, :default => 'ACC'
7
+ preference :pay_to_email, :string , :default => 'your@merchant.email_here'
8
+
9
+ def provider_class
10
+ ActiveMerchant::Billing::Skrill
11
+ end
12
+
13
+ def redirect_url(order, opts = {})
14
+ opts.merge! self.preferences
15
+
16
+ set_global_options(opts)
17
+
18
+ opts[:detail1_text] = order.number
19
+ opts[:detail1_description] = "Order:"
20
+
21
+ opts[:pay_from_email] = order.email
22
+ opts[:firstname] = order.bill_address.firstname
23
+ opts[:lastname] = order.bill_address.lastname
24
+ opts[:address] = order.bill_address.address1
25
+ opts[:address2] = order.bill_address.address2
26
+ opts[:phone_number] = order.bill_address.phone.gsub(/\D/,'') if order.bill_address.phone
27
+ opts[:city] = order.bill_address.city
28
+ opts[:postal_code] = order.bill_address.zipcode
29
+ opts[:state] = order.bill_address.state.nil? ? order.bill_address.state_name.to_s : order.bill_address.state.abbr
30
+ opts[:country] = order.bill_address.country.name
31
+ opts[:pay_to_email] = self.preferred_pay_to_email
32
+ opts[:hide_login] = 1
33
+ opts[:merchant_fields] = 'platform,order_id,payment_method_id'
34
+ opts[:platform] = 'Spree'
35
+ opts[:order_id] = order.number
36
+
37
+ skrill = self.provider
38
+ skrill.payment_url(opts)
39
+ end
40
+
41
+ private
42
+ def set_global_options(opts)
43
+ opts[:recipient_description] = Spree::Config[:site_name]
44
+ opts[:payment_methods] = self.preferred_payment_options
45
+ end
46
+
47
+ end
48
+ end
@@ -0,0 +1,213 @@
1
+ module Spree
2
+ class Gateway::AuthorizeNetCim < Gateway
3
+ preference :login, :string
4
+ preference :password, :string
5
+ preference :server, :string, default: "test"
6
+ preference :test_mode, :boolean, default: false
7
+ preference :validate_on_profile_create, :boolean, default: false
8
+
9
+ ActiveMerchant::Billing::Response.class_eval do
10
+ attr_writer :authorization
11
+ end
12
+
13
+ def provider_class
14
+ self.class
15
+ end
16
+
17
+ def options
18
+ if !['live','test'].include?(self.preferred_server)
19
+ raise "You must set the 'server' preference in your payment method (Gateway::AuthorizeNetCim) to either 'live' or 'test'"
20
+ end
21
+
22
+ # add :test key in the options hash, as that is what the
23
+ # ActiveMerchant::Billing::AuthorizeNetGateway expects
24
+ if self.preferred_server != "live"
25
+ self.preferences[:test] = true
26
+ else
27
+ self.preferences.delete(:test)
28
+ end
29
+
30
+ super
31
+ end
32
+
33
+ def authorize(amount, creditcard, gateway_options)
34
+ create_transaction(amount, creditcard, :auth_only, transaction_options(gateway_options))
35
+ end
36
+
37
+ def purchase(amount, creditcard, gateway_options)
38
+ create_transaction(amount, creditcard, :auth_capture, transaction_options(gateway_options))
39
+ end
40
+
41
+ # capture is only one where source is not passed in for payment profile
42
+ def capture(amount, response_code, gateway_options)
43
+ # no credit card needed
44
+ create_transaction(amount, nil, :prior_auth_capture, trans_id: response_code)
45
+ end
46
+
47
+ def credit(amount, creditcard, response_code, gateway_options = {})
48
+ create_transaction(amount, creditcard, :refund, transaction_options(gateway_options).merge(trans_id: response_code))
49
+ end
50
+
51
+ def void(response_code, creditcard, gateway_options = {})
52
+ create_transaction(nil, creditcard, :void, transaction_options(gateway_options).merge(trans_id: response_code))
53
+ end
54
+
55
+ def cancel(response_code)
56
+ # From: http://community.developer.authorize.net/t5/The-Authorize-Net-Developer-Blog/Refunds-in-Retail-A-user-friendly-approach-using-AIM/ba-p/9848
57
+ # DD: if unsettled, void needed
58
+ response = void(response_code, nil)
59
+ # DD: if settled, credit/refund needed
60
+ response = credit(nil, nil, response_code) unless response.success?
61
+
62
+ response
63
+ end
64
+
65
+ def payment_profiles_supported?
66
+ true
67
+ end
68
+
69
+ # Create a new CIM customer profile ready to accept a payment. Called by Spree::Payment on after_save.
70
+ def create_profile(payment)
71
+ if payment.source.gateway_customer_profile_id.nil?
72
+ profile_hash = create_customer_profile(payment)
73
+ payment.source.update_attributes(gateway_customer_profile_id: profile_hash[:customer_profile_id], gateway_payment_profile_id: profile_hash[:customer_payment_profile_id])
74
+ end
75
+ end
76
+
77
+ # Get the CIM payment profile; Needed for updates.
78
+ def get_profile(payment)
79
+ if payment.source.has_payment_profile?
80
+ profile = cim_gateway.get_customer_profile({
81
+ customer_profile_id: payment.source.gateway_customer_profile_id
82
+ })
83
+ if profile
84
+ profile.params['profile'].deep_symbolize_keys!
85
+ end
86
+ end
87
+ end
88
+
89
+ # Get the CIM payment profile; Needed for updates.
90
+ def get_payment_profile(payment)
91
+ if payment.source.has_payment_profile?
92
+ profile = cim_gateway.get_customer_payment_profile({
93
+ customer_profile_id: payment.source.gateway_customer_profile_id,
94
+ customer_payment_profile_id: payment.source.gateway_payment_profile_id
95
+ })
96
+ if profile
97
+ profile.params['payment_profile'].deep_symbolize_keys!
98
+ end
99
+ end
100
+ end
101
+
102
+ # Update billing address on the CIM payment profile
103
+ def update_payment_profile(payment)
104
+ if payment.source.has_payment_profile?
105
+ if hash = get_payment_profile(payment)
106
+ hash[:bill_to] = generate_address_hash(payment.order.bill_address)
107
+ if hash[:payment][:credit_card]
108
+ # activemerchant expects a credit card object with 'number', 'year', 'month', and 'verification_value?' defined
109
+ payment.source.define_singleton_method(:number) { "XXXXXXXXX#{payment.source.last_digits}" }
110
+ hash[:payment][:credit_card] = payment.source
111
+ end
112
+ cim_gateway.update_customer_payment_profile({
113
+ customer_profile_id: payment.source.gateway_customer_profile_id,
114
+ payment_profile: hash
115
+ })
116
+ end
117
+ end
118
+ end
119
+
120
+ private
121
+
122
+ def transaction_options(gateway_options = {})
123
+ { order: { invoice_number: gateway_options[:order_id] } }
124
+ end
125
+
126
+ # Create a transaction on a creditcard
127
+ # Set up a CIM profile for the card if one doesn't exist
128
+ # Valid transaction_types are :auth_only, :capture_only and :auth_capture
129
+ def create_transaction(amount, creditcard, transaction_type, options = {})
130
+ creditcard.save if creditcard
131
+
132
+ transaction_options = {
133
+ type: transaction_type
134
+ }.update(options)
135
+
136
+ if amount
137
+ amount = "%.2f" % (amount / 100.0) # This gateway requires formated decimal, not cents
138
+ transaction_options.update({
139
+ amount: amount
140
+ })
141
+ end
142
+
143
+ if creditcard
144
+ transaction_options.update({
145
+ customer_profile_id: creditcard.gateway_customer_profile_id,
146
+ customer_payment_profile_id: creditcard.gateway_payment_profile_id
147
+ })
148
+ end
149
+
150
+ logger.debug("\nAuthorize Net CIM Request")
151
+ logger.debug(" transaction_options: #{transaction_options.inspect}")
152
+ t = cim_gateway.create_customer_profile_transaction(transaction: transaction_options)
153
+ logger.debug("\nAuthorize Net CIM Response")
154
+ logger.debug(" response: #{t.inspect}\n")
155
+ t
156
+ end
157
+
158
+ # Create a new CIM customer profile ready to accept a payment
159
+ def create_customer_profile(payment)
160
+ options = options_for_create_customer_profile(payment)
161
+ response = cim_gateway.create_customer_profile(options)
162
+ if response.success?
163
+ { customer_profile_id: response.params['customer_profile_id'],
164
+ customer_payment_profile_id: response.params['customer_payment_profile_id_list'].values.first }
165
+ else
166
+ payment.send(:gateway_error, response)
167
+ end
168
+ end
169
+
170
+ def options_for_create_customer_profile(payment)
171
+ if payment.is_a? CreditCard
172
+ info = { bill_to: generate_address_hash(payment.address),
173
+ payment: { credit_card: payment } }
174
+ else
175
+ info = { bill_to: generate_address_hash(payment.order.bill_address),
176
+ payment: { credit_card: payment.source } }
177
+ end
178
+ validation_mode = preferred_validate_on_profile_create ? preferred_server.to_sym : :none
179
+
180
+ { profile: { merchant_customer_id: "#{Time.now.to_f}",
181
+ ship_to_list: generate_address_hash(payment.order.ship_address),
182
+ email: payment.order.email,
183
+ payment_profiles: info },
184
+ validation_mode: validation_mode }
185
+ end
186
+
187
+ # As in PaymentGateway but with separate name fields
188
+ def generate_address_hash(address)
189
+ return {} if address.nil?
190
+ {
191
+ first_name: address.firstname,
192
+ last_name: address.lastname,
193
+ address1: address.address1,
194
+ address2: address.address2,
195
+ city: address.city,
196
+ state: address.state_text,
197
+ zip: address.zipcode,
198
+ country: address.country.iso,
199
+ phone_number: address.phone
200
+ }
201
+ end
202
+
203
+ def cim_gateway
204
+ @_cim_gateway ||= begin
205
+ ActiveMerchant::Billing::Base.gateway_mode = preferred_server.to_sym
206
+ gateway_options = options
207
+ gateway_options[:test_requests] = false # DD: never ever do test requests because just returns transaction_id = 0
208
+ ActiveMerchant::Billing::AuthorizeNetCimGateway.new(gateway_options)
209
+ end
210
+ end
211
+
212
+ end
213
+ end
@@ -0,0 +1,12 @@
1
+ module Spree
2
+ class Gateway::FirstdataE4 < Gateway
3
+ preference :login, :string
4
+ preference :password, :password
5
+
6
+
7
+ def provider_class
8
+ ActiveMerchant::Billing::FirstdataE4Gateway
9
+ end
10
+ end
11
+ end
12
+
@@ -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