class ActiveMerchant::Billing::GlobalTransportGateway
Public Class Methods
new(options={})
click to toggle source
Public: Create a new Global Transport gateway.
options - A hash of options:
:global_user_name - Your Global user name :global_password - Your Global password :term_type - 3 character field assigned by Global Transport after - your application is certified.
Calls superclass method
ActiveMerchant::Billing::Gateway::new
# File lib/active_merchant/billing/gateways/global_transport.rb, line 23 def initialize(options={}) requires!(options, :global_user_name, :global_password, :term_type) super end
Public Instance Methods
capture(money, authorization, options={})
click to toggle source
# File lib/active_merchant/billing/gateways/global_transport.rb, line 46 def capture(money, authorization, options={}) post = {} add_invoice(post, money, options) add_auth(post, authorization) commit('Force', post, options) end
purchase(money, payment_method, options={})
click to toggle source
# File lib/active_merchant/billing/gateways/global_transport.rb, line 28 def purchase(money, payment_method, options={}) post = {} add_invoice(post, money, options) add_payment_method(post, payment_method) add_address(post, options) commit('Sale', post, options) end
refund(money, authorization, options={})
click to toggle source
# File lib/active_merchant/billing/gateways/global_transport.rb, line 54 def refund(money, authorization, options={}) post = {} add_invoice(post, money, options) add_auth(post, authorization) commit('Return', post, options) end
verify(payment_method, options={})
click to toggle source
# File lib/active_merchant/billing/gateways/global_transport.rb, line 69 def verify(payment_method, options={}) post = {} add_payment_method(post, payment_method) add_address(post, options) commit('CardVerify', post, options) end
void(authorization, options={})
click to toggle source
# File lib/active_merchant/billing/gateways/global_transport.rb, line 62 def void(authorization, options={}) post = {} add_auth(post, authorization) commit('Void', post, options) end
Private Instance Methods
add_address(post, options)
click to toggle source
# File lib/active_merchant/billing/gateways/global_transport.rb, line 79 def add_address(post, options) if address = (options[:billing_address] || options[:address]) post[:Street] = address[:address1] post[:Zip] = address[:zip] end end
add_auth(post, authorization)
click to toggle source
# File lib/active_merchant/billing/gateways/global_transport.rb, line 86 def add_auth(post, authorization) post[:PNRef] = authorization end
add_invoice(post, money, options)
click to toggle source
# File lib/active_merchant/billing/gateways/global_transport.rb, line 90 def add_invoice(post, money, options) currency = (options[:currency] || currency(money)) post[:Amount] = localized_amount(money, currency) post[:InvNum] = truncate(options[:order_id], 16) end
add_payment_method(post, payment_method)
click to toggle source
# File lib/active_merchant/billing/gateways/global_transport.rb, line 97 def add_payment_method(post, payment_method) post[:CardNum] = payment_method.number post[:ExpDate] = expdate(payment_method) post[:NameOnCard] = payment_method.name post[:CVNum] = payment_method.verification_value end
avs_from(response)
click to toggle source
# File lib/active_merchant/billing/gateways/global_transport.rb, line 153 def avs_from(response) { code: response[:getavsresult] } end
commit(action, parameters, options)
click to toggle source
# File lib/active_merchant/billing/gateways/global_transport.rb, line 114 def commit(action, parameters, options) raw = parse(ssl_post(url, post_data(action, parameters, options))) Response.new( success_from(raw), message_from(raw), raw, authorization: authorization_from(raw), test: test?, avs_result: avs_from(raw), cvv_result: cvv_from(raw) ) end
cvv_from(response)
click to toggle source
# File lib/active_merchant/billing/gateways/global_transport.rb, line 157 def cvv_from(response) response[:getcvresult] end
default_params()
click to toggle source
# File lib/active_merchant/billing/gateways/global_transport.rb, line 161 def default_params { CardNum: '', ExpDate: '', NameOnCard: '', Amount: '', PNRef: '', Zip: '', Street: '', CVNum: '', MagData: '', InvNum: '', ExtData: '' } end
message_from(response)
click to toggle source
# File lib/active_merchant/billing/gateways/global_transport.rb, line 145 def message_from(response) response[:respmsg] end
parse(body)
click to toggle source
# File lib/active_merchant/billing/gateways/global_transport.rb, line 104 def parse(body) response = {} Nokogiri::XML(body).root.xpath('*').each do |node| response[node.name.downcase.to_sym] = node.text end response end
post_data(action, params, options)
click to toggle source
# File lib/active_merchant/billing/gateways/global_transport.rb, line 127 def post_data(action, params, options) post = default_params post[:GlobalUserName] = @options[:global_user_name] post[:GlobalPassword] = @options[:global_password] post[:TransType] = action post[:ExtData] = "<TermType>#{@options[:term_type]}</TermType>" post.merge(params).map { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join("&") end
success_from(response)
click to toggle source
# File lib/active_merchant/billing/gateways/global_transport.rb, line 141 def success_from(response) (response[:result] == "0") end
url()
click to toggle source
# File lib/active_merchant/billing/gateways/global_transport.rb, line 137 def url (test? ? test_url : live_url) end