lib/active_merchant/billing/gateways/redsys.rb in activemerchant-1.105.0 vs lib/active_merchant/billing/gateways/redsys.rb in activemerchant-1.106.0
- old
+ new
@@ -89,15 +89,15 @@
# The set of supported transactions for this gateway.
# More operations are supported by the gateway itself, but
# are not supported in this library.
SUPPORTED_TRANSACTIONS = {
- :purchase => 'A',
- :authorize => '1',
- :capture => '2',
- :refund => '3',
- :cancel => '9'
+ purchase: 'A',
+ authorize: '1',
+ capture: '2',
+ refund: '3',
+ cancel: '9'
}
# These are the text meanings sent back by the acquirer when
# a card has been rejected. Syntax or general request errors
# are not covered here.
@@ -234,11 +234,11 @@
def void(authorization, options = {})
data = {}
add_action(data, :cancel)
order_id, amount, currency = split_authorization(authorization)
- add_amount(data, amount, :currency => currency)
+ add_amount(data, amount, currency: currency)
add_order(data, order_id)
data[:description] = options[:description]
commit data, options
end
@@ -300,25 +300,25 @@
def url
test? ? test_url : live_url
end
def threeds_url
- test? ? 'https://sis-t.redsys.es:25443/sis/services/SerClsWSEntradaV2': 'https://sis.redsys.es/sis/services/SerClsWSEntradaV2'
+ test? ? 'https://sis-t.redsys.es:25443/sis/services/SerClsWSEntradaV2' : 'https://sis.redsys.es/sis/services/SerClsWSEntradaV2'
end
def add_payment(data, card)
if card.is_a?(String)
data[:credit_card_token] = card
else
name = [card.first_name, card.last_name].join(' ').slice(0, 60)
year = sprintf('%.4i', card.year)
month = sprintf('%.2i', card.month)
data[:card] = {
- :name => name,
- :pan => card.number,
- :date => "#{year[2..3]}#{month}",
- :cvv => card.verification_value
+ name: name,
+ pan: card.number,
+ date: "#{year[2..3]}#{month}",
+ cvv: card.verification_value
}
end
end
def add_threeds(data, options)
@@ -354,11 +354,11 @@
def headers(action=nil)
if action
{
'Content-Type' => 'text/xml',
- 'SOAPAction' => action
+ 'SOAPAction' => action
}
else
{
'Content-Type' => 'application/x-www-form-urlencoded'
}
@@ -405,11 +405,11 @@
end
xml.target!
end
def build_sha1_xml_request(data, options = {})
- xml = Builder::XmlMarkup.new :indent => 2
+ xml = Builder::XmlMarkup.new indent: 2
build_merchant_data(xml, data, options)
xml.target!
end
def merchant_data_xml(data, options = {})
@@ -424,19 +424,27 @@
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]
- xml.DS_MERCHANT_PRODUCTDESCRIPTION data[:description]
+ if data[:description] && data[:threeds]
+ 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]
# Only when card is present
if data[:card]
- xml.DS_MERCHANT_TITULAR data[:card][:name]
+ if data[:card][:name] && data[:threeds]
+ 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]
xml.DS_MERCHANT_EXPIRYDATE data[:card][:date]
xml.DS_MERCHANT_CVV2 data[:card][:cvv]
xml.DS_MERCHANT_IDENTIFIER 'REQUIRED' if data[:store_in_vault]
elsif data[:credit_card_token]
@@ -454,10 +462,10 @@
def parse(data, action)
params = {}
success = false
message = ''
- options = @options.merge(:test => test?)
+ options = @options.merge(test: test?)
xml = Nokogiri::XML(data)
code = xml.xpath('//RETORNOXML/CODIGO').text
if code == '0' && xml.xpath('//RETORNOXML/OPERACION').present?
op = xml.xpath('//RETORNOXML/OPERACION')