vaulted_billing-termcap 0.0.3 → 0.0.4
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.
|
@@ -2,6 +2,7 @@ require 'vaulted_billing'
|
|
|
2
2
|
require 'vaulted_billing/termcap/gateway'
|
|
3
3
|
require 'vaulted_billing/termcap/gateways/bogus'
|
|
4
4
|
require 'vaulted_billing/termcap/gateways/ipcommerce'
|
|
5
|
+
require 'vaulted_billing/termcap/transactions/ipcommerce'
|
|
5
6
|
|
|
6
7
|
module VaultedBilling
|
|
7
8
|
module Termcap
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
require 'vaulted_billing/gateways/ipcommerce'
|
|
2
|
+
require 'vaulted_billing/termcap/transactions/ipcommerce'
|
|
2
3
|
|
|
3
4
|
VaultedBilling::Gateways::Ipcommerce.class_eval do
|
|
4
|
-
|
|
5
5
|
##
|
|
6
6
|
# Captures the passed in transaction ids.
|
|
7
7
|
# Optionally specify difference amounts for each transaction.
|
|
@@ -17,7 +17,7 @@ VaultedBilling::Gateways::Ipcommerce.class_eval do
|
|
|
17
17
|
:DifferenceData => (differences || []).collect { |difference| capture_difference(difference) }
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
response = http(options[:workflow_id] || @service_id).put(data, { :on_success => :decode_with_termcap })
|
|
20
|
+
response = http("Txn", options[:workflow_id] || @service_id).put(data, { :on_success => :decode_with_termcap })
|
|
21
21
|
transaction = new_transaction_from_response(response)
|
|
22
22
|
respond_with(transaction,
|
|
23
23
|
response,
|
|
@@ -32,7 +32,7 @@ VaultedBilling::Gateways::Ipcommerce.class_eval do
|
|
|
32
32
|
:MerchantProfileId => options[:merchant_profile_id]
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
response = http(options[:workflow_id] || @service_id).put(data, { :on_success => :decode_with_termcap })
|
|
35
|
+
response = http("Txn", options[:workflow_id] || @service_id).put(data, { :on_success => :decode_with_termcap })
|
|
36
36
|
transaction = new_transaction_from_response(response)
|
|
37
37
|
respond_with(transaction,
|
|
38
38
|
response,
|
|
@@ -62,13 +62,94 @@ VaultedBilling::Gateways::Ipcommerce.class_eval do
|
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
response = http(options[:workflow_id] || @service_id).post(data)
|
|
65
|
+
response = http("Txn", options[:workflow_id] || @service_id).post(data)
|
|
66
66
|
transaction = new_transaction_from_response(response)
|
|
67
67
|
respond_with(transaction,
|
|
68
68
|
response,
|
|
69
69
|
:success => (transaction.code == 1))
|
|
70
70
|
end
|
|
71
71
|
|
|
72
|
+
def query_transaction_details(options={})
|
|
73
|
+
data = {
|
|
74
|
+
:"__type" => "QueryTransactionsDetail:http://schemas.ipcommerce.com/CWS/v2.0/DataServices/TMS/Rest",
|
|
75
|
+
:PagingParameters => paging_parameters(options[:page], options[:per_page]),
|
|
76
|
+
:IncludeRelated => options[:include_related] || 1,
|
|
77
|
+
:QueryTransactionsParameters => {
|
|
78
|
+
:"__type" => "QueryTransactionsParameters:http://schemas.ipcommerce.com/CWS/v2.0/DataServices/TMS",
|
|
79
|
+
:IsAcknowledged => options[:is_acknowledged] || 0,
|
|
80
|
+
:QueryType => options[:query_type] || 0,
|
|
81
|
+
:TransactionIds => options[:transaction_ids] || nil
|
|
82
|
+
}.merge(date_range("TransactionDateRange", options[:start_date], options[:end_date])),
|
|
83
|
+
:TransactionDetailFormat => 2
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if options[:end_date] && options[:start_date]
|
|
87
|
+
data[:QueryTransactionsParameters].merge!(date_range(ptions[:start_date], options[:end_date]))
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
response = http("DataServices", "TMS", "transactionsDetail").post(data, { :on_success => :decode_query_response } )
|
|
91
|
+
transactions = decode_query(response.body)
|
|
92
|
+
respond_with(transactions,
|
|
93
|
+
response,
|
|
94
|
+
:success => response.success?)
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def query_transactions_families(options={})
|
|
98
|
+
data = {
|
|
99
|
+
:"__type" => "QueryTransactionsFamilies:http://schemas.ipcommerce.com/CWS/v2.0/DataServices/TMS/Rest",
|
|
100
|
+
:PagingParameters => paging_parameters(options[:page], options[:per_page]),
|
|
101
|
+
:QueryTransactionsParameters => {
|
|
102
|
+
:"__type" => "QueryTransactionsParameters:http://schemas.ipcommerce.com/CWS/v2.0/DataServices/TMS",
|
|
103
|
+
:IsAcknowledged => options[:is_acknowledged] || 0,
|
|
104
|
+
:QueryType => options[:query_type] || 0,
|
|
105
|
+
:TransactionIds => options[:transaction_ids] || nil
|
|
106
|
+
}.merge(date_range("TransactionDateRange", options[:start_date], options[:end_date]))
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
response = http("DataServices", "TMS", "transactionsFamily").post(data, { :on_success => :decode_query_response } )
|
|
110
|
+
transactions = response.body
|
|
111
|
+
respond_with(transactions,
|
|
112
|
+
response,
|
|
113
|
+
:success => response.success?)
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
def query_batch(options={})
|
|
117
|
+
data = {
|
|
118
|
+
:"__type" => "QueryBatch:http://schemas.ipcommerce.com/CWS/v2.0/DataServices/TMS/Rest",
|
|
119
|
+
:PagingParameters => paging_parameters(options[:page], options[:per_page]),
|
|
120
|
+
:QueryBatchParameters => {
|
|
121
|
+
:"__type" => "QueryBatchParameters:http://schemas.ipcommerce.com/CWS/v2.0/DataServices/TMS",
|
|
122
|
+
:IsAcknowledged => options[:is_acknowledged] || 0,
|
|
123
|
+
:QueryType => options[:query_type] || 0
|
|
124
|
+
}.merge(date_range("BatchDateRange", options[:start_date], options[:end_date]))
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
response = http("DataServices", "TMS", "batch").post(data, { :on_success => :decode_query_response } )
|
|
128
|
+
transactions = response.body
|
|
129
|
+
respond_with(transactions,
|
|
130
|
+
response,
|
|
131
|
+
:success => response.success?)
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
def query_transactions_summary(options={})
|
|
135
|
+
data = {
|
|
136
|
+
:"__type" => "QueryTransactionsSummary:http://schemas.ipcommerce.com/CWS/v2.0/DataServices/TMS/Rest",
|
|
137
|
+
:PagingParameters => paging_parameters(options[:page], options[:per_page]),
|
|
138
|
+
:QueryTransactionsParameters => {
|
|
139
|
+
:"__type" => "QueryTransactionsParameters:http://schemas.ipcommerce.com/CWS/v2.0/DataServices/TMS",
|
|
140
|
+
:IsAcknowledged => options[:is_acknowledged] || 0,
|
|
141
|
+
:QueryType => options[:query_type] || 0,
|
|
142
|
+
:TransactionIds => options[:transaction_ids] || nil
|
|
143
|
+
}.merge(date_range("TransactionDateRange", options[:start_date], options[:end_date]))
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
response = http("DataServices", "TMS", "transactionsSummary").post(data, { :on_success => :decode_query_response } )
|
|
147
|
+
transactions = response.body
|
|
148
|
+
respond_with(transactions,
|
|
149
|
+
response,
|
|
150
|
+
:success => response.success?)
|
|
151
|
+
end
|
|
152
|
+
|
|
72
153
|
private
|
|
73
154
|
|
|
74
155
|
def decode_with_termcap(response)
|
|
@@ -77,6 +158,17 @@ VaultedBilling::Gateways::Ipcommerce.class_eval do
|
|
|
77
158
|
response.success = [1, 2].include?(response.body['Status'])
|
|
78
159
|
end
|
|
79
160
|
|
|
161
|
+
def decode_query_response(response)
|
|
162
|
+
response.body = decode_body(response.body) || {}
|
|
163
|
+
response.success = response.body.is_a?(Array)
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
def decode_query(transactions)
|
|
167
|
+
transactions.collect do |transaction|
|
|
168
|
+
VaultedBilling::Transactions::Ipcommerce.new(transaction)
|
|
169
|
+
end
|
|
170
|
+
end
|
|
171
|
+
|
|
80
172
|
def capture_difference(difference)
|
|
81
173
|
{
|
|
82
174
|
:"__type" => "BankcardCapture:http://schemas.ipcommerce.com/CWS/v2.0/Transactions/Bankcard",
|
|
@@ -85,4 +177,22 @@ VaultedBilling::Gateways::Ipcommerce.class_eval do
|
|
|
85
177
|
:Amount => "%.2f" % difference[:amount]
|
|
86
178
|
}
|
|
87
179
|
end
|
|
180
|
+
|
|
181
|
+
def date_range(key, start_date, end_date)
|
|
182
|
+
return {} unless start_date && end_date
|
|
183
|
+
{
|
|
184
|
+
"#{key}" => {
|
|
185
|
+
:EndDateTime => "Date(#{end_date.to_int*1000})",
|
|
186
|
+
:StartDateTime => "Date(#{start_date.to_int*1000})"
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
def paging_parameters(page, per_page)
|
|
192
|
+
{
|
|
193
|
+
:"__type" => "PagingParameters:http://schemas.ipcommerce.com/CWS/v2.0/DataServices",
|
|
194
|
+
:Page => page || 0,
|
|
195
|
+
:PageSize => per_page || 50
|
|
196
|
+
}
|
|
197
|
+
end
|
|
88
198
|
end
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
module VaultedBilling
|
|
2
|
+
module Transactions
|
|
3
|
+
class Ipcommerce < VaultedBilling::Transaction
|
|
4
|
+
CaptureStates = %w(
|
|
5
|
+
!! NotSet CannotCapture ReadyForCapture CapturePending Captured
|
|
6
|
+
CaptureDeclined InProcess CapturedUndoPermitted CapturePendingUndoPermitted CaptureError
|
|
7
|
+
CaptureUnknown BatchSent BatchSentUndoPermitted
|
|
8
|
+
).freeze
|
|
9
|
+
|
|
10
|
+
TransactionStates = %w(
|
|
11
|
+
!! NotSet Declined Verified Authorized Adjusted
|
|
12
|
+
Captured CaptureDeclined PartiallyCaptured Undone ReturnRequested
|
|
13
|
+
PartialReturnRequested ReturnUndone Returned PartiallyReturned InProcess
|
|
14
|
+
ErrorValidation ErrorUnknown ErrorConnecting
|
|
15
|
+
).freeze
|
|
16
|
+
|
|
17
|
+
attr_accessor :raw_result
|
|
18
|
+
attr_accessor :id
|
|
19
|
+
attr_accessor :amount
|
|
20
|
+
attr_accessor :approval_code
|
|
21
|
+
attr_accessor :captured_amount
|
|
22
|
+
attr_accessor :captured_state
|
|
23
|
+
attr_accessor :captured_state_id
|
|
24
|
+
attr_accessor :captured_status_message
|
|
25
|
+
attr_accessor :transaction_state_id
|
|
26
|
+
attr_accessor :transaction_state
|
|
27
|
+
attr_accessor :batch_id
|
|
28
|
+
|
|
29
|
+
def captured?
|
|
30
|
+
%w(Captured).include?(captured_state)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def capture_failed?
|
|
34
|
+
%w(CaptureDeclined CaptureError).include?(captured_state)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def capture_pending?
|
|
38
|
+
%w(BatchSent InProcess).include?(captured_state)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def failed?
|
|
42
|
+
%w(Declined CaptureDeclined ErrorValidation ErrorUnknown).include?(transaction_state)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def initialize(input)
|
|
46
|
+
self.raw_result = input.to_s
|
|
47
|
+
self.id = input['TransactionInformation']['TransactionId']
|
|
48
|
+
self.amount = input['TransactionInformation']['Amount']
|
|
49
|
+
self.approval_code = input['TransactionInformation']['ApprovalCode']
|
|
50
|
+
self.captured_amount = input['TransactionInformation']['CapturedAmount']
|
|
51
|
+
self.captured_state = CaptureStates[input['TransactionInformation']['CaptureState']]
|
|
52
|
+
self.captured_state_id = input['TransactionInformation']['CaptureState']
|
|
53
|
+
self.captured_status_message = input['TransactionInformation']['CaptureStatusMessage']
|
|
54
|
+
self.transaction_state_id = input['TransactionInformation']['TransactionState']
|
|
55
|
+
self.transaction_state =TransactionStates[input['TransactionInformation']['TransactionState']]
|
|
56
|
+
self.batch_id = input['TransactionInformation']['BatchId']
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
metadata
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
name: vaulted_billing-termcap
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease:
|
|
5
|
-
version: 0.0.
|
|
5
|
+
version: 0.0.4
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
8
8
|
- Adam Fortuna
|
|
@@ -10,7 +10,7 @@ autorequire:
|
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
12
|
|
|
13
|
-
date: 2011-08-
|
|
13
|
+
date: 2011-08-31 00:00:00 -04:00
|
|
14
14
|
default_executable:
|
|
15
15
|
dependencies:
|
|
16
16
|
- !ruby/object:Gem::Dependency
|
|
@@ -21,7 +21,7 @@ dependencies:
|
|
|
21
21
|
requirements:
|
|
22
22
|
- - ~>
|
|
23
23
|
- !ruby/object:Gem::Version
|
|
24
|
-
version: 1.1.
|
|
24
|
+
version: 1.1.3
|
|
25
25
|
type: :runtime
|
|
26
26
|
version_requirements: *id001
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
@@ -125,6 +125,7 @@ files:
|
|
|
125
125
|
- lib/vaulted_billing/termcap/gateway.rb
|
|
126
126
|
- lib/vaulted_billing/termcap/gateways/bogus.rb
|
|
127
127
|
- lib/vaulted_billing/termcap/gateways/ipcommerce.rb
|
|
128
|
+
- lib/vaulted_billing/termcap/transactions/ipcommerce.rb
|
|
128
129
|
- lib/vaulted_billing/termcap/version.rb
|
|
129
130
|
- lib/vaulted_billing/termcap.rb
|
|
130
131
|
- lib/vaulted_billing-termcap.rb
|