Created
May 5, 2009 18:23
-
-
Save ssoper/107102 to your computer and use it in GitHub Desktop.
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
module OverwritePayflowAPI | |
def self.included(base) | |
base.alias_method_chain :commit, :retry | |
end | |
def commit_with_retry(request_body, request_type = nil) | |
# Payflow Pro purchases by reference have a habit of failing in tests, probably due to speed with which tests are executed. | |
# This ensures that the purchase is attempted a maximum number of times with a 1-sec sleep in between. This feature can be | |
# turned off by calling 'disable_ensure_purchase' in your test. | |
result = commit_without_retry(request_body, request_type) | |
10.times do | |
return result if result.success? | |
result = commit_without_retry(request_body, request_type) | |
sleep(1) | |
end unless ENV['DISABLE_ENSURE_PURCHASE'] | |
return result | |
end | |
end | |
ActiveMerchant::Billing::PayflowCommonAPI.send(:include, OverwritePayflowAPI) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment