lib/active_merchant/billing/gateways/safe_charge.rb in activemerchant-1.79.2 vs lib/active_merchant/billing/gateways/safe_charge.rb in activemerchant-1.80.0
- old
+ new
@@ -21,31 +21,31 @@
end
def purchase(money, payment, options={})
post = {}
post[:sg_APIType] = 1 if options[:three_d_secure]
- trans_type = options[:three_d_secure] ? "Sale3D" : "Sale"
+ trans_type = options[:three_d_secure] ? 'Sale3D' : 'Sale'
add_transaction_data(trans_type, post, money, options)
add_payment(post, payment, options)
add_customer_details(post, payment, options)
commit(post)
end
def authorize(money, payment, options={})
post = {}
- add_transaction_data("Auth", post, money, options)
+ add_transaction_data('Auth', post, money, options)
add_payment(post, payment, options)
add_customer_details(post, payment, options)
commit(post)
end
def capture(money, authorization, options={})
post = {}
- auth, transaction_id, token, exp_month, exp_year, _, original_currency = authorization.split("|")
- add_transaction_data("Settle", post, money, (options.merge!({currency: original_currency})))
+ auth, transaction_id, token, exp_month, exp_year, _, original_currency = authorization.split('|')
+ add_transaction_data('Settle', post, money, (options.merge!({currency: original_currency})))
post[:sg_AuthCode] = auth
post[:sg_TransactionID] = transaction_id
post[:sg_CCToken] = token
post[:sg_ExpMonth] = exp_month
post[:sg_ExpYear] = exp_year
@@ -53,12 +53,12 @@
commit(post)
end
def refund(money, authorization, options={})
post = {}
- auth, transaction_id, token, exp_month, exp_year, _, original_currency = authorization.split("|")
- add_transaction_data("Credit", post, money, (options.merge!({currency: original_currency})))
+ auth, transaction_id, token, exp_month, exp_year, _, original_currency = authorization.split('|')
+ add_transaction_data('Credit', post, money, (options.merge!({currency: original_currency})))
post[:sg_CreditType] = 2
post[:sg_AuthCode] = auth
post[:sg_TransactionID] = transaction_id
post[:sg_CCToken] = token
post[:sg_ExpMonth] = exp_month
@@ -68,20 +68,20 @@
end
def credit(money, payment, options={})
post = {}
add_payment(post, payment, options)
- add_transaction_data("Credit", post, money, options)
+ add_transaction_data('Credit', post, money, options)
post[:sg_CreditType] = 1
commit(post)
end
def void(authorization, options={})
post = {}
- auth, transaction_id, token, exp_month, exp_year, original_amount, original_currency = authorization.split("|")
- add_transaction_data("Void", post, (original_amount.to_f * 100), (options.merge!({currency: original_currency})))
+ auth, transaction_id, token, exp_month, exp_year, original_amount, original_currency = authorization.split('|')
+ add_transaction_data('Void', post, (original_amount.to_f * 100), (options.merge!({currency: original_currency})))
post[:sg_CreditType] = 2
post[:sg_AuthCode] = auth
post[:sg_TransactionID] = transaction_id
post[:sg_CCToken] = token
post[:sg_ExpMonth] = exp_month
@@ -114,11 +114,11 @@
post[:sg_TransType] = trans_type
post[:sg_Currency] = (options[:currency] || currency(money))
post[:sg_Amount] = amount(money)
post[:sg_ClientLoginID] = @options[:client_login_id]
post[:sg_ClientPassword] = @options[:client_password]
- post[:sg_ResponseFormat] = "4"
+ post[:sg_ResponseFormat] = '4'
post[:sg_Version] = VERSION
post[:sg_ClientUniqueID] = options[:order_id] if options[:order_id]
post[:sg_UserID] = options[:user_id] if options[:user_id]
post[:sg_AuthType] = options[:auth_type] if options[:auth_type]
post[:sg_ExpectedFulfillmentCount] = options[:expected_fulfillment_count] if options[:expected_fulfillment_count]
@@ -200,15 +200,15 @@
error_code: error_code_from(response)
)
end
def success_from(response)
- response[:status] == "APPROVED"
+ response[:status] == 'APPROVED'
end
def message_from(response)
- return "Success" if success_from(response)
+ return 'Success' if success_from(response)
response[:reason_codes] || response[:reason]
end
def authorization_from(response, parameters)
[
@@ -217,15 +217,15 @@
response[:token],
parameters[:sg_ExpMonth],
parameters[:sg_ExpYear],
parameters[:sg_Amount],
parameters[:sg_Currency]
- ].join("|")
+ ].join('|')
end
def split_authorization(authorization)
- auth_code, transaction_id, token, month, year, original_amount = authorization.split("|")
+ auth_code, transaction_id, token, month, year, original_amount = authorization.split('|')
{
auth_code: auth_code,
transaction_id: transaction_id,
token: token,
@@ -239,11 +239,11 @@
return nil unless params
params.map do |key, value|
next if value != false && value.blank?
"#{key}=#{CGI.escape(value.to_s)}"
- end.compact.join("&")
+ end.compact.join('&')
end
def error_code_from(response)
unless success_from(response)
response[:ex_err_code] || response[:err_code]
@@ -252,10 +252,10 @@
def underscore(camel_cased_word)
camel_cased_word.to_s.gsub(/::/, '/').
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
gsub(/([a-z\d])([A-Z])/,'\1_\2').
- tr("-", "_").
+ tr('-', '_').
downcase
end
end
end
end