# File lib/active_merchant/billing/gateways/usa_epay_transaction.rb, line 48 48: def capture(money, authorization, options = {}) 49: post = { 50: :refNum => authorization 51: } 52: 53: add_amount(post, money) 54: commit(:capture, post) 55: end
# File lib/active_merchant/billing/gateways/usa_epay_transaction.rb, line 36 36: def purchase(money, credit_card, options = {}) 37: post = {} 38: 39: add_amount(post, money) 40: add_invoice(post, options) 41: add_credit_card(post, credit_card) 42: add_address(post, credit_card, options) 43: add_customer_data(post, options) 44: 45: commit(:purchase, post) 46: end
# File lib/active_merchant/billing/gateways/usa_epay_transaction.rb, line 89 89: def add_address(post, credit_card, options) 90: billing_address = options[:billing_address] || options[:address] 91: 92: add_address_for_type(:billing, post, credit_card, billing_address) if billing_address 93: add_address_for_type(:shipping, post, credit_card, options[:shipping_address]) if options[:shipping_address] 94: end
# File lib/active_merchant/billing/gateways/usa_epay_transaction.rb, line 96 96: def add_address_for_type(type, post, credit_card, address) 97: prefix = address_key_prefix(type) 98: 99: post[address_key(prefix, 'fname')] = credit_card.first_name 100: post[address_key(prefix, 'lname')] = credit_card.last_name 101: post[address_key(prefix, 'company')] = address[:company] unless address[:company].blank? 102: post[address_key(prefix, 'street')] = address[:address1] unless address[:address1].blank? 103: post[address_key(prefix, 'street2')] = address[:address2] unless address[:address2].blank? 104: post[address_key(prefix, 'city')] = address[:city] unless address[:city].blank? 105: post[address_key(prefix, 'state')] = address[:state] unless address[:state].blank? 106: post[address_key(prefix, 'zip')] = address[:zip] unless address[:zip].blank? 107: post[address_key(prefix, 'country')] = address[:country] unless address[:country].blank? 108: post[address_key(prefix, 'phone')] = address[:phone] unless address[:phone].blank? 109: end
# File lib/active_merchant/billing/gateways/usa_epay_transaction.rb, line 59 59: def add_amount(post, money) 60: post[:amount] = amount(money) 61: end
# File lib/active_merchant/billing/gateways/usa_epay_transaction.rb, line 126 126: def add_credit_card(post, credit_card) 127: post[:card] = credit_card.number 128: post[:cvv2] = credit_card.verification_value if credit_card.verification_value? 129: post[:expir] = expdate(credit_card) 130: post[:name] = credit_card.name 131: end
# File lib/active_merchant/billing/gateways/usa_epay_transaction.rb, line 70 70: def add_customer_data(post, options) 71: address = options[:billing_address] || options[:address] || {} 72: post[:street] = address[:address1] 73: post[:zip] = address[:zip] 74: 75: if options.has_key? :email 76: post[:custemail] = options[:email] 77: post[:custreceipt] = 'No' 78: end 79: 80: if options.has_key? :customer 81: post[:custid] = options[:customer] 82: end 83: 84: if options.has_key? :ip 85: post[:ip] = options[:ip] 86: end 87: end
# File lib/active_merchant/billing/gateways/usa_epay_transaction.rb, line 122 122: def add_invoice(post, options) 123: post[:invoice] = options[:order_id] 124: end
# File lib/active_merchant/billing/gateways/usa_epay_transaction.rb, line 118 118: def address_key(prefix, key) 119: "#{prefix}#{key}".to_sym 120: end
# File lib/active_merchant/billing/gateways/usa_epay_transaction.rb, line 111 111: def address_key_prefix(type) 112: case type 113: when :shipping then 'ship' 114: when :billing then 'bill' 115: end 116: end
# File lib/active_merchant/billing/gateways/usa_epay_transaction.rb, line 159 159: def commit(action, parameters) 160: response = parse( ssl_post(URL, post_data(action, parameters)) ) 161: 162: Response.new(response[:status] == 'Approved', message_from(response), response, 163: :test => @options[:test] || test?, 164: :authorization => response[:ref_num], 165: :cvv_result => response[:cvv2_result_code], 166: :avs_result => { 167: :street_match => response[:avs_result_code].to_s[0,1], 168: :postal_match => response[:avs_result_code].to_s[1,1], 169: :code => response[:avs_result_code].to_s[2,1] 170: } 171: ) 172: end
# File lib/active_merchant/billing/gateways/usa_epay_transaction.rb, line 63 63: def expdate(credit_card) 64: year = format(credit_card.year, :two_digits) 65: month = format(credit_card.month, :two_digits) 66: 67: "#{month}#{year}" 68: end
# File lib/active_merchant/billing/gateways/usa_epay_transaction.rb, line 174 174: def message_from(response) 175: if response[:status] == "Approved" 176: return 'Success' 177: else 178: return 'Unspecified error' if response[:error].blank? 179: return response[:error] 180: end 181: end
# File lib/active_merchant/billing/gateways/usa_epay_transaction.rb, line 133 133: def parse(body) 134: fields = {} 135: for line in body.split('&') 136: key, value = *line.scan( %{^(\w+)\=(.*)$} ).flatten 137: fields[key] = CGI.unescape(value.to_s) 138: end 139: 140: { 141: :status => fields['UMstatus'], 142: :auth_code => fields['UMauthCode'], 143: :ref_num => fields['UMrefNum'], 144: :batch => fields['UMbatch'], 145: :avs_result => fields['UMavsResult'], 146: :avs_result_code => fields['UMavsResultCode'], 147: :cvv2_result => fields['UMcvv2Result'], 148: :cvv2_result_code => fields['UMcvv2ResultCode'], 149: :vpas_result_code => fields['UMvpasResultCode'], 150: :result => fields['UMresult'], 151: :error => fields['UMerror'], 152: :error_code => fields['UMerrorcode'], 153: :acs_url => fields['UMacsurl'], 154: :payload => fields['UMpayload'] 155: }.delete_if{|k, v| v.nil?} 156: end
# File lib/active_merchant/billing/gateways/usa_epay_transaction.rb, line 183 183: def post_data(action, parameters = {}) 184: parameters[:command] = TRANSACTIONS[action] 185: parameters[:key] = @options[:login] 186: parameters[:software] = 'Active Merchant' 187: parameters[:testmode] = @options[:test] ? 1 : 0 188: 189: parameters.collect { |key, value| "UM#{key}=#{CGI.escape(value.to_s)}" }.join("&") 190: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.