This repository has been archived by the owner on Sep 10, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 61
adds comments about confusing test mode nomenclature mis-match… #26
Open
jasonfb
wants to merge
1
commit into
solidusio:master
Choose a base branch
from
jasonfb:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,14 +2,27 @@ module Spree | |
class Gateway::AuthorizeNet < Gateway | ||
preference :login, :string | ||
preference :password, :string | ||
preference :server, :string, :default => "live" | ||
|
||
# WARNING: Unlike other payment integrations, 'test mode' in Authorize Net's termiminology does not mean use test server | ||
# instead, use preferred server set to either 'live' or 'test' | ||
# DO NOT TURN TEST MODE TO ON (EVEN IN QA/STAGING ENVIRONMENTS), it will return 0 as transaction ids under all circumstances | ||
|
||
# here, it overloads the setting on the base class, which confusingly defaults to true | ||
preference :test_mode, :boolean, :default => false | ||
|
||
def provider_class | ||
ActiveMerchant::Billing::AuthorizeNetGateway | ||
end | ||
|
||
def options_with_test_preference | ||
options_without_test_preference.merge(test: self.preferred_test_mode) | ||
if !['live','test'].include?(self.preferred_server) | ||
ActiveSupport::Deprecation.warn("You must set your preferred server to either 'live' or 'test'") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it would be more appropriate to throw an exception here. If someone has this misconfigured it would not behave as expected. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My original implementation was to raise but @jhawthorn asked me to change it to be a Warning. |
||
end | ||
# warning: 'test' parameter indicates live or test server; it DOES NOT indicate Authorize.net test-mode | ||
options_without_test_preference.merge(:test => (self.preferred_server != "live") ) | ||
end | ||
|
||
alias_method_chain :options, :test_preference | ||
|
||
def credit(amount, response_code, refund, gateway_options = {}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we want this to always be false, maybe we should override the implementation of preferred_test_mode to always return false.