module Dolla::Gateway
Constants
- ACTIONS
Attributes
address[RW]
amount[RW]
bank_account_terms[RW]
card_expiration[RW]
card_number[RW]
card_type_bank_code[RW]
cardholder[RW]
code[RW]
cvv[RW]
email[RW]
last_name[RW]
name[RW]
payment_id[RW]
phone_number[RW]
server_address[RW]
user_agent[RW]
zip_code[RW]
Public Instance Methods
amex?()
click to toggle source
# File lib/dolla/gateway.rb, line 57 def amex? CardNumberPrefix.card_number_is_amex? card_number end
amex_avs_validation()
click to toggle source
# File lib/dolla/gateway.rb, line 106 def amex_avs_validation opt = ActiveSupport::OrderedHash.new opt[ get_option(:name) ] = name opt[ get_option(:surnames) ] = last_name opt[ get_option(:zip_code) ] = zip_code opt[ get_option(:address) ] = address opt[ get_option(:shipping) ] = nil opt end
amex_typed_card()
click to toggle source
# File lib/dolla/gateway.rb, line 118 def amex_typed_card opt = ActiveSupport::OrderedHash.new opt['operationEnvironment'] = 0 # more static values that we don't know what they are opt['cardHolderPresent'] = 'S' opt['cardPresent'] = false opt[ get_option(:online_purchase) ] = ActiveSupport::OrderedHash.new opt[ get_option(:online_purchase) ]['browser'] = user_agent[0..49] opt[ get_option(:online_purchase) ]['shipping'] = '05' # plz don't ask me what this means, multipagos just said to set it to this opt[ get_option(:online_purchase) ]['productId'] = '0' * 6 # just a placeholder until we get the asset system right opt[ get_option(:online_purchase) ][ get_option(:client_ip) ] = server_address opt end
build_amex_payment_body()
click to toggle source
# File lib/dolla/gateway.rb, line 95 def build_amex_payment_body body = default_body_fields body.set_option :typed_card, amex_typed_card body.set_option :avs_validation, amex_avs_validation body.set_option :slid_card, nil body.set_option :card_chip, nil body.set_option :order!, body.keys end
build_default_payment_body()
click to toggle source
# File lib/dolla/gateway.rb, line 77 def build_default_payment_body body = default_body_fields body.set_option :card_type, card_type_bank_code body.set_option :transaction_type, Dolla.configuration.transaction_type body.set_option :track, '' body.set_option :admin_email, Dolla.configuration.admin_email body.set_option :transaction, Dolla.configuration.payment body.set_option :afiliation, '' body.set_option :platform, Dolla.configuration.platform %i/card_sequence interred_sequence signature_flag promissory_code promissory_transaction/.each do |opt| body.set_option opt, '' end body.set_option(:order!, body.keys) # Unfortunately order matters... end
build_payment_body()
click to toggle source
# File lib/dolla/gateway.rb, line 73 def build_payment_body amex? ? build_amex_payment_body : build_default_payment_body end
card_number=(value)
click to toggle source
# File lib/dolla/gateway.rb, line 61 def card_number= value @card_number = value.to_s.gsub /\D/, '' end
decimal_amount()
click to toggle source
# File lib/dolla/gateway.rb, line 69 def decimal_amount decimal_format( amount ) end
default_body_fields()
click to toggle source
# File lib/dolla/gateway.rb, line 134 def default_body_fields encrypted = encrypted_customer_info if amex? cardholder = :full_name currency = :amex_currency terms = bank_account_terms > 1 ? bank_account_terms : '' end cardholder ||= :cardholder currency ||= :currency body = RequestBuilder.new body.set_option :payment_id, payment_id body.set_option :payment_code, code body.set_option :business_unit, Dolla.configuration.business_unit body.set_option :service_type, Dolla.configuration.payment_gateway_code body.set_option currency, Dolla.configuration.currency body.set_option :total, decimal_amount body.set_option cardholder, full_name body.set_option :card_number, encrypted[:cc] body.set_option :card_expiration, encrypted[:cc_exp] body.set_option :cvv, encrypted[:cc_cvv] body.set_option :digest, encrypted[:hmac] body.set_option :client_email, email body.set_option :client_phone, phone_number body.set_option :client_id, Dolla.configuration.client_id body.set_option :payment_plan, payment_plan body.set_option :terms, (amex? ? terms : bank_account_terms) end
encrypted_customer_info()
click to toggle source
# File lib/dolla/gateway.rb, line 166 def encrypted_customer_info { hmac: build_digest( payment_id, code, decimal_amount, cvv ), cc: rijndael_encrypt( card_number ), cc_exp: rijndael_encrypt( card_expiration.strftime( '%y%m' ) ), cc_cvv: rijndael_encrypt( cvv.to_s ), } end
full_name()
click to toggle source
# File lib/dolla/gateway.rb, line 65 def full_name [name, last_name].join(' ') end
pay!()
click to toggle source
# File lib/dolla/gateway.rb, line 25 def pay! request soap_action(:process_purchase), xmlns: xml_namespace do soap.element_form_default = :qualified soap.body = build_payment_body.to_hash end end
payments_gateway()
click to toggle source
# File lib/dolla/gateway.rb, line 37 def payments_gateway @client ||= ::Savon::Client.new do wsdl.endpoint = wsdl_address wsdl.namespace = xml_namespace end end
reference(valid_timeframe = 1.week)
click to toggle source
# File lib/dolla/gateway.rb, line 32 def reference valid_timeframe = 1.week due_date = valid_timeframe.from_now ReferenceNumber.new( due_date: due_date, amount: amount, payment_id: payment_id ) end
soap_action(key)
click to toggle source
# File lib/dolla/gateway.rb, line 52 def soap_action key actions = amex? ? ACTIONS[:amex] : ACTIONS[:default] actions[key] end
wsdl_address()
click to toggle source
# File lib/dolla/gateway.rb, line 44 def wsdl_address amex? ? get_wsdl_address(:amex) : get_wsdl_address end
xml_namespace()
click to toggle source
# File lib/dolla/gateway.rb, line 48 def xml_namespace amex? ? get_xml_namespace(:amex) : get_xml_namespace end