lib/active_merchant/billing/gateways/trans_first.rb in activemerchant-1.79.2 vs lib/active_merchant/billing/gateways/trans_first.rb in activemerchant-1.80.0
- old
+ new
@@ -13,23 +13,23 @@
UNUSED_CREDIT_CARD_FIELDS = %w(UserId TrackData MerchZIP MerchCustPNum MCC InstallmentNum InstallmentOf POSInd POSEntryMode POSConditionCode EComInd AuthCharInd CardCertData CAVVData)
DECLINED = 'The transaction was declined'
ACTIONS = {
- purchase: "CCSale",
- purchase_echeck: "ACHDebit",
- refund: "CreditCardCredit",
- refund_echeck: "ACHVoidTransaction",
- void: "CreditCardAutoRefundorVoid",
+ purchase: 'CCSale',
+ purchase_echeck: 'ACHDebit',
+ refund: 'CreditCardCredit',
+ refund_echeck: 'ACHVoidTransaction',
+ void: 'CreditCardAutoRefundorVoid',
}
ENDPOINTS = {
- purchase: "creditcard.asmx",
- purchase_echeck: "checkverifyws/checkverifyws.asmx",
- refund: "creditcard.asmx",
- refund_echeck: "checkverifyws/checkverifyws.asmx",
- void: "creditcard.asmx"
+ purchase: 'creditcard.asmx',
+ purchase_echeck: 'checkverifyws/checkverifyws.asmx',
+ refund: 'creditcard.asmx',
+ refund_echeck: 'checkverifyws/checkverifyws.asmx',
+ void: 'creditcard.asmx'
}
def initialize(options = {})
requires!(options, :login, :password)
super
@@ -53,11 +53,11 @@
transaction_id, payment_type = split_authorization(authorization)
add_amount(post, money)
add_pair(post, :TransID, transaction_id)
add_pair(post, :RefID, options[:order_id], required: true)
- commit((payment_type == "check" ? :refund_echeck : :refund), post)
+ commit((payment_type == 'check' ? :refund_echeck : :refund), post)
end
def void(authorization, options={})
post = {}
@@ -91,22 +91,22 @@
if address
add_pair(post, :Address, address[:address1], required: true)
add_pair(post, :ZipCode, address[:zip], required: true)
else
- add_pair(post, :Address, "", required: true)
- add_pair(post, :ZipCode, "", required: true)
+ add_pair(post, :Address, '', required: true)
+ add_pair(post, :ZipCode, '', required: true)
end
end
def add_invoice(post, options)
add_pair(post, :SECCCode, options[:invoice], required: true)
add_pair(post, :PONumber, options[:invoice], required: true)
add_pair(post, :SaleTaxAmount, amount(options[:tax] || 0))
add_pair(post, :TaxIndicator, 0)
- add_pair(post, :PaymentDesc, options[:description] || "", required: true)
- add_pair(post, :CompanyName, options[:company_name] || "", required: true)
+ add_pair(post, :PaymentDesc, options[:description] || '', required: true)
+ add_pair(post, :CompanyName, options[:company_name] || '', required: true)
end
def add_payment(post, payment)
if payment.is_a?(Check)
add_echeck(post, payment)
@@ -123,15 +123,15 @@
end
def add_echeck(post, payment)
add_pair(post, :TransRoute, payment.routing_number, required: true)
add_pair(post, :BankAccountNo, payment.account_number, required: true)
- add_pair(post, :BankAccountType, add_or_use_default(payment.account_type, "Checking"), required: true)
- add_pair(post, :CheckType, add_or_use_default(payment.account_holder_type, "Personal"), required: true)
+ add_pair(post, :BankAccountType, add_or_use_default(payment.account_type, 'Checking'), required: true)
+ add_pair(post, :CheckType, add_or_use_default(payment.account_holder_type, 'Personal'), required: true)
add_pair(post, :Name, payment.name, required: true)
- add_pair(post, :ProcessDate, Time.now.strftime("%m%d%y"), required: true)
- add_pair(post, :Description, "", required: true)
+ add_pair(post, :ProcessDate, Time.now.strftime('%m%d%y'), required: true)
+ add_pair(post, :Description, '', required: true)
end
def add_or_use_default(payment_data, default_value)
return payment_data.capitalize if payment_data
return default_value
@@ -139,11 +139,11 @@
def add_unused_fields(action, post)
return unless action == :purchase
UNUSED_CREDIT_CARD_FIELDS.each do |f|
- post[f] = ""
+ post[f] = ''
end
end
def expdate(credit_card)
year = format(credit_card.year, :two_digits)
@@ -154,11 +154,11 @@
def parse(data)
response = {}
xml = REXML::Document.new(data)
- root = REXML::XPath.first(xml, "*")
+ root = REXML::XPath.first(xml, '*')
if root.nil?
response[:message] = data.to_s.strip
else
root.elements.to_a.each do |node|
@@ -181,26 +181,26 @@
:cvv_result => response[:cvv2_code]
)
end
def authorization_from(response)
- if response[:status] == "APPROVED"
+ if response[:status] == 'APPROVED'
"#{response[:trans_id]}|check"
else
"#{response[:trans_id]}|creditcard"
end
end
def success_from(response)
case response[:status]
- when "Authorized"
+ when 'Authorized'
true
- when "Voided"
+ when 'Voided'
true
- when "APPROVED"
+ when 'APPROVED'
true
- when "VOIDED"
+ when 'VOIDED'
true
else
false
end
end
@@ -217,11 +217,11 @@
def post_data(action, params = {})
add_unused_fields(action, params)
params[:MerchantID] = @options[:login]
params[:RegKey] = @options[:password]
- request = params.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join("&")
+ request = params.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&')
request
end
def add_pair(post, key, value, options = {})
post[key] = value if !value.blank? || options[:required]
@@ -231,10 +231,10 @@
base_url = test? ? test_url : live_url
"#{base_url}/#{ENDPOINTS[action]}/#{ACTIONS[action]}"
end
def split_authorization(authorization)
- authorization.split("|")
+ authorization.split('|')
end
end
end
end