lib/active_merchant/billing/gateways/ipg.rb in activemerchant-1.133.0 vs lib/active_merchant/billing/gateways/ipg.rb in activemerchant-1.137.0

- old
+ new

@@ -16,11 +16,11 @@ } ACTION_REQUEST_ITEMS = %w(vault unstore) def initialize(options = {}) - requires!(options, :store_id, :user_id, :password, :pem, :pem_password) + requires!(options, :user_id, :password, :pem, :pem_password) @credentials = options @hosted_data_id = nil super end @@ -84,12 +84,11 @@ def scrub(transcript) transcript. gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]'). gsub(%r((<v1:CardNumber>).+(</v1:CardNumber>)), '\1[FILTERED]\2'). - gsub(%r((<v1:CardCodeValue>).+(</v1:CardCodeValue>)), '\1[FILTERED]\2'). - gsub(%r((<v1:StoreId>).+(</v1:StoreId>)), '\1[FILTERED]\2') + gsub(%r((<v1:CardCodeValue>).+(</v1:CardCodeValue>)), '\1[FILTERED]\2') end private NAMESPACE_BASE_URL = 'http://ipg-online.com' @@ -271,11 +270,11 @@ xml.tag!('v1:HostedDataStoreID', options[:hosted_data_store_id]) if options[:hosted_data_store_id] xml.tag!('v1:DeclineHostedDataDuplicates', options[:decline_hosted_data_duplicates]) if options[:decline_hosted_data_duplicates] xml.tag!('v1:SubTotal', options[:sub_total]) if options[:sub_total] xml.tag!('v1:ValueAddedTax', options[:value_added_tax]) if options[:value_added_tax] xml.tag!('v1:DeliveryAmount', options[:delivery_amount]) if options[:delivery_amount] - xml.tag!('v1:ChargeTotal', money) + xml.tag!('v1:ChargeTotal', amount(money)) xml.tag!('v1:Currency', CURRENCY_CODES[options[:currency]]) xml.tag!('v1:numberOfInstallments', options[:number_of_installments]) if options[:number_of_installments] end end @@ -315,11 +314,14 @@ 'Authorization' => "Basic #{encoded_credentials}" } end def encoded_credentials - Base64.encode64("WS#{@credentials[:store_id]}._.#{@credentials[:user_id]}:#{@credentials[:password]}").delete("\n") + # We remove 'WS' and add it back on the next line because the ipg docs are a little confusing. + # Some merchants will likely add it to their user_id and others won't. + user_id = @credentials[:user_id].sub(/^WS/, '') + Base64.encode64("WS#{user_id}:#{@credentials[:password]}").delete("\n") end def envelope_namespaces { 'xmlns:soapenv' => 'http://schemas.xmlsoap.org/soap/envelope/', @@ -342,9 +344,11 @@ 'xmlns:ns3' => "#{NAMESPACE_BASE_URL}/ipgapi/schemas/v1" } end def override_store_id(options) + raise ArgumentError, 'store_id must be provieded' if @credentials[:store_id].blank? && options[:store_id].blank? + @credentials[:store_id] = options[:store_id] if options[:store_id].present? end def commit(action, request, options = {}) override_store_id(options)