# File lib/active_merchant/billing/gateways/optimal_payment.rb, line 47 47: def capture(money, authorization, options = {}) 48: options[:confirmationNumber] = authorization 49: commit('ccSettlement', money, options) 50: end
# File lib/active_merchant/billing/gateways/optimal_payment.rb, line 31 31: def purchase(money, card_or_auth, options = {}) 32: parse_card_or_auth(card_or_auth, options) 33: commit("cc#{@stored_data}Purchase", money, options) 34: end
# File lib/active_merchant/billing/gateways/optimal_payment.rb, line 37 37: def refund(money, authorization, options = {}) 38: options[:confirmationNumber] = authorization 39: commit('ccCredit', money, options) 40: end
# File lib/active_merchant/billing/gateways/optimal_payment.rb, line 241 241: def build_billing_details(xml, opts) 242: xml.tag! 'billingDetails' do 243: addr = opts[:billing_address] 244: xml.tag! 'cardPayMethod', 'WEB' 245: if addr[:name] 246: xml.tag! 'firstName', CGI.escape(addr[:name].split(' ').first) # TODO: parse properly 247: xml.tag! 'lastName' , CGI.escape(addr[:name].split(' ').last ) 248: end 249: xml.tag! 'street' , CGI.escape(addr[:address1]) if addr[:address1] && !addr[:address1].empty? 250: xml.tag! 'street2', CGI.escape(addr[:address2]) if addr[:address2] && !addr[:address2].empty? 251: xml.tag! 'city' , CGI.escape(addr[:city] ) if addr[:city] && !addr[:city].empty? 252: xml.tag! 'state' , CGI.escape(addr[:state] ) if addr[:state] && !addr[:state].empty? 253: xml.tag! 'country', CGI.escape(addr[:country] ) if addr[:country] && !addr[:country].empty? 254: xml.tag! 'zip' , CGI.escape(addr[:zip] ) # this one's actually required 255: xml.tag! 'phone' , CGI.escape(addr[:phone] ) if addr[:phone] && !addr[:phone].empty? 256: #xml.tag! 'email' , '' 257: end 258: end
# File lib/active_merchant/billing/gateways/optimal_payment.rb, line 224 224: def build_card(xml, opts) 225: xml.tag! 'card' do 226: xml.tag! 'cardNum' , @credit_card.number 227: xml.tag! 'cardExpiry' do 228: xml.tag! 'month' , @credit_card.month 229: xml.tag! 'year' , @credit_card.year 230: end 231: if type = card_type(@credit_card.type) 232: xml.tag! 'cardType' , type 233: end 234: if @credit_card.verification_value 235: xml.tag! 'cvdIndicator' , '1' # Value Provided 236: xml.tag! 'cvd' , @credit_card.verification_value 237: end 238: end 239: end
# File lib/active_merchant/billing/gateways/optimal_payment.rb, line 216 216: def build_merchant_account(xml, opts) 217: xml.tag! 'merchantAccount' do 218: xml.tag! 'accountNum' , opts[:account] 219: xml.tag! 'storeID' , opts[:login] 220: xml.tag! 'storePwd' , opts[:password] 221: end 222: end
# File lib/active_merchant/billing/gateways/optimal_payment.rb, line 260 260: def card_type(key) 261: { 'visa' => 'VI', 262: 'master' => 'MC', 263: 'american_express'=> 'AM', 264: 'discover' => 'DI', 265: 'diners_club' => 'DC', 266: #'switch' => '', 267: 'solo' => 'SO' 268: }[key] 269: end
# File lib/active_merchant/billing/gateways/optimal_payment.rb, line 146 146: def cc_auth_request(money, opts) 147: xml_document('ccAuthRequestV1') do |xml| 148: build_merchant_account(xml, @options) 149: xml.merchantRefNum opts[:order_id] 150: xml.amount(money/100.0) 151: build_card(xml, opts) 152: build_billing_details(xml, opts) 153: end 154: end
# File lib/active_merchant/billing/gateways/optimal_payment.rb, line 156 156: def cc_auth_reversal_request(opts) 157: xml_document('ccAuthReversalRequestV1') do |xml| 158: build_merchant_account(xml, @options) 159: xml.confirmationNumber opts[:confirmationNumber] 160: xml.merchantRefNum opts[:order_id] 161: end 162: end
# File lib/active_merchant/billing/gateways/optimal_payment.rb, line 164 164: def cc_post_auth_request(money, opts) 165: xml_document('ccPostAuthRequestV1') do |xml| 166: build_merchant_account(xml, @options) 167: xml.confirmationNumber opts[:confirmationNumber] 168: xml.merchantRefNum opts[:order_id] 169: xml.amount(money/100.0) 170: end 171: end
# File lib/active_merchant/billing/gateways/optimal_payment.rb, line 173 173: def cc_stored_data_request(money, opts) 174: xml_document('ccStoredDataRequestV1') do |xml| 175: build_merchant_account(xml, @options) 176: xml.merchantRefNum opts[:order_id] 177: xml.confirmationNumber opts[:confirmationNumber] 178: xml.amount(money/100.0) 179: end 180: end
# File lib/active_merchant/billing/gateways/optimal_payment.rb, line 72 72: def commit(action, money, post) 73: post[:order_id] ||= 'order_id' 74: 75: xml = case action 76: when 'ccAuthorize', 'ccPurchase', 'ccVerification' 77: cc_auth_request(money, post) 78: when 'ccCredit', 'ccSettlement' 79: cc_post_auth_request(money, post) 80: when 'ccStoredDataAuthorize', 'ccStoredDataPurchase' 81: cc_stored_data_request(money, post) 82: when 'ccAuthorizeReversal' 83: cc_auth_reversal_request(post) 84: #when 'ccCancelSettle', 'ccCancelCredit', 'ccCancelPayment' 85: # cc_cancel_request(money, post) 86: #when 'ccPayment' 87: # cc_payment_request(money, post) 88: #when 'ccAuthenticate' 89: # cc_authenticate_request(money, post) 90: else 91: raise 'Unknown Action' 92: end 93: txnRequest = URI.encode(xml) 94: response = parse(ssl_post(test? ? TEST_URL : LIVE_URL, "txnMode=#{action}&txnRequest=#{txnRequest}")) 95: 96: Response.new(successful?(response), message_from(response), hash_from_xml(response), 97: :test => test?, 98: :authorization => authorization_from(response) 99: ) 100: end
# File lib/active_merchant/billing/gateways/optimal_payment.rb, line 119 119: def hash_from_xml(response) 120: hsh = {} 121: %(confirmationNumber authCode 122: decision code description 123: actionCode avsResponse cvdResponse 124: txnTime duplicateFound 125: ).each do |tag| 126: node = REXML::XPath.first(response, "//#{tag}") 127: hsh[tag] = node.text if node 128: end 129: REXML::XPath.each(response, '//detail') do |detail| 130: next unless detail.is_a?(REXML::Element) 131: tag = detail.elements['tag'].text 132: value = detail.elements['value'].text 133: hsh[tag] = value 134: end 135: hsh 136: end
# File lib/active_merchant/billing/gateways/optimal_payment.rb, line 106 106: def message_from(response) 107: REXML::XPath.each(response, '//detail') do |detail| 108: if detail.is_a?(REXML::Element) && detail.elements['tag'].text == 'InternalResponseDescription' 109: return detail.elements['value'].text 110: end 111: end 112: nil 113: end
# File lib/active_merchant/billing/gateways/optimal_payment.rb, line 68 68: def parse(body) 69: REXML::Document.new(body || '') 70: end
# File lib/active_merchant/billing/gateways/optimal_payment.rb, line 58 58: def parse_card_or_auth(card_or_auth, options) 59: if card_or_auth.respond_to?(:number) 60: @credit_card = card_or_auth 61: @stored_data = "" 62: else 63: options[:confirmationNumber] = card_or_auth 64: @stored_data = "StoredData" 65: end 66: end
untested
def cc_cancel_request(opts)
xml_document('ccCancelRequestV1') do |xml| build_merchant_account(xml, @options) xml.confirmationNumber opts[:confirmationNumber] end
end
def cc_payment_request(money, opts)
xml_document('ccPaymentRequestV1') do |xml| build_merchant_account(xml, @options) xml.merchantRefNum opts[:order_id] xml.amount(money/100.0) build_card(xml, opts) build_billing_details(xml, opts) end
end
def cc_authenticate_request(opts)
xml_document('ccAuthenticateRequestV1') do |xml| build_merchant_account(xml, @options) xml.confirmationNumber opts[:confirmationNumber] xml.paymentResponse 'myPaymentResponse' end
end
# File lib/active_merchant/billing/gateways/optimal_payment.rb, line 209 209: def schema 210: { 'xmlns' => 'http://www.optimalpayments.com/creditcard/xmlschema/v1', 211: 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', 212: 'xsi:schemaLocation' => 'http://www.optimalpayments.com/creditcard/xmlschema/v1' 213: } 214: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.