lib/active_merchant/billing/gateways/card_stream.rb in activemerchant-1.77.0 vs lib/active_merchant/billing/gateways/card_stream.rb in activemerchant-1.78.0

- old
+ new

@@ -153,41 +153,55 @@ add_pair(post, :captureDelay, -1) add_amount(post, money, options) add_invoice(post, credit_card_or_reference, money, options) add_credit_card_or_reference(post, credit_card_or_reference) add_customer_data(post, options) + add_remote_address(post, options) commit('SALE', post) end def purchase(money, credit_card_or_reference, options = {}) post = {} add_pair(post, :captureDelay, 0) add_amount(post, money, options) add_invoice(post, credit_card_or_reference, money, options) add_credit_card_or_reference(post, credit_card_or_reference) add_customer_data(post, options) + add_remote_address(post, options) commit('SALE', post) end def capture(money, authorization, options = {}) post = {} add_pair(post, :xref, authorization) add_pair(post, :amount, amount(money), :required => true) + add_remote_address(post, options) commit('CAPTURE', post) end def refund(money, authorization, options = {}) post = {} add_pair(post, :xref, authorization) add_amount(post, money, options) - commit('REFUND', post) + add_remote_address(post, options) + response = commit('REFUND_SALE', post) + + return response if response.success? + return response unless options[:force_full_refund_if_unsettled] + + if response.params["responseCode"] == "65541" + void(authorization, options) + else + response + end end def void(authorization, options = {}) post = {} add_pair(post, :xref, authorization) + add_remote_address(post, options) commit('CANCEL', post) end def verify(creditcard, options={}) MultiResponse.run(:use_first_response) do |r| @@ -218,10 +232,13 @@ add_pair(post, :customerEmail, options[:email]) if (address = options[:billing_address] || options[:address]) add_pair(post, :customerAddress, "#{address[:address1]} #{address[:address2]}".strip) add_pair(post, :customerPostCode, address[:zip]) add_pair(post, :customerPhone, options[:phone]) + add_pair(post, :customerCountryCode, address[:country] || 'GB') + else + add_pair(post, :customerCountryCode, 'GB') end end def add_invoice(post, credit_card_or_reference, money, options) add_pair(post, :transactionUnique, options[:order_id], :required => true) @@ -269,9 +286,13 @@ add_pair(post, :cardCVV, credit_card.verification_value) end def add_threeds_required(post, options) add_pair(post, :threeDSRequired, (options[:threeds_required] || @threeds_required) ? 'Y' : 'N') + end + + def add_remote_address(post, options={}) + add_pair(post, :remoteAddress, options[:ip] || '1.1.1.1') end def normalize_line_endings(str) str.gsub(/%0D%0A|%0A%0D|%0D/, "%0A") end