lib/active_merchant/billing/gateways/realex.rb in activemerchant-1.14.0 vs lib/active_merchant/billing/gateways/realex.rb in activemerchant-1.15.0
- old
+ new
@@ -129,11 +129,11 @@
add_merchant_details(xml, options)
xml.tag! 'orderid', sanitize_order_id(options[:order_id])
add_amount(xml, money, options)
add_card(xml, credit_card)
xml.tag! 'autosettle', 'flag' => auto_settle_flag(action)
- add_signed_digest(xml, timestamp, @options[:login], options[:order_id], amount(money), (options[:currency] || currency(money)), credit_card.number)
+ add_signed_digest(xml, timestamp, @options[:login], sanitize_order_id(options[:order_id]), amount(money), (options[:currency] || currency(money)), credit_card.number)
add_comments(xml, options)
add_address_and_customer_info(xml, options)
end
xml.target!
end
@@ -143,11 +143,11 @@
xml = Builder::XmlMarkup.new :indent => 2
xml.tag! 'request', 'timestamp' => timestamp, 'type' => 'settle' do
add_merchant_details(xml, options)
add_transaction_identifiers(xml, authorization, options)
add_comments(xml, options)
- add_signed_digest(xml, timestamp, @options[:login], options[:order_id])
+ add_signed_digest(xml, timestamp, @options[:login], sanitize_order_id(options[:order_id]), nil, nil, nil)
end
xml.target!
end
def build_refund_request(money, authorization, options)
@@ -158,11 +158,11 @@
add_transaction_identifiers(xml, authorization, options)
xml.tag! 'amount', amount(money), 'currency' => options[:currency] || currency(money)
xml.tag! 'refundhash', @options[:refund_hash] if @options[:refund_hash]
xml.tag! 'autosettle', 'flag' => 1
add_comments(xml, options)
- add_signed_digest(xml, timestamp, @options[:login], options[:order_id], amount(money), (options[:currency] || currency(money)))
+ add_signed_digest(xml, timestamp, @options[:login], sanitize_order_id(options[:order_id]), amount(money), (options[:currency] || currency(money)), nil)
end
xml.target!
end
def build_void_request(authorization, options)
@@ -170,11 +170,11 @@
xml = Builder::XmlMarkup.new :indent => 2
xml.tag! 'request', 'timestamp' => timestamp, 'type' => 'void' do
add_merchant_details(xml, options)
add_transaction_identifiers(xml, authorization, options)
add_comments(xml, options)
- add_signed_digest(xml, timestamp, @options[:login], options[:order_id])
+ add_signed_digest(xml, timestamp, @options[:login], sanitize_order_id(options[:order_id]), nil, nil, nil)
end
xml.target!
end
def add_address_and_customer_info(xml, options)
@@ -205,11 +205,11 @@
end
def add_merchant_details(xml, options)
xml.tag! 'merchantid', @options[:login]
if options[:account] || @options[:account]
- xml.tag! 'account', options[:account] || @options[:account]
+ xml.tag! 'account', (options[:account] || @options[:account])
end
end
def add_transaction_identifiers(xml, authorization, options)
options[:order_id], pasref, authcode = authorization.split(';')
@@ -250,37 +250,24 @@
def extract_digits(string)
return "" if string.nil?
string.gsub(/[\D]/,'')
end
- def stringify_values(values)
- string = ""
- (0..5).each do |i|
- string << "#{values[i]}"
- string << "." unless i == 5
- end
- string
- end
-
def new_timestamp
Time.now.strftime('%Y%m%d%H%M%S')
end
def add_signed_digest(xml, *values)
- string = stringify_values(values)
- xml.tag! 'sha1hash', sha1from(string)
+ string = Digest::SHA1.hexdigest(values.join("."))
+ xml.tag! 'sha1hash', Digest::SHA1.hexdigest([string, @options[:password]].join("."))
end
def auto_settle_flag(action)
action == :authorization ? '0' : '1'
end
def expiry_date(credit_card)
"#{format(credit_card.month, :two_digits)}#{format(credit_card.year, :two_digits)}"
- end
-
- def sha1from(string)
- Digest::SHA1.hexdigest("#{Digest::SHA1.hexdigest(string)}.#{@options[:password]}")
end
def normalize(field)
case field
when "true" then true
\ No newline at end of file