lib/active_merchant/billing/gateways/authorize_net.rb in activemerchant-1.49.0 vs lib/active_merchant/billing/gateways/authorize_net.rb in activemerchant-1.50.0
- old
+ new
@@ -33,10 +33,15 @@
'3153' => STANDARD_ERROR_CODE[:processing_error],
'235' => STANDARD_ERROR_CODE[:processing_error],
'24' => STANDARD_ERROR_CODE[:pickup_card]
}
+ MARKET_TYPE = {
+ :moto => '1',
+ :retail => '2'
+ }
+
class_attribute :duplicate_window
APPROVED, DECLINED, ERROR, FRAUD_REVIEW = 1, 2, 3, 4
TRANSACTION_ALREADY_ACTIONED = %w(310 311)
@@ -64,11 +69,11 @@
xml.amount(amount(amount))
add_payment_source(xml, payment)
add_invoice(xml, options)
add_customer_data(xml, payment, options)
- add_retail_data(xml, payment)
+ add_market_type(xml, payment)
add_settings(xml, payment, options)
add_user_fields(xml, amount, options)
end
end
end
@@ -81,10 +86,11 @@
xml.amount(amount(amount))
add_payment_source(xml, payment)
add_invoice(xml, options)
add_customer_data(xml, payment, options)
+ add_market_type(xml, payment)
add_settings(xml, payment, options)
add_user_fields(xml, amount, options)
end
end
end
@@ -266,14 +272,19 @@
xml.dataValue(Base64.strict_encode64(apple_pay_payment_token.payment_data.to_json))
end
end
end
- def add_retail_data(xml, payment)
- return unless valid_track_data
- xml.retail do
- # As per http://www.authorize.net/support/CP_guide.pdf, '2' is for Retail, the only current market_type
- xml.marketType(2)
+ def add_market_type(xml, payment)
+ return if card_brand(payment) == 'check' or card_brand(payment) == 'apple_pay'
+ if valid_track_data
+ xml.retail do
+ xml.marketType(MARKET_TYPE[:retail])
+ end
+ elsif payment.manual_entry
+ xml.retail do
+ xml.marketType(MARKET_TYPE[:moto])
+ end
end
end
def valid_track_data
@valid_track_data ||= false