lib/active_merchant/billing/gateways/authorize_net.rb in activemerchant-1.78.0 vs lib/active_merchant/billing/gateways/authorize_net.rb in activemerchant-1.79.0

- old
+ new

@@ -165,11 +165,11 @@ add_order_id(xml, options) xml.transactionRequest do xml.transactionType('refundTransaction') xml.amount(amount(amount)) - add_payment_source(xml, payment) + add_payment_source(xml, payment, options, :credit) xml.refTransId(transaction_id_from(options[:transaction_id])) if options[:transaction_id] add_invoice(xml, 'refundTransaction', options) add_customer_data(xml, payment, options) add_settings(xml, payment, options) add_user_fields(xml, amount, options) @@ -244,11 +244,11 @@ def add_auth_purchase(xml, transaction_type, amount, payment, options) add_order_id(xml, options) xml.transactionRequest do xml.transactionType(transaction_type) xml.amount(amount(amount)) - add_payment_source(xml, payment) + add_payment_source(xml, payment, options) add_invoice(xml, transaction_type, options) add_tax_fields(xml, options) add_duty_fields(xml, options) add_shipping_fields(xml, options) add_tax_exempt_status(xml, options) @@ -266,11 +266,11 @@ xml.send(transaction_type) do xml.amount(amount(amount)) add_tax_fields(xml, options) add_shipping_fields(xml, options) add_duty_fields(xml, options) - add_payment_source(xml, payment) + add_payment_source(xml, payment, options) add_invoice(xml, transaction_type, options) add_tax_exempt_status(xml, options) end end end @@ -373,20 +373,20 @@ xml.refTransId(transaction_id_from(authorization)) end end end - def add_payment_source(xml, source) + def add_payment_source(xml, source, options, action = nil) return unless source if source.is_a?(String) - add_token_payment_method(xml, source) + add_token_payment_method(xml, source, options) elsif card_brand(source) == 'check' add_check(xml, source) elsif card_brand(source) == 'apple_pay' add_apple_pay_payment_token(xml, source) else - add_credit_card(xml, source) + add_credit_card(xml, source, action) end end def camel_case_lower(key) String(key).split('_').inject([]){ |buffer,e| buffer.push(buffer.empty? ? e : e.capitalize) }.join @@ -455,22 +455,22 @@ end end end end - def add_credit_card(xml, credit_card) + def add_credit_card(xml, credit_card, action) if credit_card.track_data add_swipe_data(xml, credit_card) else xml.payment do xml.creditCard do xml.cardNumber(truncate(credit_card.number, 16)) xml.expirationDate(format(credit_card.month, :two_digits) + '/' + format(credit_card.year, :four_digits)) if credit_card.valid_card_verification_value?(credit_card.verification_value, credit_card.brand) xml.cardCode(credit_card.verification_value) end - if credit_card.is_a?(NetworkTokenizationCreditCard) + if credit_card.is_a?(NetworkTokenizationCreditCard) && action != :credit xml.cryptogram(credit_card.payment_cryptogram) end end end end @@ -487,12 +487,14 @@ end end end end - def add_token_payment_method(xml, token) + def add_token_payment_method(xml, token, options) customer_profile_id, customer_payment_profile_id, _ = split_authorization(token) + customer_profile_id = options[:customer_profile_id] if options[:customer_profile_id] + customer_payment_profile_id = options[:customer_payment_profile_id] if options[:customer_payment_profile_id] xml.customerProfileId(customer_profile_id) xml.customerPaymentProfileId(customer_payment_profile_id) end def add_apple_pay_payment_token(xml, apple_pay_payment_token) @@ -550,11 +552,14 @@ add_shipping_address(xml, options) xml.customerIP(options[:ip]) unless empty?(options[:ip]) xml.cardholderAuthentication do - xml.authenticationIndicator(options[:authentication_indicator]) - xml.cardholderAuthenticationValue(options[:cardholder_authentication_value]) + three_d_secure = options.fetch(:three_d_secure, {}) + xml.authenticationIndicator( + options[:authentication_indicator] || three_d_secure[:eci]) + xml.cardholderAuthenticationValue( + options[:cardholder_authentication_value] || three_d_secure[:cavv]) end end def add_billing_address(xml, payment_source, options) address = options[:billing_address] || options[:address] || {}