lib/active_merchant/billing/gateways/realex.rb in activemerchant-1.96.0 vs lib/active_merchant/billing/gateways/realex.rb in activemerchant-1.97.0

- old
+ new

@@ -40,11 +40,12 @@ BANK_ERROR = REALEX_ERROR = 'Gateway is in maintenance. Please try again later.' ERROR = CLIENT_DEACTIVATED = 'Gateway Error' def initialize(options = {}) requires!(options, :login, :password) - options[:refund_hash] = Digest::SHA1.hexdigest(options[:rebate_secret]) if options.has_key?(:rebate_secret) + options[:refund_hash] = Digest::SHA1.hexdigest(options[:rebate_secret]) if options[:rebate_secret].present? + options[:credit_hash] = Digest::SHA1.hexdigest(options[:refund_secret]) if options[:refund_secret].present? super end def purchase(money, credit_card, options = {}) requires!(options, :order_id) @@ -68,13 +69,13 @@ def refund(money, authorization, options = {}) request = build_refund_request(money, authorization, options) commit(request) end - def credit(money, authorization, options = {}) - ActiveMerchant.deprecated CREDIT_DEPRECATION_MESSAGE - refund(money, authorization, options) + def credit(money, creditcard, options = {}) + request = build_credit_request(money, creditcard, options) + commit(request) end def void(authorization, options = {}) request = build_void_request(authorization, options) commit(request) @@ -178,9 +179,25 @@ 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], sanitize_order_id(options[:order_id]), amount(money), (options[:currency] || currency(money)), nil) + end + xml.target! + end + + def build_credit_request(money, credit_card, options) + timestamp = new_timestamp + xml = Builder::XmlMarkup.new :indent => 2 + xml.tag! 'request', 'timestamp' => timestamp, 'type' => 'credit' do + 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! 'refundhash', @options[:credit_hash] if @options[:credit_hash] + xml.tag! 'autosettle', 'flag' => 1 + add_comments(xml, options) + add_signed_digest(xml, timestamp, @options[:login], sanitize_order_id(options[:order_id]), amount(money), (options[:currency] || currency(money)), credit_card.number) end xml.target! end def build_void_request(authorization, options)