lib/active_merchant/billing/gateways/payflow.rb in activemerchant-1.42.2 vs lib/active_merchant/billing/gateways/payflow.rb in activemerchant-1.42.3
- old
+ new
@@ -17,25 +17,28 @@
request = build_sale_or_authorization_request(:authorization, money, credit_card_or_reference, options)
commit(request, options)
end
- def purchase(money, credit_card_or_reference, options = {})
- request = build_sale_or_authorization_request(:purchase, money, credit_card_or_reference, options)
+ def purchase(money, funding_source, options = {})
+ request = build_sale_or_authorization_request(:purchase, money, funding_source, options)
commit(request, options)
end
- def credit(money, identification_or_credit_card, options = {})
- if identification_or_credit_card.is_a?(String)
+ def credit(money, funding_source, options = {})
+ if funding_source.is_a?(String)
deprecated CREDIT_DEPRECATION_MESSAGE
# Perform referenced credit
- refund(money, identification_or_credit_card, options)
- else
+ refund(money, funding_source, options)
+ elsif card_brand(funding_source) == 'check'
# Perform non-referenced credit
- request = build_credit_card_request(:credit, money, identification_or_credit_card, options)
+ request = build_check_request(:credit, money, funding_source, options)
commit(request, options)
+ else
+ request = build_credit_card_request(:credit, money, funding_source, options)
+ commit(request, options)
end
end
def refund(money, reference, options = {})
commit(build_reference_request(:credit, money, reference, options), options)
@@ -74,15 +77,17 @@
def express
@express ||= PayflowExpressGateway.new(@options)
end
private
- def build_sale_or_authorization_request(action, money, credit_card_or_reference, options)
- if credit_card_or_reference.is_a?(String)
- build_reference_sale_or_authorization_request(action, money, credit_card_or_reference, options)
+ def build_sale_or_authorization_request(action, money, funding_source, options)
+ if funding_source.is_a?(String)
+ build_reference_sale_or_authorization_request(action, money, funding_source, options)
+ elsif card_brand(funding_source) == 'check'
+ build_check_request(action, money, funding_source, options)
else
- build_credit_card_request(action, money, credit_card_or_reference, options)
+ build_credit_card_request(action, money, funding_source, options)
end
end
def build_reference_sale_or_authorization_request(action, money, reference, options)
xml = Builder::XmlMarkup.new
@@ -139,9 +144,34 @@
xml.tag! 'TotalAmt', amount(money), 'Currency' => options[:currency] || currency(money)
end
xml.tag! 'Tender' do
add_credit_card(xml, credit_card)
+ end
+ end
+ end
+ xml.target!
+ end
+
+ def build_check_request(action, money, check, options)
+ 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].to_s.gsub(/[^\w.]/, '') unless options[:order_id].blank?
+ xml.tag! 'Description', options[:description] unless options[:description].blank?
+ xml.tag! 'BillTo' do
+ xml.tag! 'Name', check.name
+ end
+ xml.tag! 'TotalAmt', amount(money), 'Currency' => options[:currency] || currency(money)
+ end
+ xml.tag! 'Tender' do
+ xml.tag! 'ACH' do
+ xml.tag! 'AcctType', check.account_type == 'checking' ? 'C' : 'S'
+ xml.tag! 'AcctNum', check.account_number
+ xml.tag! 'ABA', check.routing_number
+ end
end
end
end
xml.target!
end