lib/active_merchant/billing/gateways/redsys.rb in activemerchant-1.119.0 vs lib/active_merchant/billing/gateways/redsys.rb in activemerchant-1.120.0
- old
+ new
@@ -206,10 +206,11 @@
add_threeds(data, options) if options[:execute_threed]
add_stored_credential_options(data, options)
data[:description] = options[:description]
data[:store_in_vault] = options[:store]
data[:sca_exemption] = options[:sca_exemption]
+ data[:sca_exemption_direct_payment_enabled] = options[:sca_exemption_direct_payment_enabled]
commit data, options
end
def authorize(money, payment, options = {})
@@ -224,10 +225,11 @@
add_threeds(data, options) if options[:execute_threed]
add_stored_credential_options(data, options)
data[:description] = options[:description]
data[:store_in_vault] = options[:store]
data[:sca_exemption] = options[:sca_exemption]
+ data[:sca_exemption_direct_payment_enabled] = options[:sca_exemption_direct_payment_enabled]
commit data, options
end
def capture(money, authorization, options = {})
@@ -395,11 +397,12 @@
</soapenv:Body>
</soapenv:Envelope>
REQUEST
parse(ssl_post(threeds_url, request, headers(action)), action)
else
- parse(ssl_post(url, "entrada=#{CGI.escape(xml_request_from(data, options))}", headers), action)
+ xmlreq = xml_request_from(data, options)
+ parse(ssl_post(url, "entrada=#{CGI.escape(xmlreq)}", headers), action)
end
end
def headers(action = nil)
if action
@@ -465,32 +468,44 @@
xml = Builder::XmlMarkup.new
build_merchant_data(xml, data, options)
xml.target!
end
+ # Template Method to allow AM API clients to override decision to escape, based on their own criteria.
+ def escape_special_chars?(data, options = {})
+ data[:threeds]
+ end
+
def build_merchant_data(xml, data, options = {})
# See https://sis-t.redsys.es:25443/sis/services/SerClsWSEntradaV2/wsdl/SerClsWSEntradaV2.wsdl
# (which results from calling #threeds_url + '?WSDL', https://sis-t.redsys.es:25443/sis/services/SerClsWSEntradaV2?WSDL)
xml.DATOSENTRADA do
# Basic elements
xml.DS_Version 0.1
xml.DS_MERCHANT_CURRENCY data[:currency]
xml.DS_MERCHANT_AMOUNT data[:amount]
xml.DS_MERCHANT_ORDER data[:order_id]
xml.DS_MERCHANT_TRANSACTIONTYPE data[:action]
- if data[:description] && data[:threeds]
+ if data[:description] && escape_special_chars?(data, options)
xml.DS_MERCHANT_PRODUCTDESCRIPTION CGI.escape(data[:description])
else
xml.DS_MERCHANT_PRODUCTDESCRIPTION data[:description]
end
xml.DS_MERCHANT_TERMINAL options[:terminal] || @options[:terminal]
xml.DS_MERCHANT_MERCHANTCODE @options[:login]
xml.DS_MERCHANT_MERCHANTSIGNATURE build_signature(data) unless sha256_authentication?
- xml.DS_MERCHANT_EXCEP_SCA data[:sca_exemption] if data[:sca_exemption]
+ action = determine_3ds_action(data[:threeds]) if data[:threeds]
+ if action == 'iniciaPeticion' && data[:sca_exemption]
+ xml.DS_MERCHANT_EXCEP_SCA 'Y'
+ else
+ xml.DS_MERCHANT_EXCEP_SCA data[:sca_exemption] if data[:sca_exemption]
+ xml.DS_MERCHANT_DIRECTPAYMENT data[:sca_exemption_direct_payment_enabled] if data[:sca_exemption_direct_payment_enabled]
+ end
+
# Only when card is present
if data[:card]
- if data[:card][:name] && data[:threeds]
+ if data[:card][:name] && escape_special_chars?(data, options)
xml.DS_MERCHANT_TITULAR CGI.escape(data[:card][:name])
else
xml.DS_MERCHANT_TITULAR data[:card][:name]
end
xml.DS_MERCHANT_PAN data[:card][:pan]