lib/active_merchant/billing/gateways/paypal.rb in activemerchant-1.117.0 vs lib/active_merchant/billing/gateways/paypal.rb in activemerchant-1.118.0

- old
+ new

@@ -56,11 +56,11 @@ currency_code = options[:currency] || currency(money) xml = Builder::XmlMarkup.new indent: 2 xml.tag! transaction_type + 'Req', 'xmlns' => PAYPAL_NAMESPACE do xml.tag! transaction_type + 'Request', 'xmlns:n2' => EBAY_NAMESPACE do - xml.tag! 'n2:Version', API_VERSION + xml.tag! 'n2:Version', api_version(options) xml.tag! 'n2:' + transaction_type + 'RequestDetails' do xml.tag! 'n2:ReferenceID', reference_id if transaction_type == 'DoReferenceTransaction' xml.tag! 'n2:PaymentAction', action add_descriptors(xml, options) add_payment_details(xml, money, currency_code, options) @@ -71,10 +71,16 @@ end xml.target! end + def api_version(options) + return API_VERSION_3DS2 if options.dig(:three_d_secure, :version) =~ /^2/ + + API_VERSION + end + def add_credit_card(xml, credit_card, address, options) xml.tag! 'n2:CreditCard' do xml.tag! 'n2:CreditCardType', credit_card_type(card_brand(credit_card)) xml.tag! 'n2:CreditCardNumber', credit_card.number xml.tag! 'n2:ExpMonth', format(credit_card.month, :two_digits) @@ -102,13 +108,15 @@ def add_three_d_secure(xml, options) three_d_secure = options[:three_d_secure] xml.tag! 'ThreeDSecureRequest' do xml.tag! 'MpiVendor3ds', 'Y' - xml.tag! 'AuthStatus3ds', three_d_secure[:trans_status] unless three_d_secure[:trans_status].blank? + xml.tag! 'AuthStatus3ds', three_d_secure[:authentication_response_status] || three_d_secure[:trans_status] if three_d_secure[:authentication_response_status] || three_d_secure[:trans_status] xml.tag! 'Cavv', three_d_secure[:cavv] unless three_d_secure[:cavv].blank? xml.tag! 'Eci3ds', three_d_secure[:eci] unless three_d_secure[:eci].blank? xml.tag! 'Xid', three_d_secure[:xid] unless three_d_secure[:xid].blank? + xml.tag! 'ThreeDSVersion', three_d_secure[:version] unless three_d_secure[:version].blank? + xml.tag! 'DSTransactionId', three_d_secure[:ds_transaction_id] unless three_d_secure[:ds_transaction_id].blank? end end def credit_card_type(type) case type