# File lib/active_merchant/billing/gateways/jetpay.rb, line 79 79: def capture(money, reference, options = {}) 80: commit(money, build_capture_request('CAPT', reference.split(";").first)) 81: end
# File lib/active_merchant/billing/gateways/jetpay.rb, line 88 88: def credit(money, transaction_id_or_card, options = {}) 89: if transaction_id_or_card.is_a?(String) 90: deprecated CREDIT_DEPRECATION_MESSAGE 91: refund(money, transaction_id_or_card, options) 92: else 93: commit(money, build_credit_request('CREDIT', money, nil, transaction_id_or_card)) 94: end 95: end
# File lib/active_merchant/billing/gateways/jetpay.rb, line 71 71: def purchase(money, credit_card, options = {}) 72: commit(money, build_sale_request(money, credit_card, options)) 73: end
# File lib/active_merchant/billing/gateways/jetpay.rb, line 97 97: def refund(money, reference, options = {}) 98: transaction_id = reference.split(";").first 99: credit_card = options[:credit_card] 100: commit(money, build_credit_request('CREDIT', money, transaction_id, credit_card)) 101: end
# File lib/active_merchant/billing/gateways/jetpay.rb, line 83 83: def void(reference, options = {}) 84: transaction_id, approval, amount = reference.split(";") 85: commit(amount.to_i, build_void_request(amount.to_i, transaction_id, approval)) 86: end
# File lib/active_merchant/billing/gateways/jetpay.rb, line 234 234: def add_addresses(xml, options) 235: if billing_address = options[:billing_address] || options[:address] 236: xml.tag! 'BillingAddress', [billing_address[:address1], billing_address[:address2]].compact.join(" ") 237: xml.tag! 'BillingCity', billing_address[:city] 238: xml.tag! 'BillingStateProv', billing_address[:state] 239: xml.tag! 'BillingPostalCode', billing_address[:zip] 240: xml.tag! 'BillingCountry', lookup_country_code(billing_address[:country]) 241: xml.tag! 'BillingPhone', billing_address[:phone] 242: end 243: 244: if shipping_address = options[:shipping_address] 245: xml.tag! 'ShippingInfo' do 246: xml.tag! 'ShippingName', shipping_address[:name] 247: 248: xml.tag! 'ShippingAddr' do 249: xml.tag! 'Address', [shipping_address[:address1], shipping_address[:address2]].compact.join(" ") 250: xml.tag! 'City', shipping_address[:city] 251: xml.tag! 'StateProv', shipping_address[:state] 252: xml.tag! 'PostalCode', shipping_address[:zip] 253: xml.tag! 'Country', lookup_country_code(shipping_address[:country]) 254: end 255: end 256: end 257: end
# File lib/active_merchant/billing/gateways/jetpay.rb, line 220 220: def add_credit_card(xml, credit_card) 221: xml.tag! 'CardNum', credit_card.number 222: xml.tag! 'CardExpMonth', format_exp(credit_card.month) 223: xml.tag! 'CardExpYear', format_exp(credit_card.year) 224: 225: if credit_card.first_name || credit_card.last_name 226: xml.tag! 'CardName', [credit_card.first_name,credit_card.last_name].compact.join(' ') 227: end 228: 229: unless credit_card.verification_value.nil? || (credit_card.verification_value.length == 0) 230: xml.tag! 'CVV2', credit_card.verification_value 231: end 232: end
# File lib/active_merchant/billing/gateways/jetpay.rb, line 259 259: def add_customer_data(xml, options) 260: xml.tag! 'Email', options[:email] if options[:email] 261: xml.tag! 'UserIPAddress', options[:ip] if options[:ip] 262: end
# File lib/active_merchant/billing/gateways/jetpay.rb, line 264 264: def add_invoice_data(xml, options) 265: xml.tag! 'OrderNumber', options[:order_id] if options[:order_id] 266: xml.tag! 'TaxAmount', amount(options[:tax]) if options[:tax] 267: end
# File lib/active_merchant/billing/gateways/jetpay.rb, line 134 134: def build_authonly_request(money, credit_card, options) 135: build_xml_request('AUTHONLY') do |xml| 136: add_credit_card(xml, credit_card) 137: add_addresses(xml, options) 138: add_customer_data(xml, options) 139: add_invoice_data(xml, options) 140: xml.tag! 'TotalAmount', amount(money) 141: 142: xml.target! 143: end 144: end
# File lib/active_merchant/billing/gateways/jetpay.rb, line 146 146: def build_capture_request(transaction_type, transaction_id) 147: build_xml_request(transaction_type, transaction_id) 148: end
`transaction_id` may be nil for unlinked credit transactions.
# File lib/active_merchant/billing/gateways/jetpay.rb, line 160 160: def build_credit_request(transaction_type, money, transaction_id, card) 161: build_xml_request(transaction_type, transaction_id) do |xml| 162: add_credit_card(xml, card) if card 163: xml.tag! 'TotalAmount', amount(money) 164: 165: xml.target! 166: end 167: end
# File lib/active_merchant/billing/gateways/jetpay.rb, line 122 122: def build_sale_request(money, credit_card, options) 123: build_xml_request('SALE') do |xml| 124: add_credit_card(xml, credit_card) 125: add_addresses(xml, options) 126: add_customer_data(xml, options) 127: add_invoice_data(xml, options) 128: xml.tag! 'TotalAmount', amount(money) 129: 130: xml.target! 131: end 132: end
# File lib/active_merchant/billing/gateways/jetpay.rb, line 150 150: def build_void_request(money, transaction_id, approval) 151: build_xml_request('VOID', transaction_id) do |xml| 152: xml.tag! 'Approval', approval 153: xml.tag! 'TotalAmount', amount(money) 154: 155: xml.target! 156: end 157: end
# File lib/active_merchant/billing/gateways/jetpay.rb, line 106 106: def build_xml_request(transaction_type, transaction_id = nil, &block) 107: xml = Builder::XmlMarkup.new 108: xml.tag! 'JetPay' do 109: # The basic values needed for any request 110: xml.tag! 'TerminalID', @options[:login] 111: xml.tag! 'TransactionType', transaction_type 112: xml.tag! 'TransactionID', transaction_id.nil? ? generate_unique_id.slice(0, 18) : transaction_id 113: 114: if block_given? 115: yield xml 116: else 117: xml.target! 118: end 119: end 120: end
# File lib/active_merchant/billing/gateways/jetpay.rb, line 169 169: def commit(money, request) 170: response = parse(ssl_post(test? ? TEST_URL : LIVE_URL, request)) 171: 172: success = success?(response) 173: Response.new(success, 174: success ? 'APPROVED' : message_from(response), 175: response, 176: :test => test?, 177: :authorization => authorization_from(response, money), 178: :avs_result => { :code => response[:avs] }, 179: :cvv_result => response[:cvv2] 180: ) 181: end
# File lib/active_merchant/billing/gateways/jetpay.rb, line 203 203: def format_exp(value) 204: format(value, :two_digits) 205: end
# File lib/active_merchant/billing/gateways/jetpay.rb, line 269 269: def lookup_country_code(code) 270: country = Country.find(code) rescue nil 271: country && country.code(:alpha3) 272: end
# File lib/active_merchant/billing/gateways/jetpay.rb, line 211 211: def message_from(response) 212: ACTION_CODE_MESSAGES[response[:action_code]] 213: end
# File lib/active_merchant/billing/gateways/jetpay.rb, line 183 183: def parse(body) 184: return {} if body.blank? 185: 186: xml = REXML::Document.new(body) 187: 188: response = {} 189: xml.root.elements.to_a.each do |node| 190: parse_element(response, node) 191: end 192: response 193: end
# File lib/active_merchant/billing/gateways/jetpay.rb, line 195 195: def parse_element(response, node) 196: if node.has_elements? 197: node.elements.each{|element| parse_element(response, element) } 198: else 199: response[node.name.underscore.to_sym] = node.text 200: end 201: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.