lib/active_merchant/billing/gateways/payflow.rb in activemerchant-1.2.1 vs lib/active_merchant/billing/gateways/payflow.rb in activemerchant-1.3.0

- old
+ new

@@ -60,12 +60,12 @@ def cancel_recurring(profile_id) request = build_recurring_request(:cancel, 0, :profile_id => profile_id) commit(request, :recurring) end - def recurring_inquiry(profile_id) - request = build_recurring_request(:inquiry, nil, :profile_id => profile_id) + def recurring_inquiry(profile_id, options = {}) + request = build_recurring_request(:inquiry, nil, options.update( :profile_id => profile_id )) commit(request, :recurring) end def express @express ||= PayflowExpressGateway.new(@options) @@ -79,11 +79,11 @@ build_credit_card_request(action, money, credit_card_or_reference, options) end end def build_reference_sale_or_authorization_request(action, money, reference, options) - xml = Builder::XmlMarkup.new :indent => 2 + xml = Builder::XmlMarkup.new xml.tag! TRANSACTIONS[action] do xml.tag! 'PayData' do xml.tag! 'Invoice' do xml.tag! 'TotalAmt', amount(money), 'Currency' => options[:currency] || currency(money) end @@ -96,23 +96,21 @@ end xml.target! end def build_credit_card_request(action, money, credit_card, options) - xml = Builder::XmlMarkup.new :indent => 2 + xml = Builder::XmlMarkup.new xml.tag! TRANSACTIONS[action] do xml.tag! 'PayData' do xml.tag! 'Invoice' do xml.tag! 'CustIP', options[:ip] unless options[:ip].blank? - xml.tag! 'InvNum', options[:order_id] unless options[:order_id].blank? + xml.tag! 'InvNum', options[:order_id].to_s.gsub(/[^\w.]/, '') unless options[:order_id].blank? xml.tag! 'Description', options[:description] unless options[:description].blank? billing_address = options[:billing_address] || options[:address] - shipping_address = options[:shipping_address] || billing_address - - add_address(xml, 'BillTo', billing_address, options) - add_address(xml, 'ShipTo', shipping_address, options) + add_address(xml, 'BillTo', billing_address, options) if billing_address + add_address(xml, 'ShipTo', options[:shipping_address], options) if options[:shipping_address] xml.tag! 'TotalAmt', amount(money), 'Currency' => options[:currency] || currency(money) end xml.tag! 'Tender' do @@ -161,11 +159,11 @@ def build_recurring_request(action, money, options) unless RECURRING_ACTIONS.include?(action) raise StandardError, "Invalid Recurring Profile Action: #{action}" end - xml = Builder::XmlMarkup.new :indent => 2 + xml = Builder::XmlMarkup.new xml.tag! 'RecurringProfiles' do xml.tag! 'RecurringProfile' do xml.tag! action.to_s.capitalize do unless [:cancel, :inquiry].include?(action) xml.tag! 'RPData' do @@ -186,20 +184,21 @@ xml.tag! 'Start', format_rp_date(options[:starting_at] || Date.today + 1 ) xml.tag! 'EMail', options[:email] unless options[:email].nil? billing_address = options[:billing_address] || options[:address] - shipping_address = options[:shipping_address] || billing_address - - add_address(xml, 'BillTo', billing_address, options) - add_address(xml, 'ShipTo', shipping_address, options) + add_address(xml, 'BillTo', billing_address, options) if billing_address + add_address(xml, 'ShipTo', options[:shipping_address], options) if options[:shipping_address] end xml.tag! 'Tender' do yield xml end end if action != :add xml.tag! "ProfileID", options[:profile_id] + end + if action == :inquiry + xml.tag! "PaymentHistory", ( options[:history] ? 'Y' : 'N' ) end end end end end