lib/active_merchant/billing/gateways/merchant_partners.rb in activemerchant-1.79.2 vs lib/active_merchant/billing/gateways/merchant_partners.rb in activemerchant-1.80.0
- old
+ new
@@ -1,17 +1,17 @@
require 'nokogiri'
module ActiveMerchant #:nodoc:
module Billing #:nodoc:
class MerchantPartnersGateway < Gateway
- self.display_name = "Merchant Partners"
- self.homepage_url = "http://www.merchantpartners.com/"
+ self.display_name = 'Merchant Partners'
+ self.homepage_url = 'http://www.merchantpartners.com/'
- self.live_url = "https://trans.merchantpartners.com/cgi-bin/ProcessXML.cgi"
+ self.live_url = 'https://trans.merchantpartners.com/cgi-bin/ProcessXML.cgi'
- self.supported_countries = ["US"]
- self.default_currency = "USD"
+ self.supported_countries = ['US']
+ self.default_currency = 'USD'
self.money_format = :dollars
self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club, :jcb]
def initialize(options={})
requires!(options, :account_id, :merchant_pin)
@@ -141,23 +141,23 @@
def add_reference(post, authorization)
post[:historykeyid] = authorization
end
ACTIONS = {
- purchase: "2",
- authorize: "1",
- capture: "3",
- void: "5",
- refund: "4",
- credit: "6",
- store: "7",
- stored_purchase: "8",
- stored_credit: "13"
+ purchase: '2',
+ authorize: '1',
+ capture: '3',
+ void: '5',
+ refund: '4',
+ credit: '6',
+ store: '7',
+ stored_purchase: '8',
+ stored_credit: '13'
}
STORE_TX_TYPES = {
- store_only: "3"
+ store_only: '3'
}
def commit(action, post)
post[:acctid] = @options[:account_id]
post[:merchantpin] = @options[:merchant_pin]
@@ -170,27 +170,27 @@
Response.new(
succeeded,
message_from(succeeded, response_data),
response_data,
authorization: authorization_from(post, response_data),
- :avs_result => AVSResult.new(code: response_data["avs_response"]),
- :cvv_result => CVVResult.new(response_data["cvv2_response"]),
+ :avs_result => AVSResult.new(code: response_data['avs_response']),
+ :cvv_result => CVVResult.new(response_data['cvv2_response']),
test: test?
)
end
def headers
{
- "Content-Type" => "application/xml"
+ 'Content-Type' => 'application/xml'
}
end
def build_request(post)
Nokogiri::XML::Builder.new(:encoding => 'utf-8') do |xml|
xml.interface_driver {
xml.trans_catalog {
- xml.transaction(name: "creditcard") {
+ xml.transaction(name: 'creditcard') {
xml.inputs {
post.each do |field, value|
xml.send(field, value)
end
}
@@ -200,11 +200,11 @@
end.to_xml
end
def parse(body)
response = {}
- Nokogiri::XML(CGI.unescapeHTML(body)).xpath("//trans_catalog/transaction/outputs").children.each do |node|
+ Nokogiri::XML(CGI.unescapeHTML(body)).xpath('//trans_catalog/transaction/outputs').children.each do |node|
parse_element(response, node)
end
response
end
@@ -215,28 +215,28 @@
node.elements.each{|element| parse_element(response, element) }
end
end
def success_from(response)
- response[:status] == "Approved"
+ response[:status] == 'Approved'
end
def message_from(succeeded, response)
- succeeded ? "Succeeded" : error_message_from(response)
+ succeeded ? 'Succeeded' : error_message_from(response)
end
def authorization_from(request, response)
request[:service] == ACTIONS[:store] ?
"#{response[:userprofileid]}|#{response[:last4digits]}" :
response[:historyid]
end
def split_authorization(authorization)
- authorization.split("|")
+ authorization.split('|')
end
def error_message_from(response)
- if(response[:status] == "Declined")
+ if(response[:status] == 'Declined')
match = response[:result].match(/DECLINED:\d{10}:(.+):/)
match[1] if match
end
end
end