johnideal-activemerchant 1.4.4 → 1.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.4.
|
1
|
+
1.4.5
|
data/activemerchant.gemspec
CHANGED
@@ -1,72 +1,83 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
cattr_accessor :elements
|
1
|
+
class PaymentechOrbitalResponse
|
2
|
+
cattr_accessor :elements
|
3
|
+
attr_reader :doc, :request_type
|
5
4
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
5
|
+
self.elements = [
|
6
|
+
:industry_type, :message_type, :merchant_id,
|
7
|
+
:terminal_id, :card_brand, :account_num,
|
8
|
+
:order_id, :tx_ref_num, :tx_ref_idx, :proc_status,
|
9
|
+
:approval_status, :resp_code, :avs_resp_code,
|
10
|
+
:cvv2_resp_code, :auth_code, :status_msg, :resp_msg,
|
11
|
+
:customer_ref_num, :customer_name, :profile_proc_status,
|
12
|
+
:customer_profile_message, :resp_time, :batch_seq_num
|
13
|
+
]
|
15
14
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
15
|
+
def initialize(doc, request_type, options={})
|
16
|
+
@doc = REXML::Document.new(doc)
|
17
|
+
@request_type = request_type
|
18
|
+
@options = options
|
19
|
+
end
|
20
|
+
|
21
|
+
def success?
|
22
|
+
case request_type
|
23
|
+
when "NewOrder"
|
24
|
+
proc_success? && approved?
|
25
|
+
when "Profile"
|
26
|
+
profile_proc_success?
|
27
|
+
when "Reversal", "EndOfDay"
|
28
|
+
proc_success?
|
29
|
+
else
|
30
|
+
false
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def proc_success?
|
35
|
+
proc_status == "0"
|
36
|
+
end
|
37
|
+
|
38
|
+
def profile_proc_success?
|
39
|
+
profile_proc_status == "0"
|
40
|
+
end
|
20
41
|
|
21
|
-
|
22
|
-
|
23
|
-
|
42
|
+
def approved?
|
43
|
+
approval_status == "1"
|
44
|
+
end
|
24
45
|
|
25
|
-
|
26
|
-
|
27
|
-
|
46
|
+
def authorization
|
47
|
+
approval_status
|
48
|
+
end
|
28
49
|
|
29
|
-
|
30
|
-
|
31
|
-
|
50
|
+
def test?
|
51
|
+
@options[:test] || false
|
52
|
+
end
|
32
53
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
def test?
|
38
|
-
@options[:test] || false
|
39
|
-
end
|
54
|
+
def avs_result
|
55
|
+
@avs_result ||= AVSResult.new({:code => avs_resp_code})
|
56
|
+
end
|
40
57
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
def cvv_result
|
46
|
-
@cvv_result ||= CVVResult.new({:code => cvv2_result_code})
|
47
|
-
end
|
58
|
+
def cvv_result
|
59
|
+
@cvv_result ||= CVVResult.new({:code => cvv2_result_code})
|
60
|
+
end
|
48
61
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
62
|
+
private
|
63
|
+
def tagify(s)
|
64
|
+
s.to_s.gsub(/\/(.?)/) {
|
65
|
+
"::#{$1.upcase}"
|
66
|
+
}.gsub(/(?:^|_)(.)/) {
|
67
|
+
$1.upcase
|
68
|
+
}
|
69
|
+
end
|
57
70
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
71
|
+
def value_at(sym)
|
72
|
+
node = REXML::XPath.first(@doc, "//#{tagify(sym)}")
|
73
|
+
node ? node.text : nil
|
74
|
+
end
|
62
75
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
end
|
69
|
-
end
|
76
|
+
def method_missing(sym, *args, &blk)
|
77
|
+
if self.class.elements.include?(sym)
|
78
|
+
value_at(sym)
|
79
|
+
else
|
80
|
+
super(sym, *args, &blk)
|
70
81
|
end
|
71
82
|
end
|
72
83
|
end
|
@@ -1,10 +1,18 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/paymentech_orbital/paymentech_orbital_request'
|
2
|
+
|
3
|
+
require File.dirname(__FILE__) + '/paymentech_orbital/end_of_day_request'
|
4
|
+
require File.dirname(__FILE__) + '/paymentech_orbital/new_order_request'
|
5
|
+
require File.dirname(__FILE__) + '/paymentech_orbital/profile_management_request'
|
6
|
+
require File.dirname(__FILE__) + '/paymentech_orbital/void_request'
|
7
|
+
|
1
8
|
require File.dirname(__FILE__) + '/paymentech_orbital/paymentech_orbital_response'
|
2
9
|
|
3
10
|
module ActiveMerchant #:nodoc:
|
4
11
|
module Billing #:nodoc:
|
5
12
|
class PaymentechOrbitalGateway < Gateway
|
6
13
|
cattr_accessor :enable_profile_management, :urls,
|
7
|
-
:currency_code, :currency_exponent
|
14
|
+
:currency_code, :currency_exponent,
|
15
|
+
:headers
|
8
16
|
|
9
17
|
self.urls = {
|
10
18
|
:test => [
|
@@ -39,128 +47,77 @@ module ActiveMerchant #:nodoc:
|
|
39
47
|
# Enable profile management?
|
40
48
|
self.enable_profile_management = true
|
41
49
|
|
50
|
+
# Headers
|
51
|
+
self.headers = {
|
52
|
+
"MIME-Version" => "1.0",
|
53
|
+
"Content-Type" => "Application/PTI46",
|
54
|
+
"Content-transfer-encoding" => "text",
|
55
|
+
"Request-number" => "1",
|
56
|
+
"Document-type" => "Request"
|
57
|
+
}
|
58
|
+
|
42
59
|
def initialize(options = {})
|
43
60
|
requires!(options, :login, :password, :merchant_id, :bin, :terminal_id)
|
44
|
-
@options = options
|
61
|
+
@options = options.merge({
|
62
|
+
:currency_code => self.class.currency_code,
|
63
|
+
:currency_exponent => self.class.currency_exponent
|
64
|
+
})
|
45
65
|
super
|
46
66
|
end
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
define_method(:"#{attr}") do
|
51
|
-
@options[:"#{attr}"]
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
def authorize(money, creditcard, options = {})
|
56
|
-
request = build_request("NewOrder", money, options) do |xml|
|
57
|
-
add_credentials(xml, "A")
|
58
|
-
add_credit_card(xml, credit_card)
|
59
|
-
add_billing_address(xml, options[:billing_address]) if options[:billing_address]
|
60
|
-
add_profile_management(xml, options[:customer_ref_num]) if enable_profile_management?
|
61
|
-
end
|
67
|
+
|
68
|
+
def authorize(money, credit_card=nil, options = {})
|
69
|
+
request = NewOrderRequest.new("A", money, credit_card, options.merge(@options))
|
62
70
|
|
63
71
|
commit('authonly', request)
|
64
72
|
end
|
65
73
|
|
66
74
|
def purchase(money, credit_card=nil, options = {})
|
67
|
-
request =
|
68
|
-
add_credentials(xml, "AC")
|
69
|
-
add_credit_card(xml, credit_card)
|
70
|
-
add_billing_address(xml, options[:billing_address]) if options[:billing_address]
|
71
|
-
add_profile_management(xml, options[:customer_ref_num]) if enable_profile_management?
|
72
|
-
end
|
75
|
+
request = NewOrderRequest.new("AC", money, credit_card, options.merge(@options))
|
73
76
|
|
74
77
|
commit('sale', request)
|
75
78
|
end
|
79
|
+
|
80
|
+
def refund(money, credit_card=nil, options={})
|
81
|
+
request = NewOrderRequest.new("R", money, credit_card, options.merge(@options))
|
76
82
|
|
77
|
-
|
78
|
-
commit('capture', money, post)
|
83
|
+
commit('refund', request)
|
79
84
|
end
|
80
85
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
xml.instruct!(:xml, :version => '1.0', :encoding => 'UTF-8')
|
86
|
-
xml.tag! "Request" do
|
87
|
-
xml.tag! request_type do
|
88
|
-
yield xml if block_given?
|
89
|
-
|
90
|
-
xml.tag! "OrderID", options[:order_id]
|
91
|
-
xml.tag! "Amount", money
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
xml.target!
|
96
|
-
end
|
97
|
-
|
98
|
-
def add_credentials(xml, message_type)
|
99
|
-
xml.tag! "OrbitalConnectionUsername", login
|
100
|
-
xml.tag! "OrbitalConnectionPassword", password
|
101
|
-
xml.tag! "IndustryType", "EC"
|
102
|
-
xml.tag! "MessageType", message_type
|
103
|
-
xml.tag! "BIN", bin
|
104
|
-
xml.tag! "MerchantID", merchant_id
|
105
|
-
xml.tag! "TerminalID", terminal_id
|
106
|
-
end
|
107
|
-
|
108
|
-
def add_credit_card(xml, credit_card=nil)
|
109
|
-
if credit_card
|
110
|
-
xml.tag! "CardBrand", card_brand(credit_card)
|
111
|
-
xml.tag! "AccountNum", credit_card.number
|
112
|
-
xml.tag! "Exp", "#{credit_card.month}#{credit_card.year}"
|
113
|
-
add_currency(xml)
|
114
|
-
xml.tag! "CardSecVal", credit_card.verification_value
|
115
|
-
else
|
116
|
-
xml.tag! "AccountNum", nil
|
117
|
-
add_currency(xml)
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
def add_currency(xml)
|
122
|
-
xml.tag! "CurrencyCode", self.class.currency_code
|
123
|
-
xml.tag! "CurrencyExponent", self.class.currency_exponent
|
86
|
+
def profile(action, credit_card=nil, options={})
|
87
|
+
request = ProfileManagementRequest.new(action, credit_card, options.merge(@options))
|
88
|
+
|
89
|
+
commit("profile-#{action}", request)
|
124
90
|
end
|
125
91
|
|
126
|
-
def
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
xml.tag! "AVScity", address[:city]
|
131
|
-
xml.tag! "AVSstate", address[:state]
|
132
|
-
xml.tag! "AVSphoneNum" , address[:phone]
|
133
|
-
xml.tag! "AVSname", address[:name]
|
134
|
-
xml.tag! "AVScountryCode", address[:country]
|
92
|
+
def void(tx_ref_num, tx_ref_idx, money=nil, options={})
|
93
|
+
request = VoidRequest.new(tx_ref_num, tx_ref_idx, money, options.merge(@options))
|
94
|
+
|
95
|
+
commit('void', request)
|
135
96
|
end
|
136
|
-
|
137
|
-
def
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
xml.tag! "CustomerProfileFromOrderInd", "A"
|
142
|
-
xml.tag! "CustomerProfileOrderOverrideInd", "NO"
|
143
|
-
end
|
97
|
+
|
98
|
+
def end_of_day(options={})
|
99
|
+
request = EndOfDayRequest.new(options.merge(@options))
|
100
|
+
|
101
|
+
commit('end of day', request)
|
144
102
|
end
|
145
|
-
|
103
|
+
|
104
|
+
private
|
146
105
|
def commit(action, request)
|
147
|
-
resp = ssl_post(endpoint_url, request,
|
148
|
-
"MIME-Version" => "1.0",
|
149
|
-
"Content-Type" => "Application/PTI46",
|
150
|
-
"Content-transfer-encoding" => "text",
|
151
|
-
"Request-number" => "1",
|
152
|
-
"Document-type" => "Request"
|
153
|
-
})
|
106
|
+
resp = ssl_post(endpoint_url, request.to_xml, headers)
|
154
107
|
|
155
|
-
@response ||= PaymentechOrbitalResponse.new(resp, {
|
108
|
+
@response ||= PaymentechOrbitalResponse.new(resp, request.request_type, {
|
156
109
|
:test => test?
|
157
110
|
})
|
158
111
|
end
|
159
|
-
|
112
|
+
|
113
|
+
def headers
|
114
|
+
self.class.headers
|
115
|
+
end
|
116
|
+
|
160
117
|
def endpoint_url
|
161
118
|
self.class.urls[Base.gateway_mode][0]
|
162
119
|
end
|
163
|
-
|
120
|
+
|
164
121
|
def enable_profile_management?
|
165
122
|
self.class.enable_profile_management
|
166
123
|
end
|
@@ -64,7 +64,6 @@ module ActiveMerchant
|
|
64
64
|
http.get(endpoint.request_uri, headers)
|
65
65
|
when :post
|
66
66
|
debug body
|
67
|
-
puts RUBY_184_POST_HEADERS.merge(headers).inspect
|
68
67
|
http.post(endpoint.request_uri, body, RUBY_184_POST_HEADERS.merge(headers))
|
69
68
|
else
|
70
69
|
raise ArgumentError, "Unsupported request method #{method.to_s.upcase}"
|