lib/active_merchant/billing/gateways/sage_pay.rb in activemerchant-1.79.2 vs lib/active_merchant/billing/gateways/sage_pay.rb in activemerchant-1.80.0
- old
+ new
@@ -23,34 +23,34 @@
:unstore => 'REMOVETOKEN',
:repeat => 'REPEAT'
}
CREDIT_CARDS = {
- :visa => "VISA",
- :master => "MC",
- :delta => "DELTA",
- :solo => "SOLO",
- :switch => "MAESTRO",
- :maestro => "MAESTRO",
- :american_express => "AMEX",
- :electron => "UKE",
- :diners_club => "DC",
- :jcb => "JCB"
+ :visa => 'VISA',
+ :master => 'MC',
+ :delta => 'DELTA',
+ :solo => 'SOLO',
+ :switch => 'MAESTRO',
+ :maestro => 'MAESTRO',
+ :american_express => 'AMEX',
+ :electron => 'UKE',
+ :diners_club => 'DC',
+ :jcb => 'JCB'
}
AVS_CODE = {
- "NOTPROVIDED" => nil,
- "NOTCHECKED" => 'X',
- "MATCHED" => 'Y',
- "NOTMATCHED" => 'N'
+ 'NOTPROVIDED' => nil,
+ 'NOTCHECKED' => 'X',
+ 'MATCHED' => 'Y',
+ 'NOTMATCHED' => 'N'
}
CVV_CODE = {
- "NOTPROVIDED" => 'S',
- "NOTCHECKED" => 'X',
- "MATCHED" => 'M',
- "NOTMATCHED" => 'N'
+ 'NOTPROVIDED' => 'S',
+ 'NOTCHECKED' => 'X',
+ 'MATCHED' => 'M',
+ 'NOTMATCHED' => 'N'
}
OPTIONAL_REQUEST_FIELDS = {
paypal_callback_url: :PayPalCallbackURL,
basket: :Basket,
@@ -325,11 +325,11 @@
def is_usa(country)
truncate(country, 2) == 'US'
end
def map_card_type(credit_card)
- raise ArgumentError, "The credit card type must be provided" if card_brand(credit_card).blank?
+ raise ArgumentError, 'The credit card type must be provided' if card_brand(credit_card).blank?
card_type = card_brand(credit_card).to_sym
if card_type == :visa && credit_card.electron?
CREDIT_CARDS[:electron]
@@ -340,40 +340,40 @@
# MMYY format
def format_date(month, year)
return nil if year.blank? || month.blank?
- year = sprintf("%.4i", year)
- month = sprintf("%.2i", month)
+ year = sprintf('%.4i', year)
+ month = sprintf('%.2i', month)
"#{month}#{year[-2..-1]}"
end
def commit(action, parameters)
response = parse( ssl_post(url_for(action), post_data(action, parameters)) )
- Response.new(response["Status"] == APPROVED, message_from(response), response,
+ Response.new(response['Status'] == APPROVED, message_from(response), response,
:test => test?,
:authorization => authorization_from(response, parameters, action),
:avs_result => {
- :street_match => AVS_CODE[ response["AddressResult"] ],
- :postal_match => AVS_CODE[ response["PostCodeResult"] ],
+ :street_match => AVS_CODE[ response['AddressResult'] ],
+ :postal_match => AVS_CODE[ response['PostCodeResult'] ],
},
- :cvv_result => CVV_CODE[ response["CV2Result"] ]
+ :cvv_result => CVV_CODE[ response['CV2Result'] ]
)
end
def authorization_from(response, params, action)
case action
when :store
response['Token']
else
[ params[:VendorTxCode],
- response["VPSTxId"] || params[:VPSTxId],
- response["TxAuthNo"],
- response["SecurityKey"] || params[:SecurityKey],
- action ].join(";")
+ response['VPSTxId'] || params[:VPSTxId],
+ response['TxAuthNo'],
+ response['SecurityKey'] || params[:SecurityKey],
+ action ].join(';')
end
end
def abort_or_void_from(identification)
original_transaction = identification.split(';').last
@@ -384,19 +384,19 @@
simulate ? build_simulator_url(action) : build_url(action)
end
def build_url(action)
endpoint = case action
- when :purchase, :authorization then "vspdirect-register"
+ when :purchase, :authorization then 'vspdirect-register'
when :store then 'directtoken'
else TRANSACTIONS[action].downcase
end
"#{test? ? self.test_url : self.live_url}/#{endpoint}.vsp"
end
def build_simulator_url(action)
- endpoint = [ :purchase, :authorization ].include?(action) ? "VSPDirectGateway.asp" : "VSPServerGateway.asp?Service=Vendor#{TRANSACTIONS[action].capitalize}Tx"
+ endpoint = [ :purchase, :authorization ].include?(action) ? 'VSPDirectGateway.asp' : "VSPServerGateway.asp?Service=Vendor#{TRANSACTIONS[action].capitalize}Tx"
"#{self.simulator_url}/#{endpoint}"
end
def message_from(response)
response['Status'] == APPROVED ? 'Success' : (response['StatusDetail'] || 'Unspecified error') # simonr 20080207 can't actually get non-nil blanks, so this is shorter
@@ -411,10 +411,10 @@
if(application_id && (application_id != Gateway.application_id))
parameters.update(:ReferrerID => application_id)
end
- parameters.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join("&")
+ parameters.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&')
end
# SagePay returns data in the following format
# Key1=value1
# Key2=value2