lib/active_merchant/billing/gateways/blue_snap.rb in activemerchant-1.79.2 vs lib/active_merchant/billing/gateways/blue_snap.rb in activemerchant-1.80.0
- old
+ new
@@ -1,26 +1,26 @@
require 'nokogiri'
module ActiveMerchant
module Billing
class BlueSnapGateway < Gateway
- self.test_url = "https://sandbox.bluesnap.com/services/2"
- self.live_url = "https://ws.bluesnap.com/services/2"
+ self.test_url = 'https://sandbox.bluesnap.com/services/2'
+ self.live_url = 'https://ws.bluesnap.com/services/2'
self.supported_countries = %w(US CA GB AT BE BG HR CY CZ DK EE FI FR DE GR HU IE IT LV LT LU MT NL PL PT RO SK SI ES SE)
self.default_currency = 'USD'
self.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb, :diners_club, :maestro]
self.homepage_url = 'https://home.bluesnap.com/'
self.display_name = 'BlueSnap'
TRANSACTIONS = {
- purchase: "AUTH_CAPTURE",
- authorize: "AUTH_ONLY",
- capture: "CAPTURE",
- void: "AUTH_REVERSAL",
- refund: "REFUND"
+ purchase: 'AUTH_CAPTURE',
+ authorize: 'AUTH_ONLY',
+ capture: 'CAPTURE',
+ void: 'AUTH_REVERSAL',
+ refund: 'REFUND'
}
CVC_CODE_TRANSLATOR = {
'MA' => 'M',
'NC' => 'U',
@@ -103,12 +103,12 @@
end
def store(credit_card, options = {})
commit(:store) do |doc|
add_personal_info(doc, credit_card, options)
- doc.send("payment-sources") do
- doc.send("credit-card-info") do
+ doc.send('payment-sources') do
+ doc.send('credit-card-info') do
add_credit_card(doc, credit_card)
end
end
add_order(doc, options)
end
@@ -136,21 +136,21 @@
end
private
def add_auth_purchase(doc, money, payment_method, options)
- doc.send("recurring-transaction", options[:recurring] ? "RECURRING" : "ECOMMERCE")
+ doc.send('recurring-transaction', options[:recurring] ? 'RECURRING' : 'ECOMMERCE')
add_order(doc, options)
add_amount(doc, money, options)
- doc.send("transaction-fraud-info") do
- doc.send("shopper-ip-address", options[:ip]) if options[:ip]
+ doc.send('transaction-fraud-info') do
+ doc.send('shopper-ip-address', options[:ip]) if options[:ip]
end
if payment_method.is_a?(String)
- doc.send("vaulted-shopper-id", payment_method)
+ doc.send('vaulted-shopper-id', payment_method)
else
- doc.send("card-holder-info") do
+ doc.send('card-holder-info') do
add_personal_info(doc, payment_method, options)
end
add_credit_card(doc, payment_method)
end
end
@@ -159,38 +159,38 @@
doc.amount(amount(money))
doc.currency(options[:currency] || currency(money))
end
def add_personal_info(doc, credit_card, options)
- doc.send("first-name", credit_card.first_name)
- doc.send("last-name", credit_card.last_name)
+ doc.send('first-name', credit_card.first_name)
+ doc.send('last-name', credit_card.last_name)
doc.email(options[:email]) if options[:email]
add_address(doc, options)
end
def add_credit_card(doc, card)
- doc.send("credit-card") do
- doc.send("card-number", card.number)
- doc.send("security-code", card.verification_value)
- doc.send("expiration-month", card.month)
- doc.send("expiration-year", card.year)
+ doc.send('credit-card') do
+ doc.send('card-number', card.number)
+ doc.send('security-code', card.verification_value)
+ doc.send('expiration-month', card.month)
+ doc.send('expiration-year', card.year)
end
end
def add_description(doc, description)
- doc.send("transaction-meta-data") do
- doc.send("meta-data") do
- doc.send("meta-key", "description")
- doc.send("meta-value", truncate(description, 500))
- doc.send("meta-description", "Description")
+ doc.send('transaction-meta-data') do
+ doc.send('meta-data') do
+ doc.send('meta-key', 'description')
+ doc.send('meta-value', truncate(description, 500))
+ doc.send('meta-description', 'Description')
end
end
end
def add_order(doc, options)
- doc.send("merchant-transaction-id", truncate(options[:order_id], 50)) if options[:order_id]
- doc.send("soft-descriptor", options[:soft_descriptor]) if options[:soft_descriptor]
+ doc.send('merchant-transaction-id', truncate(options[:order_id], 50)) if options[:order_id]
+ doc.send('soft-descriptor', options[:soft_descriptor]) if options[:soft_descriptor]
add_description(doc, options[:description]) if options[:description]
end
def add_address(doc, options)
address = options[:billing_address]
@@ -202,11 +202,11 @@
doc.city(address[:city]) if address[:city]
doc.zip(address[:zip]) if address[:zip]
end
def add_authorization(doc, authorization)
- doc.send("transaction-id", authorization)
+ doc.send('transaction-id', authorization)
end
def parse(response)
return bad_authentication_response if response.code.to_i == 401
@@ -220,11 +220,11 @@
parse_element(parsed, childnode)
end
end
end
- parsed["content-location-header"] = response['content-location']
+ parsed['content-location-header'] = response['content-location']
parsed
end
def parse_element(parsed, node)
if !node.elements.empty?
@@ -260,16 +260,16 @@
)
end
def url(action = nil)
base = test? ? test_url : live_url
- resource = (action == :store) ? "vaulted-shoppers" : "transactions"
+ resource = (action == :store) ? 'vaulted-shoppers' : 'transactions'
"#{base}/#{resource}"
end
def cvv_result(parsed)
- CVVResult.new(CVC_CODE_TRANSLATOR[parsed["cvv-response-code"]])
+ CVVResult.new(CVC_CODE_TRANSLATOR[parsed['cvv-response-code']])
end
def avs_result(parsed)
AVSResult.new(code: AVS_CODE_TRANSLATOR[avs_lookup_key(parsed)])
end
@@ -281,35 +281,35 @@
def success_from(action, response)
(200...300).include?(response.code.to_i)
end
def message_from(succeeded, parsed_response)
- return "Success" if succeeded
- parsed_response["description"]
+ return 'Success' if succeeded
+ parsed_response['description']
end
def authorization_from(action, parsed_response)
- (action == :store) ? vaulted_shopper_id(parsed_response) : parsed_response["transaction-id"]
+ (action == :store) ? vaulted_shopper_id(parsed_response) : parsed_response['transaction-id']
end
def vaulted_shopper_id(parsed_response)
- return nil unless parsed_response["content-location-header"]
- parsed_response["content-location-header"].split("/").last
+ return nil unless parsed_response['content-location-header']
+ parsed_response['content-location-header'].split('/').last
end
def error_code_from(parsed_response)
- parsed_response["code"]
+ parsed_response['code']
end
def root_attributes
{
- xmlns: "http://ws.plimus.com"
+ xmlns: 'http://ws.plimus.com'
}
end
def root_element(action)
- (action == :store) ? "vaulted-shopper" : "card-transaction"
+ (action == :store) ? 'vaulted-shopper' : 'card-transaction'
end
def headers
{
'Content-Type' => 'application/xml',
@@ -318,11 +318,11 @@
end
def build_xml_request(action)
builder = Nokogiri::XML::Builder.new
builder.__send__(root_element(action), root_attributes) do |doc|
- doc.send("card-transaction-type", TRANSACTIONS[action]) if TRANSACTIONS[action]
+ doc.send('card-transaction-type', TRANSACTIONS[action]) if TRANSACTIONS[action]
yield(doc)
end
builder.doc.root.to_xml
end
@@ -334,10 +334,10 @@
raise ResponseError.new(response)
end
end
def bad_authentication_response
- { "description" => "Unable to authenticate. Please check your credentials." }
+ { 'description' => 'Unable to authenticate. Please check your credentials.' }
end
end
end
end