authorizenet 1.9.4 → 1.9.5
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.
- data/lib/app/helpers/authorize_net_helper.rb +2 -3
- data/lib/authorize_net.rb +5 -5
- data/lib/authorize_net/addresses/address.rb +15 -19
- data/lib/authorize_net/addresses/shipping_address.rb +12 -16
- data/lib/authorize_net/aim/response.rb +27 -38
- data/lib/authorize_net/aim/transaction.rb +46 -65
- data/lib/authorize_net/api/api_transaction.rb +85 -90
- data/lib/authorize_net/api/constants.yml +1 -1
- data/lib/authorize_net/api/schema.rb +968 -936
- data/lib/authorize_net/api/transaction.rb +100 -102
- data/lib/authorize_net/arb/fields.rb +21 -21
- data/lib/authorize_net/arb/paging.rb +7 -11
- data/lib/authorize_net/arb/response.rb +7 -15
- data/lib/authorize_net/arb/sorting.rb +6 -10
- data/lib/authorize_net/arb/subscription.rb +27 -31
- data/lib/authorize_net/arb/subscription_detail.rb +1 -5
- data/lib/authorize_net/arb/subscription_list_response.rb +13 -20
- data/lib/authorize_net/arb/transaction.rb +50 -56
- data/lib/authorize_net/authorize_net.rb +20 -27
- data/lib/authorize_net/cim/customer_profile.rb +4 -8
- data/lib/authorize_net/cim/payment_profile.rb +10 -12
- data/lib/authorize_net/cim/response.rb +19 -24
- data/lib/authorize_net/cim/transaction.rb +168 -174
- data/lib/authorize_net/customer.rb +11 -14
- data/lib/authorize_net/email_receipt.rb +8 -12
- data/lib/authorize_net/fields.rb +483 -502
- data/lib/authorize_net/key_value_response.rb +54 -62
- data/lib/authorize_net/key_value_transaction.rb +87 -97
- data/lib/authorize_net/line_item.rb +10 -14
- data/lib/authorize_net/order.rb +21 -25
- data/lib/authorize_net/payment_methods/credit_card.rb +6 -7
- data/lib/authorize_net/payment_methods/echeck.rb +29 -31
- data/lib/authorize_net/reporting/batch.rb +4 -7
- data/lib/authorize_net/reporting/batch_statistics.rb +2 -6
- data/lib/authorize_net/reporting/fds_filter.rb +2 -5
- data/lib/authorize_net/reporting/response.rb +54 -60
- data/lib/authorize_net/reporting/returned_item.rb +11 -12
- data/lib/authorize_net/reporting/transaction.rb +27 -29
- data/lib/authorize_net/reporting/transaction_details.rb +3 -6
- data/lib/authorize_net/response.rb +6 -10
- data/lib/authorize_net/sim/hosted_payment_form.rb +16 -20
- data/lib/authorize_net/sim/hosted_receipt_page.rb +18 -23
- data/lib/authorize_net/sim/response.rb +24 -33
- data/lib/authorize_net/sim/transaction.rb +33 -43
- data/lib/authorize_net/transaction.rb +15 -21
- data/lib/authorize_net/xml_response.rb +36 -54
- data/lib/authorize_net/xml_transaction.rb +115 -134
- data/lib/generators/authorize_net/direct_post/direct_post_generator.rb +5 -6
- data/lib/generators/authorize_net/sim/sim_generator.rb +6 -7
- data/lib/generators/generator_extensions.rb +23 -25
- metadata +127 -81
- checksums.yaml +0 -7
| @@ -1,117 +1,109 @@ | |
| 1 1 | 
             
            module AuthorizeNet
         | 
| 2 | 
            -
              
         | 
| 3 2 | 
             
              # The core, key/value response class. You shouldn't instantiate this one.
         | 
| 4 3 | 
             
              # Instead you should use AuthorizeNet::AIM::Response or AuthorizeNet::SIM::Response.
         | 
| 5 4 | 
             
              class KeyValueResponse < AuthorizeNet::Response
         | 
| 6 | 
            -
                
         | 
| 7 5 | 
             
                # Defines constants for each response code.
         | 
| 8 6 | 
             
                module ResponseCode
         | 
| 9 | 
            -
                  APPROVED = '1'
         | 
| 10 | 
            -
                  DECLINED = '2'
         | 
| 11 | 
            -
                  ERROR = '3'
         | 
| 12 | 
            -
                  HELD = '4'
         | 
| 7 | 
            +
                  APPROVED = '1'.freeze
         | 
| 8 | 
            +
                  DECLINED = '2'.freeze
         | 
| 9 | 
            +
                  ERROR = '3'.freeze
         | 
| 10 | 
            +
                  HELD = '4'.freeze
         | 
| 13 11 | 
             
                end
         | 
| 14 | 
            -
             | 
| 12 | 
            +
             | 
| 15 13 | 
             
                # Defines constants for each address verification response code.
         | 
| 16 14 | 
             
                module AVSResponseCode
         | 
| 17 | 
            -
                  ADDRESS_MATCH_NOT_ZIP = 'A'
         | 
| 18 | 
            -
                  NO_INFO = 'B'
         | 
| 19 | 
            -
                  ERROR = 'E'
         | 
| 20 | 
            -
                  NON_US = 'G'
         | 
| 21 | 
            -
                  NO_MATCH = 'N'
         | 
| 22 | 
            -
                  NOT_APPLICABLE = 'P'
         | 
| 23 | 
            -
                  RETRY = 'R'
         | 
| 24 | 
            -
                  NOT_SUPPOPRTED = 'S'
         | 
| 25 | 
            -
                  UNAVAILABLE = 'U'
         | 
| 26 | 
            -
                  ZIP9_MATCH_NOT_ADDRESS = 'W'
         | 
| 27 | 
            -
                  ADDRESS_AND_ZIP9_MATCH = 'X'
         | 
| 28 | 
            -
                  ADDRESS_AND_ZIP5_MATCH = 'Y'
         | 
| 29 | 
            -
                  ZIP5_MATCH_NOT_ADDRESS = 'Z'
         | 
| 15 | 
            +
                  ADDRESS_MATCH_NOT_ZIP = 'A'.freeze
         | 
| 16 | 
            +
                  NO_INFO = 'B'.freeze
         | 
| 17 | 
            +
                  ERROR = 'E'.freeze
         | 
| 18 | 
            +
                  NON_US = 'G'.freeze
         | 
| 19 | 
            +
                  NO_MATCH = 'N'.freeze
         | 
| 20 | 
            +
                  NOT_APPLICABLE = 'P'.freeze
         | 
| 21 | 
            +
                  RETRY = 'R'.freeze
         | 
| 22 | 
            +
                  NOT_SUPPOPRTED = 'S'.freeze
         | 
| 23 | 
            +
                  UNAVAILABLE = 'U'.freeze
         | 
| 24 | 
            +
                  ZIP9_MATCH_NOT_ADDRESS = 'W'.freeze
         | 
| 25 | 
            +
                  ADDRESS_AND_ZIP9_MATCH = 'X'.freeze
         | 
| 26 | 
            +
                  ADDRESS_AND_ZIP5_MATCH = 'Y'.freeze
         | 
| 27 | 
            +
                  ZIP5_MATCH_NOT_ADDRESS = 'Z'.freeze
         | 
| 30 28 | 
             
                end
         | 
| 31 | 
            -
             | 
| 29 | 
            +
             | 
| 32 30 | 
             
                # Defines constants for each supported credit card type.
         | 
| 33 31 | 
             
                module CardType
         | 
| 34 | 
            -
                  VISA = 'Visa'
         | 
| 35 | 
            -
                  MASTER_CARD = 'MasterCard'
         | 
| 36 | 
            -
                  AMEX = 'American Express'
         | 
| 37 | 
            -
                  DISCOVER = 'Discover'
         | 
| 38 | 
            -
                  DINERS_CLUB = 'Diners Club'
         | 
| 39 | 
            -
                  JCB = 'JCB'
         | 
| 32 | 
            +
                  VISA = 'Visa'.freeze
         | 
| 33 | 
            +
                  MASTER_CARD = 'MasterCard'.freeze
         | 
| 34 | 
            +
                  AMEX = 'American Express'.freeze
         | 
| 35 | 
            +
                  DISCOVER = 'Discover'.freeze
         | 
| 36 | 
            +
                  DINERS_CLUB = 'Diners Club'.freeze
         | 
| 37 | 
            +
                  JCB = 'JCB'.freeze
         | 
| 40 38 | 
             
                end
         | 
| 41 | 
            -
             | 
| 39 | 
            +
             | 
| 42 40 | 
             
                # Defines constants for CCV code validation responses.
         | 
| 43 41 | 
             
                module CCVResponseCode
         | 
| 44 | 
            -
                  MATCH = 'M'
         | 
| 45 | 
            -
                  NO_MATCH = 'N'
         | 
| 46 | 
            -
                  NOT_PROCESSED = 'P'
         | 
| 47 | 
            -
                  SHOULD_HAVE_BEEN_PRESENT = 'S'
         | 
| 48 | 
            -
                  UNABLE_TO_PROCESS = 'U'
         | 
| 42 | 
            +
                  MATCH = 'M'.freeze
         | 
| 43 | 
            +
                  NO_MATCH = 'N'.freeze
         | 
| 44 | 
            +
                  NOT_PROCESSED = 'P'.freeze
         | 
| 45 | 
            +
                  SHOULD_HAVE_BEEN_PRESENT = 'S'.freeze
         | 
| 46 | 
            +
                  UNABLE_TO_PROCESS = 'U'.freeze
         | 
| 49 47 | 
             
                end
         | 
| 50 | 
            -
             | 
| 48 | 
            +
             | 
| 51 49 | 
             
                # Defines constants for CAVV code validation responses.
         | 
| 52 50 | 
             
                module CAVVResponseCode
         | 
| 53 | 
            -
                  ERRONEOUS_DATA = '0'
         | 
| 54 | 
            -
                  FAILED_VALIDATION = '1'
         | 
| 55 | 
            -
                  PASSED_VALIDATION = '2'
         | 
| 56 | 
            -
                  ISSUER_ATTEMPT_INCOMPLETE = '3'
         | 
| 57 | 
            -
                  ISSUER_SYSTEM_ERROR = '4'
         | 
| 58 | 
            -
                  FAILED_ISSUER_AVAILABLE = '7'
         | 
| 59 | 
            -
                  PASSED_ISSUER_AVAILABLE = '8'
         | 
| 60 | 
            -
                  FAILED_ISSUER_UNAVAILABLE = '9'
         | 
| 61 | 
            -
                  PASSED_ISSUER_UNAVAILABLE = 'A'
         | 
| 62 | 
            -
                  PASSED_NO_LIABILITY_SHIFT = 'B'
         | 
| 51 | 
            +
                  ERRONEOUS_DATA = '0'.freeze
         | 
| 52 | 
            +
                  FAILED_VALIDATION = '1'.freeze
         | 
| 53 | 
            +
                  PASSED_VALIDATION = '2'.freeze
         | 
| 54 | 
            +
                  ISSUER_ATTEMPT_INCOMPLETE = '3'.freeze
         | 
| 55 | 
            +
                  ISSUER_SYSTEM_ERROR = '4'.freeze
         | 
| 56 | 
            +
                  FAILED_ISSUER_AVAILABLE = '7'.freeze
         | 
| 57 | 
            +
                  PASSED_ISSUER_AVAILABLE = '8'.freeze
         | 
| 58 | 
            +
                  FAILED_ISSUER_UNAVAILABLE = '9'.freeze
         | 
| 59 | 
            +
                  PASSED_ISSUER_UNAVAILABLE = 'A'.freeze
         | 
| 60 | 
            +
                  PASSED_NO_LIABILITY_SHIFT = 'B'.freeze
         | 
| 63 61 | 
             
                end
         | 
| 64 | 
            -
             | 
| 62 | 
            +
             | 
| 65 63 | 
             
                # Check to see if the transaction was approved.
         | 
| 66 64 | 
             
                def approved?
         | 
| 67 65 | 
             
                  @fields[:response_code] == ResponseCode::APPROVED
         | 
| 68 66 | 
             
                end
         | 
| 69 | 
            -
             | 
| 67 | 
            +
             | 
| 70 68 | 
             
                # Check to see if the transaction was declined.
         | 
| 71 69 | 
             
                def declined?
         | 
| 72 70 | 
             
                  @fields[:response_code] == ResponseCode::DECLINED
         | 
| 73 71 | 
             
                end
         | 
| 74 | 
            -
             | 
| 72 | 
            +
             | 
| 75 73 | 
             
                # Check to see if the transaction was returned with an error.
         | 
| 76 74 | 
             
                def error?
         | 
| 77 75 | 
             
                  @fields[:response_code] == ResponseCode::ERROR
         | 
| 78 76 | 
             
                end
         | 
| 79 | 
            -
             | 
| 77 | 
            +
             | 
| 80 78 | 
             
                # Check to see if the transaction was held for review by Authorize.Net.
         | 
| 81 79 | 
             
                def held?
         | 
| 82 80 | 
             
                  @fields[:response_code] == ResponseCode::HELD
         | 
| 83 81 | 
             
                end
         | 
| 84 | 
            -
             | 
| 82 | 
            +
             | 
| 85 83 | 
             
                # Returns the response code received from the gateway. Note: its better to use
         | 
| 86 84 | 
             
                # success?, approved?, etc. to check the response code.
         | 
| 87 85 | 
             
                def response_code
         | 
| 88 86 | 
             
                  @fields[:response_code]
         | 
| 89 87 | 
             
                end
         | 
| 90 | 
            -
             | 
| 88 | 
            +
             | 
| 91 89 | 
             
                # Returns the response reason code received from the gateway. This code can be used
         | 
| 92 90 | 
             
                # to identify why something failed by referencing the AIM documentation.
         | 
| 93 91 | 
             
                def response_reason_code
         | 
| 94 92 | 
             
                  @fields[:response_reason_code]
         | 
| 95 93 | 
             
                end
         | 
| 96 | 
            -
             | 
| 94 | 
            +
             | 
| 97 95 | 
             
                # Returns the response reason text received from the gateway. This is a brief, human readable
         | 
| 98 96 | 
             
                # explanation of why you got the response code that you got. Note that these strings tend to be
         | 
| 99 97 | 
             
                # a bit vague. More detail can be gleaned from the response_reason_code.
         | 
| 100 98 | 
             
                def response_reason_text
         | 
| 101 99 | 
             
                  @fields[:response_reason_text]
         | 
| 102 100 | 
             
                end
         | 
| 103 | 
            -
             | 
| 101 | 
            +
             | 
| 104 102 | 
             
                # Returns all the fields returned in the response, keyed by their API name. Custom fields are NOT
         | 
| 105 103 | 
             
                # included (see custom_fields).
         | 
| 106 | 
            -
                 | 
| 107 | 
            -
             | 
| 108 | 
            -
                end
         | 
| 109 | 
            -
                
         | 
| 104 | 
            +
                attr_reader :fields
         | 
| 105 | 
            +
             | 
| 110 106 | 
             
                # Returns all the custom fields returned in the response, keyed by their field name.
         | 
| 111 | 
            -
                 | 
| 112 | 
            -
                  @custom_fields
         | 
| 113 | 
            -
                end
         | 
| 114 | 
            -
                
         | 
| 107 | 
            +
                attr_reader :custom_fields
         | 
| 115 108 | 
             
              end
         | 
| 116 | 
            -
             | 
| 117 | 
            -
            end
         | 
| 109 | 
            +
            end
         | 
| @@ -1,27 +1,25 @@ | |
| 1 1 | 
             
            module AuthorizeNet
         | 
| 2 | 
            -
              
         | 
| 3 2 | 
             
              # The core, key/value transaction class. You shouldn't instantiate this one.
         | 
| 4 3 | 
             
              # Instead you should use AuthorizeNet::AIM::Transaction or AuthorizeNet::SIM::Transaction.
         | 
| 5 4 | 
             
              class KeyValueTransaction < AuthorizeNet::Transaction
         | 
| 6 | 
            -
                
         | 
| 7 5 | 
             
                # Constants for both the various Authorize.Net payment gateways are defined here.
         | 
| 8 6 | 
             
                module Gateway
         | 
| 9 | 
            -
                  LIVE = 'https://secure2.authorize.net/gateway/transact.dll'
         | 
| 10 | 
            -
                  TEST = 'https://test.authorize.net/gateway/transact.dll'
         | 
| 11 | 
            -
                  CARD_PRESENT_LIVE = 'https://cardpresent.authorize.net/gateway/transact.dll'
         | 
| 12 | 
            -
                  CARD_PRESENT_TEST = 'https://test.authorize.net/gateway/transact.dll'
         | 
| 7 | 
            +
                  LIVE = 'https://secure2.authorize.net/gateway/transact.dll'.freeze
         | 
| 8 | 
            +
                  TEST = 'https://test.authorize.net/gateway/transact.dll'.freeze
         | 
| 9 | 
            +
                  CARD_PRESENT_LIVE = 'https://cardpresent.authorize.net/gateway/transact.dll'.freeze
         | 
| 10 | 
            +
                  CARD_PRESENT_TEST = 'https://test.authorize.net/gateway/transact.dll'.freeze
         | 
| 13 11 | 
             
                end
         | 
| 14 | 
            -
             | 
| 12 | 
            +
             | 
| 15 13 | 
             
                # Constants for both the various Authorize.Net payment transaction types are defined here.
         | 
| 16 14 | 
             
                module Type
         | 
| 17 | 
            -
                  AUTHORIZE_AND_CAPTURE = "AUTH_CAPTURE"
         | 
| 18 | 
            -
                  AUTHORIZE_ONLY = "AUTH_ONLY"
         | 
| 19 | 
            -
                  CAPTURE_ONLY = "CAPTURE_ONLY"
         | 
| 20 | 
            -
                  CREDIT = "CREDIT"
         | 
| 21 | 
            -
                  PRIOR_AUTHORIZATION_AND_CAPTURE = "PRIOR_AUTH_CAPTURE"
         | 
| 22 | 
            -
                  VOID = "VOID"
         | 
| 15 | 
            +
                  AUTHORIZE_AND_CAPTURE = "AUTH_CAPTURE".freeze
         | 
| 16 | 
            +
                  AUTHORIZE_ONLY = "AUTH_ONLY".freeze
         | 
| 17 | 
            +
                  CAPTURE_ONLY = "CAPTURE_ONLY".freeze
         | 
| 18 | 
            +
                  CREDIT = "CREDIT".freeze
         | 
| 19 | 
            +
                  PRIOR_AUTHORIZATION_AND_CAPTURE = "PRIOR_AUTH_CAPTURE".freeze
         | 
| 20 | 
            +
                  VOID = "VOID".freeze
         | 
| 23 21 | 
             
                end
         | 
| 24 | 
            -
             | 
| 22 | 
            +
             | 
| 25 23 | 
             
                # Constants for the various device types used in card present transactions.
         | 
| 26 24 | 
             
                module DeviceType
         | 
| 27 25 | 
             
                  UNKNOWN = 1
         | 
| @@ -35,81 +33,75 @@ module AuthorizeNet | |
| 35 33 | 
             
                  DIAL_TERMINAL = 9
         | 
| 36 34 | 
             
                  VIRTUAL_TERMINAL = 10
         | 
| 37 35 | 
             
                end
         | 
| 38 | 
            -
             | 
| 36 | 
            +
             | 
| 39 37 | 
             
                # Constants for the various market types used in card present transactions.
         | 
| 40 38 | 
             
                module MarketType
         | 
| 41 39 | 
             
                  RETAIL = 2
         | 
| 42 40 | 
             
                end
         | 
| 43 | 
            -
             | 
| 41 | 
            +
             | 
| 44 42 | 
             
                # The default options for purchase.
         | 
| 45 43 | 
             
                @@purchase_option_defaults = {
         | 
| 46 | 
            -
                  : | 
| 47 | 
            -
                  : | 
| 44 | 
            +
                  cardholder_auth_value: nil,
         | 
| 45 | 
            +
                  cardholder_auth_indicator: nil
         | 
| 48 46 | 
             
                }
         | 
| 49 | 
            -
             | 
| 47 | 
            +
             | 
| 50 48 | 
             
                # The default options for authorize.
         | 
| 51 49 | 
             
                @@authorize_option_defaults = {
         | 
| 52 | 
            -
                  : | 
| 53 | 
            -
                  : | 
| 50 | 
            +
                  cardholder_auth_value: nil,
         | 
| 51 | 
            +
                  cardholder_auth_indicator: nil
         | 
| 54 52 | 
             
                }
         | 
| 55 | 
            -
             | 
| 53 | 
            +
             | 
| 56 54 | 
             
                # Fields to convert to/from booleans.
         | 
| 57 55 | 
             
                @@boolean_fields = []
         | 
| 58 | 
            -
             | 
| 56 | 
            +
             | 
| 59 57 | 
             
                # Fields to convert to/from BigDecimal.
         | 
| 60 58 | 
             
                @@decimal_fields = []
         | 
| 61 | 
            -
             | 
| 59 | 
            +
             | 
| 62 60 | 
             
                # DO NOT USE. Instantiate AuthorizeNet::AIM::Transaction or AuthorizeNet::SIM::Transaction instead.
         | 
| 63 | 
            -
                def initialize | 
| 61 | 
            +
                def initialize
         | 
| 64 62 | 
             
                  super
         | 
| 65 63 | 
             
                  @custom_fields ||= {}
         | 
| 66 64 | 
             
                  @test_mode ||= false
         | 
| 67 65 | 
             
                  @version = '3.1'
         | 
| 68 66 | 
             
                end
         | 
| 69 | 
            -
             | 
| 67 | 
            +
             | 
| 70 68 | 
             
                # Checks if the transaction has been configured for test mode or not. Return TRUE if the
         | 
| 71 69 | 
             
                # transaction is a test transaction, FALSE otherwise. All transactions run against the sandbox
         | 
| 72 70 | 
             
                # are considered test transactions.
         | 
| 73 71 | 
             
                def test?
         | 
| 74 72 | 
             
                  !!@test_mode
         | 
| 75 73 | 
             
                end
         | 
| 76 | 
            -
             | 
| 74 | 
            +
             | 
| 77 75 | 
             
                # Returns the current API version that we are adhering to
         | 
| 78 | 
            -
                 | 
| 79 | 
            -
             | 
| 80 | 
            -
                 | 
| 81 | 
            -
                    
         | 
| 82 | 
            -
                # Sets arbitrary custom fields, overwriting existing values if they exist. Takes a hash of key/value pairs, 
         | 
| 76 | 
            +
                attr_reader :version
         | 
| 77 | 
            +
             | 
| 78 | 
            +
                # Sets arbitrary custom fields, overwriting existing values if they exist. Takes a hash of key/value pairs,
         | 
| 83 79 | 
             
                # where the keys are the field names. You can set a field to Nil to unset it.
         | 
| 84 80 | 
             
                def set_custom_fields(fields = {})
         | 
| 85 81 | 
             
                  @custom_fields.merge!(fields)
         | 
| 86 82 | 
             
                end
         | 
| 87 | 
            -
             | 
| 83 | 
            +
             | 
| 88 84 | 
             
                # Returns the current hash of custom fields.
         | 
| 89 | 
            -
                 | 
| 90 | 
            -
             | 
| 91 | 
            -
                end
         | 
| 92 | 
            -
                
         | 
| 85 | 
            +
                attr_reader :custom_fields
         | 
| 86 | 
            +
             | 
| 93 87 | 
             
                # Convenience method for adding line items to a transaction.
         | 
| 94 88 | 
             
                def add_line_item(id = nil, name = nil, description = nil, quantity = nil, price = nil, taxable = nil)
         | 
| 95 89 | 
             
                  line_item = "#{id}<|>#{name}<|>#{description}<|>#{quantity}<|>#{price}<|>#{taxable}"
         | 
| 96 | 
            -
                  if @fields. | 
| 90 | 
            +
                  if @fields.key?(:line_item)
         | 
| 97 91 | 
             
                    @fields[:line_item] = @fields[:line_item].to_a << line_item
         | 
| 98 92 | 
             
                  else
         | 
| 99 93 | 
             
                    @fields[:line_item] = [line_item]
         | 
| 100 94 | 
             
                  end
         | 
| 101 95 | 
             
                end
         | 
| 102 | 
            -
             | 
| 96 | 
            +
             | 
| 103 97 | 
             
                # Takes an instance of AuthorizeNet::EmailReceipt and adds it to the transaction.
         | 
| 104 98 | 
             
                def set_email_receipt(email)
         | 
| 105 99 | 
             
                  @fields.merge!(email.to_hash)
         | 
| 106 100 | 
             
                end
         | 
| 107 | 
            -
             | 
| 101 | 
            +
             | 
| 108 102 | 
             
                # Returns the type of transaction.
         | 
| 109 | 
            -
                 | 
| 110 | 
            -
             | 
| 111 | 
            -
                end
         | 
| 112 | 
            -
                
         | 
| 103 | 
            +
                attr_reader :type
         | 
| 104 | 
            +
             | 
| 113 105 | 
             
                # Sets the type of transaction.
         | 
| 114 106 | 
             
                def type=(type)
         | 
| 115 107 | 
             
                  case type
         | 
| @@ -129,75 +121,75 @@ module AuthorizeNet | |
| 129 121 | 
             
                    @type = type
         | 
| 130 122 | 
             
                  end
         | 
| 131 123 | 
             
                end
         | 
| 132 | 
            -
             | 
| 124 | 
            +
             | 
| 133 125 | 
             
                # Sets up and submits a standard purchase (AUTHORIZE_AND_CAPTURE) transaction. Returns a response object. If the transaction
         | 
| 134 126 | 
             
                # has already been run, it will return nil.
         | 
| 135 | 
            -
                # | 
| 127 | 
            +
                #
         | 
| 136 128 | 
             
                # +amount+:: The amount to charge. Accepts a string in the format "%0.2f", a Float or a BigDecimal.
         | 
| 137 129 | 
             
                # +credit_card+:: The credit card or eCheck to charge. Accepts an instance of AuthorizeNet::CreditCard, AuthorizeNet::ECheck, or a string of digits (in which case the expiration should be added using set_fields).
         | 
| 138 130 | 
             
                # +options+:: A hash with any of following keys: cardholder_auth_indicator, cardholder_auth_value. These are for CAVV and can be ignored in most cases.
         | 
| 139 | 
            -
                # | 
| 140 | 
            -
                # | 
| 131 | 
            +
                #
         | 
| 132 | 
            +
                #
         | 
| 141 133 | 
             
                # Typical usage:
         | 
| 142 | 
            -
                # | 
| 134 | 
            +
                #
         | 
| 143 135 | 
             
                #   credit_card = AuthorizeNet::CreditCard.new('4111111111111111', '1120')
         | 
| 144 136 | 
             
                #   response = transaction.purchase(10.0, credit_card)
         | 
| 145 | 
            -
                # | 
| 137 | 
            +
                #
         | 
| 146 138 | 
             
                def purchase(amount, credit_card, options = {})
         | 
| 147 139 | 
             
                  handle_payment_argument(credit_card)
         | 
| 148 140 | 
             
                  options = @@purchase_option_defaults.merge(options)
         | 
| 149 141 | 
             
                  handle_cavv_options(options)
         | 
| 150 | 
            -
                  set_fields(: | 
| 142 | 
            +
                  set_fields(amount: amount)
         | 
| 151 143 | 
             
                  self.type = Type::AUTHORIZE_AND_CAPTURE
         | 
| 152 144 | 
             
                  run
         | 
| 153 145 | 
             
                end
         | 
| 154 | 
            -
             | 
| 146 | 
            +
             | 
| 155 147 | 
             
                # Sets up and submits a refund (CREDIT) transaction. Returns a response object. If the transaction
         | 
| 156 148 | 
             
                # has already been run, it will return nil.
         | 
| 157 | 
            -
                # | 
| 149 | 
            +
                #
         | 
| 158 150 | 
             
                # +amount+:: The amount to refund. Accepts a string in the format "%0.2f", a Float or a BigDecimal.
         | 
| 159 151 | 
             
                # +transaction+:: The transaction ID to apply the refund to. Accepts a string of the transaction ID, an instance of AuthorizeNet::Transaction or AuthorizeNet::Response.
         | 
| 160 152 | 
             
                # +credit_card+:: The credit card or eCheck to charge. Accepts an instance of AuthorizeNet::CreditCard, AuthorizeNet::ECheck, or a string of digits. In many cases you only need the last 4 digits of the credit card here.
         | 
| 161 | 
            -
                # | 
| 162 | 
            -
                # | 
| 153 | 
            +
                #
         | 
| 154 | 
            +
                #
         | 
| 163 155 | 
             
                # Typical usage:
         | 
| 164 | 
            -
                # | 
| 156 | 
            +
                #
         | 
| 165 157 | 
             
                #   response = transaction.refund(10.0, '123456789', '1212')
         | 
| 166 158 | 
             
                #
         | 
| 167 159 | 
             
                def refund(amount, transaction, credit_card)
         | 
| 168 160 | 
             
                  handle_payment_argument(credit_card)
         | 
| 169 161 | 
             
                  handle_transaction_argument(transaction)
         | 
| 170 | 
            -
                  set_fields(: | 
| 162 | 
            +
                  set_fields(amount: amount)
         | 
| 171 163 | 
             
                  self.type = Type::CREDIT
         | 
| 172 164 | 
             
                  run
         | 
| 173 165 | 
             
                end
         | 
| 174 | 
            -
             | 
| 166 | 
            +
             | 
| 175 167 | 
             
                # Sets up and submits a refund (CREDIT) transaction for a transaction that was not originally
         | 
| 176 168 | 
             
                # submitted via the payment gateway. Note that this is a special feature which requires your
         | 
| 177 169 | 
             
                # account to support ECC (expanded credits capability) transactions.
         | 
| 178 | 
            -
                # | 
| 170 | 
            +
                #
         | 
| 179 171 | 
             
                # +amount+:: The amount to refund. Accepts a string in the format "%0.2f", a Float or a BigDecimal.
         | 
| 180 172 | 
             
                # +credit_card+:: The credit card or eCheck to charge. Accepts an instance of AuthorizeNet::CreditCard, AuthorizeNet::ECheck, or a string of digits.
         | 
| 181 | 
            -
                # | 
| 173 | 
            +
                #
         | 
| 182 174 | 
             
                # Typical usage:
         | 
| 183 | 
            -
                # | 
| 175 | 
            +
                #
         | 
| 184 176 | 
             
                #   response = transaction.unlinked_credit(10.0, '4111111111111111')
         | 
| 185 | 
            -
                # | 
| 177 | 
            +
                #
         | 
| 186 178 | 
             
                def unlinked_credit(amount, credit_card)
         | 
| 187 179 | 
             
                  handle_payment_argument(credit_card)
         | 
| 188 | 
            -
                  set_fields(: | 
| 180 | 
            +
                  set_fields(amount: amount)
         | 
| 189 181 | 
             
                  self.type = Type::CREDIT
         | 
| 190 182 | 
             
                  run
         | 
| 191 183 | 
             
                end
         | 
| 192 | 
            -
             | 
| 184 | 
            +
             | 
| 193 185 | 
             
                # Sets up and submits a void (VOID) transaction. Returns a response object. If the transaction
         | 
| 194 186 | 
             
                # has already been run, it will return nil. Note that you can only void unsettled transactions.
         | 
| 195 | 
            -
                # | 
| 187 | 
            +
                #
         | 
| 196 188 | 
             
                # +transaction+:: The transaction ID of the transaction to void. Accepts a string of the transaction ID, an instance of AuthorizeNet::Transaction or AuthorizeNet::Response.
         | 
| 197 | 
            -
                # | 
| 198 | 
            -
                # | 
| 189 | 
            +
                #
         | 
| 190 | 
            +
                #
         | 
| 199 191 | 
             
                # Typical usage:
         | 
| 200 | 
            -
                # | 
| 192 | 
            +
                #
         | 
| 201 193 | 
             
                #   response = transaction.void('123456789')
         | 
| 202 194 | 
             
                #
         | 
| 203 195 | 
             
                def void(transaction)
         | 
| @@ -205,18 +197,18 @@ module AuthorizeNet | |
| 205 197 | 
             
                  self.type = Type::VOID
         | 
| 206 198 | 
             
                  run
         | 
| 207 199 | 
             
                end
         | 
| 208 | 
            -
             | 
| 200 | 
            +
             | 
| 209 201 | 
             
                # Sets up and submits an authorize (AUTH_ONLY) transaction. Returns a response object. If the transaction
         | 
| 210 202 | 
             
                # has already been run, it will return nil. Use this to put a hold on funds, but don't actually charge
         | 
| 211 203 | 
             
                # the card yet.
         | 
| 212 | 
            -
                # | 
| 204 | 
            +
                #
         | 
| 213 205 | 
             
                # +amount+:: The amount to authorize. Accepts a string in the format "%0.2f", a Float or a BigDecimal.
         | 
| 214 206 | 
             
                # +credit_card+:: The credit card or eCheck to charge. Accepts an instance of AuthorizeNet::CreditCard, AuthorizeNet::ECheck, or a string of digits (in which case the expiration should be added using set_fields).
         | 
| 215 207 | 
             
                # +options+:: A hash with any of following keys: cardholder_auth_indicator, cardholder_auth_value. These are for CAVV and can be ignored in most cases.
         | 
| 216 | 
            -
                # | 
| 217 | 
            -
                # | 
| 208 | 
            +
                #
         | 
| 209 | 
            +
                #
         | 
| 218 210 | 
             
                # Typical usage:
         | 
| 219 | 
            -
                # | 
| 211 | 
            +
                #
         | 
| 220 212 | 
             
                #   credit_card = AuthorizeNet::CreditCard.new('4111111111111111', '1120')
         | 
| 221 213 | 
             
                #   response = transaction.authorize(10.0, credit_card)
         | 
| 222 214 | 
             
                #
         | 
| @@ -224,68 +216,66 @@ module AuthorizeNet | |
| 224 216 | 
             
                  handle_payment_argument(credit_card)
         | 
| 225 217 | 
             
                  options = @@authorize_option_defaults.merge(options)
         | 
| 226 218 | 
             
                  handle_cavv_options(options)
         | 
| 227 | 
            -
                  set_fields(: | 
| 219 | 
            +
                  set_fields(amount: amount)
         | 
| 228 220 | 
             
                  self.type = Type::AUTHORIZE_ONLY
         | 
| 229 221 | 
             
                  run
         | 
| 230 222 | 
             
                end
         | 
| 231 | 
            -
             | 
| 223 | 
            +
             | 
| 232 224 | 
             
                # Sets up and submits a capture (CAPTURE_ONLY) transaction. Returns a response object. If the transaction
         | 
| 233 225 | 
             
                # has already been run, it will return nil. Note that you can not capture a transaction that was made
         | 
| 234 226 | 
             
                # though the AIM API using this method. Use prior_auth_capture instead.
         | 
| 235 | 
            -
                # | 
| 227 | 
            +
                #
         | 
| 236 228 | 
             
                # +amount+:: The amount to capture. Accepts a string in the format "%0.2f", a Float or a BigDecimal.
         | 
| 237 229 | 
             
                # +authorization_code+:: The authorization code of the transaction to capture. Accepts a string.
         | 
| 238 | 
            -
                # | 
| 239 | 
            -
                # | 
| 230 | 
            +
                #
         | 
| 231 | 
            +
                #
         | 
| 240 232 | 
             
                # Typical usage:
         | 
| 241 | 
            -
                # | 
| 233 | 
            +
                #
         | 
| 242 234 | 
             
                #   response = transaction.capture(10.0, '123FAKE')
         | 
| 243 235 | 
             
                #
         | 
| 244 236 | 
             
                def capture(amount, authorization_code)
         | 
| 245 | 
            -
                  set_fields(: | 
| 237 | 
            +
                  set_fields(amount: amount, auth_code: authorization_code)
         | 
| 246 238 | 
             
                  self.type = Type::CAPTURE_ONLY
         | 
| 247 239 | 
             
                  run
         | 
| 248 240 | 
             
                end
         | 
| 249 | 
            -
             | 
| 241 | 
            +
             | 
| 250 242 | 
             
                # Sets up and submits a capture (PRIOR_AUTH_CAPTURE) transaction. Returns a response object. Use this method
         | 
| 251 243 | 
             
                # to actually charge a card that you previously put a hold on (using authorize).
         | 
| 252 | 
            -
                # | 
| 244 | 
            +
                #
         | 
| 253 245 | 
             
                # +transaction+:: The transaction ID to capture. Accepts a string of the transaction ID, an instance of AuthorizeNet::Transaction or AuthorizeNet::Response.
         | 
| 254 246 | 
             
                # +amount+:: The amount to capture (only if less than the amount originally authorized, otherwise leave as Nil). Accepts a string in the format "%0.2f", a Float, a BigDecimal or Nil.
         | 
| 255 | 
            -
                # | 
| 256 | 
            -
                # | 
| 247 | 
            +
                #
         | 
| 248 | 
            +
                #
         | 
| 257 249 | 
             
                # Typical usage:
         | 
| 258 | 
            -
                # | 
| 250 | 
            +
                #
         | 
| 259 251 | 
             
                #   response = transaction.prior_auth_capture('123456789')
         | 
| 260 252 | 
             
                #
         | 
| 261 253 | 
             
                def prior_auth_capture(transaction, amount = nil)
         | 
| 262 254 | 
             
                  handle_transaction_argument(transaction)
         | 
| 263 | 
            -
                  set_fields(: | 
| 255 | 
            +
                  set_fields(amount: amount)
         | 
| 264 256 | 
             
                  self.type = Type::PRIOR_AUTHORIZATION_AND_CAPTURE
         | 
| 265 257 | 
             
                  run
         | 
| 266 258 | 
             
                end
         | 
| 267 | 
            -
             | 
| 259 | 
            +
             | 
| 268 260 | 
             
                #:enddoc:
         | 
| 269 261 | 
             
                protected
         | 
| 270 | 
            -
             | 
| 262 | 
            +
             | 
| 271 263 | 
             
                # Internal method to handle multiple types of transaction arguments.
         | 
| 272 264 | 
             
                def handle_transaction_argument(transaction)
         | 
| 273 265 | 
             
                  case transaction
         | 
| 274 266 | 
             
                  when Transaction
         | 
| 275 | 
            -
                    set_fields(: | 
| 267 | 
            +
                    set_fields(trans_id: transaction.response.transaction_id)
         | 
| 276 268 | 
             
                  when Response
         | 
| 277 | 
            -
                    set_fields(: | 
| 269 | 
            +
                    set_fields(trans_id: transaction.transaction_id)
         | 
| 278 270 | 
             
                  else
         | 
| 279 | 
            -
                    set_fields(: | 
| 271 | 
            +
                    set_fields(trans_id: transaction)
         | 
| 280 272 | 
             
                  end
         | 
| 281 273 | 
             
                end
         | 
| 282 | 
            -
             | 
| 274 | 
            +
             | 
| 283 275 | 
             
                # Internal method to handle CAVV options.
         | 
| 284 276 | 
             
                def handle_cavv_options(options)
         | 
| 285 | 
            -
                  set_fields(: | 
| 286 | 
            -
                  set_fields(: | 
| 277 | 
            +
                  set_fields(authentication_indicator: options[:cardholder_auth_indicator]) unless options[:cardholder_auth_indicator].nil?
         | 
| 278 | 
            +
                  set_fields(cardholder_authentication_value: options[:cardholder_auth_value]) unless options[:cardholder_auth_value].nil?
         | 
| 287 279 | 
             
                end
         | 
| 288 | 
            -
                
         | 
| 289 280 | 
             
              end
         | 
| 290 | 
            -
             | 
| 291 | 
            -
            end
         | 
| 281 | 
            +
            end
         |