class ActiveMerchant::Billing::CreditcallGateway
Constants
- AVS_CODE
- CVV_CODE
Public Class Methods
new(options = {})
click to toggle source
Calls superclass method
ActiveMerchant::Billing::Gateway::new
# File lib/active_merchant/billing/gateways/creditcall.rb, line 44 def initialize(options = {}) requires!(options, :terminal_id, :transaction_key) super end
Public Instance Methods
capture(money, authorization, options = {})
click to toggle source
# File lib/active_merchant/billing/gateways/creditcall.rb, line 79 def capture(money, authorization, options = {}) request = build_xml_request do |xml| add_transaction_details(xml, money, authorization, 'Conf', options) add_terminal_details(xml, options) end commit(request) end
purchase(money, payment_method, options = {})
click to toggle source
# File lib/active_merchant/billing/gateways/creditcall.rb, line 49 def purchase(money, payment_method, options = {}) multi_response = MultiResponse.run do |r| r.process { authorize(money, payment_method, options) } r.process { capture(money, r.authorization, options) } end merged_params = multi_response.responses.map(&:params).reduce({}, :merge) Response.new( multi_response.primary_response.success?, multi_response.primary_response.message, merged_params, authorization: multi_response.responses.first.authorization, avs_result: AVSResult.new(code: avs_result_code_from(merged_params)), cvv_result: CVVResult.new(cvv_result_code_from(merged_params)), error_code: error_result_code_from(merged_params), test: test? ) end
refund(money, authorization, options = {})
click to toggle source
# File lib/active_merchant/billing/gateways/creditcall.rb, line 88 def refund(money, authorization, options = {}) request = build_xml_request do |xml| add_transaction_details(xml, money, authorization, 'Refund', options) add_terminal_details(xml, options) end commit(request) end
scrub(transcript)
click to toggle source
# File lib/active_merchant/billing/gateways/creditcall.rb, line 117 def scrub(transcript) transcript. gsub(%r((<TransactionKey>).+?(</TransactionKey>))i, '\1[FILTERED]\2'). gsub(%r((<PAN>).+?(</PAN>))i, '\1[FILTERED]\2'). gsub(%r((<CSC>).+?(</CSC>))i, '\1[FILTERED]\2') end
supports_scrubbing?()
click to toggle source
# File lib/active_merchant/billing/gateways/creditcall.rb, line 113 def supports_scrubbing? true end
verify(credit_card, options = {})
click to toggle source
# File lib/active_merchant/billing/gateways/creditcall.rb, line 106 def verify(credit_card, options = {}) MultiResponse.run(:use_first_response) do |r| r.process { authorize(100, credit_card, options) } r.process(:ignore_result) { void(r.authorization, options) } end end
void(authorization, options = {})
click to toggle source
# File lib/active_merchant/billing/gateways/creditcall.rb, line 97 def void(authorization, options = {}) request = build_xml_request do |xml| add_transaction_details(xml, nil, authorization, 'Void', options) add_terminal_details(xml, options) end commit(request) end
Private Instance Methods
add_additional_verification(xml, options)
click to toggle source
# File lib/active_merchant/billing/gateways/creditcall.rb, line 176 def add_additional_verification(xml, options) return unless (options[:verify_zip].to_s == 'true') || (options[:verify_address].to_s == 'true') if address = options[:billing_address] xml.AdditionalVerification do xml.Zip address[:zip] if options[:verify_zip].to_s == 'true' xml.Address address[:address1] if options[:verify_address].to_s == 'true' end end end
add_card_details(xml, payment_method, options = {})
click to toggle source
# File lib/active_merchant/billing/gateways/creditcall.rb, line 164 def add_card_details(xml, payment_method, options = {}) xml.CardDetails do xml.Manual(type: manual_type(options)) do xml.PAN payment_method.number xml.ExpiryDate exp_date(payment_method) xml.CSC payment_method.verification_value unless empty?(payment_method.verification_value) end add_additional_verification(xml, options) end end
add_terminal_details(xml, options = {})
click to toggle source
# File lib/active_merchant/billing/gateways/creditcall.rb, line 156 def add_terminal_details(xml, options = {}) xml.TerminalDetails do xml.TerminalID @options[:terminal_id] xml.TransactionKey @options[:transaction_key] xml.Software(version: 'SoftwareVersion') { xml.text('SoftwareName') } end end
add_transaction_details(xml, amount, authorization, type, options = {})
click to toggle source
# File lib/active_merchant/billing/gateways/creditcall.rb, line 147 def add_transaction_details(xml, amount, authorization, type, options = {}) xml.TransactionDetails do xml.MessageType type xml.Amount(unit: 'Minor') { xml.text(amount) } if amount xml.CardEaseReference authorization if authorization xml.VoidReason '01' if type == 'Void' end end
avs_result_code_from(params)
click to toggle source
# File lib/active_merchant/billing/gateways/creditcall.rb, line 126 def avs_result_code_from(params) AVS_CODE["#{params['Address']};#{params['Zip']}"] end
build_xml_request() { |xml| ... }
click to toggle source
# File lib/active_merchant/billing/gateways/creditcall.rb, line 138 def build_xml_request builder = Nokogiri::XML::Builder.new do |xml| xml.Request(type: 'CardEaseXML', version: '1.0.0') do yield(xml) end end builder.to_xml end
childnode_to_response(response, childnode)
click to toggle source
# File lib/active_merchant/billing/gateways/creditcall.rb, line 221 def childnode_to_response(response, childnode) childnode.elements.each do |element| if element.name == 'Error' response['ErrorCode'] = element.attr('code') response['ErrorMessage'] = element.text else response[element.name] = element.text end end end
commit(parameters)
click to toggle source
# File lib/active_merchant/billing/gateways/creditcall.rb, line 232 def commit(parameters) response = parse(ssl_post(url, parameters)) Response.new( success_from(response), message_from(response), response, authorization: authorization_from(response), avs_result: AVSResult.new(code: avs_result_code_from(response)), cvv_result: CVVResult.new(cvv_result_code_from(response)), error_code: error_result_code_from(response), test: test? ) end
cvv_result_code_from(params)
click to toggle source
# File lib/active_merchant/billing/gateways/creditcall.rb, line 130 def cvv_result_code_from(params) CVV_CODE[params['CSC']] end
error_result_code_from(params)
click to toggle source
# File lib/active_merchant/billing/gateways/creditcall.rb, line 134 def error_result_code_from(params) params['ErrorCode'] end
exp_date(payment_method)
click to toggle source
# File lib/active_merchant/billing/gateways/creditcall.rb, line 187 def exp_date(payment_method) "#{format(payment_method.year, :two_digits)}#{format(payment_method.month, :two_digits)}" end
manual_type(options)
click to toggle source
# File lib/active_merchant/billing/gateways/creditcall.rb, line 267 def manual_type(options) options[:manual_type] || 'ecommerce' end
message_from(response)
click to toggle source
# File lib/active_merchant/billing/gateways/creditcall.rb, line 255 def message_from(response) if success_from(response) 'Succeeded' else response['ErrorMessage'] end end
parse(body)
click to toggle source
# File lib/active_merchant/billing/gateways/creditcall.rb, line 191 def parse(body) response = {} xml = Nokogiri::XML(body) node = xml.xpath('//Response/TransactionDetails') node.children.each do |childnode| response[childnode.name] = childnode.text end node = xml.xpath('//Response/Result') node.children.each do |childnode| if childnode.elements.empty? response[childnode.name] = childnode.text else childnode_to_response(response, childnode) end end node = xml.xpath('//Response/CardDetails') node.children.each do |childnode| if childnode.elements.empty? response[childnode.name] = childnode.text else childnode_to_response(response, childnode) end end response end
success_from(response)
click to toggle source
# File lib/active_merchant/billing/gateways/creditcall.rb, line 251 def success_from(response) response['LocalResult'] == '0' || response['LocalResult'] == '00' end
url()
click to toggle source
# File lib/active_merchant/billing/gateways/creditcall.rb, line 247 def url test? ? test_url : live_url end