diff --git a/lib/active_merchant/billing/gateways/litle.rb b/lib/active_merchant/billing/gateways/litle.rb index 763eefa8041..07d6847e1ae 100644 --- a/lib/active_merchant/billing/gateways/litle.rb +++ b/lib/active_merchant/billing/gateways/litle.rb @@ -1,5 +1,6 @@ require 'nokogiri' require 'active_merchant/billing/gateways/litle/paypage_registration' +require 'active_merchant/billing/gateways/litle/token' module ActiveMerchant #:nodoc: module Billing #:nodoc: @@ -47,11 +48,11 @@ def add_level_two_data(doc, payment_method, options = {}) case payment_method.brand when 'visa' doc.salesTax(level_2_data[:sales_tax]) if level_2_data[:sales_tax] - doc.taxExempt(true) if level_2_data[:sales_tax] == 0 + doc.taxExempt(true) if level_2_data[:sales_tax].to_i == 0 when 'master' doc.customerReference(level_2_data[:customer_code]) if level_2_data[:customer_code] doc.salesTax(level_2_data[:total_tax_amount]) if level_2_data[:total_tax_amount] - doc.taxExempt(true) if level_2_data[:total_tax_amount] == 0 + doc.taxExempt(true) if level_2_data[:total_tax_amount].to_i == 0 doc.detailTax do doc.taxIncludedInTotal(level_2_data[:tax_included_in_total]) if level_2_data[:tax_included_in_total] doc.taxAmount(level_2_data[:tax_amount]) if level_2_data[:tax_amount] @@ -93,7 +94,7 @@ def add_level_three_information_tags_visa(doc, payment_method, level_3_data) def add_level_three_information_tags_master(doc, payment_method, level_3_data) doc.customerReference :customerReference, level_3_data[:customer_code] if level_3_data[:customer_code] doc.salesTax(level_3_data[:total_tax_amount]) if level_3_data[:total_tax_amount] - doc.taxExempt(true) if level_3_data[:total_tax_amount] == 0 + doc.taxExempt(true) if level_3_data[:total_tax_amount].to_i == 0 doc.detailTax do doc.taxIncludedInTotal(level_3_data[:tax_included_in_total]) if level_3_data[:tax_included_in_total] doc.taxAmount(level_3_data[:tax_amount]) if level_3_data[:tax_amount] @@ -114,15 +115,15 @@ def add_line_item_information_for_level_three_visa(doc, payment_method, level_3_ doc.lineItemData do level_3_data[:line_items].each do |line_item| doc.itemSequenceNumber(line_item[:item_sequence_number]) if line_item[:item_sequence_number] - doc.commodityCode(line_item[:commodity_code]) if line_item[:commodity_code] doc.itemDescription(line_item[:item_description]) if line_item[:item_description] doc.productCode(line_item[:product_code]) if line_item[:product_code] doc.quantity(line_item[:quantity]) if line_item[:quantity] doc.unitOfMeasure(line_item[:unit_of_measure]) if line_item[:unit_of_measure] doc.taxAmount(line_item[:tax_amount]) if line_item[:tax_amount] - doc.itemDiscountAmount(line_item[:discount_per_line_item]) unless line_item[:discount_per_line_item] < 0 - doc.unitCost(line_item[:unit_cost]) unless line_item[:unit_cost] < 0 doc.lineItemTotal(line_item[:line_item_total]) if line_item[:line_item_total] + doc.itemDiscountAmount(line_item[:discount_per_line_item]) if line_item[:discount_per_line_item] + doc.commodityCode(line_item[:commodity_code]) if line_item[:commodity_code] + doc.unitCost(line_item[:unit_cost]) if line_item[:unit_cost] doc.detailTax do doc.taxIncludedInTotal(line_item[:tax_included_in_total]) if line_item[:tax_included_in_total] doc.taxAmount(line_item[:tax_amount]) if line_item[:tax_amount] @@ -320,10 +321,10 @@ def add_auth_purchase_params(doc, money, payment_method, options) add_payment_method(doc, payment_method, options) add_pos(doc, payment_method) add_descriptor(doc, options) - add_processing_type(doc, options) - add_original_network_transaction(doc, options) add_level_two_data(doc, payment_method, options) add_level_three_data(doc, payment_method, options) + add_processing_type(doc, options) + add_original_network_transaction(doc, options) add_merchant_data(doc, options) add_debt_repayment(doc, options) add_stored_credential_params(doc, options) @@ -382,14 +383,14 @@ def add_payment_method(doc, payment_method, options) doc.expDate("#{options[:month]}#{options[:year]}") end end - elsif payment_method.respond_to?(:litle_token) + elsif payment_method.litle_token.present? doc.token do doc.litleToken(payment_method.litle_token) if payment_method.try(:month) && payment_method.try(:year) doc.expDate("#{payment_method.month}#{payment_method.year}") end end - elsif payment_method.respond_to?(:paypage_registration_id) + elsif payment_method.paypage_registration_id.present? doc.paypage do doc.paypageRegistrationId(payment_method.paypage_registration_id) if payment_method.try(:month) && payment_method.try(:year) diff --git a/lib/active_merchant/billing/gateways/litle/paypage_registration.rb b/lib/active_merchant/billing/gateways/litle/paypage_registration.rb index f8f4613295a..463712658fb 100644 --- a/lib/active_merchant/billing/gateways/litle/paypage_registration.rb +++ b/lib/active_merchant/billing/gateways/litle/paypage_registration.rb @@ -13,7 +13,7 @@ module Billing # The name parameter is allowed by Vantiv as a member of the billToAddress element. # It is passed in here to be consistent with the rest of the Litle gateway and Activemerchant. class LitlePaypageRegistration - attr_reader :paypage_registration_id, :month, :year, :verification_value, :name, :type + attr_reader :paypage_registration_id, :month, :year, :verification_value, :name, :type, :brand, :litle_token def initialize(paypage_registration_id, options = {}) @paypage_registration_id = paypage_registration_id @@ -22,6 +22,8 @@ def initialize(paypage_registration_id, options = {}) @verification_value = options[:verification_value] @name = options[:name] @type = options[:type] + @brand = options[:brand] + @litle_token = options[:litle_token] end end end diff --git a/lib/active_merchant/billing/gateways/litle/token.rb b/lib/active_merchant/billing/gateways/litle/token.rb new file mode 100644 index 00000000000..18e34eb61f2 --- /dev/null +++ b/lib/active_merchant/billing/gateways/litle/token.rb @@ -0,0 +1,15 @@ +module ActiveMerchant + module Billing + # The name parameter is allowed by Vantiv as a member of the billToAddress element. + # It is passed in here to be consistent with the rest of the Litle gateway and Activemerchant. + class LitleToken + attr_reader :name, :brand, :litle_token + + def initialize(options = {}) + @name = options[:name] + @brand = options[:brand] + @litle_token = options[:litle_token] + end + end + end +end