midas_client 0.1.4.1 → 0.2.1
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.
- checksums.yaml +4 -4
- data/README.md +18 -1
- data/lib/midas_client/billet.rb +7 -0
- data/lib/midas_client/endpoints.rb +12 -17
- data/lib/midas_client/management.rb +7 -11
- data/lib/midas_client/query.rb +30 -5
- data/lib/midas_client/request.rb +4 -2
- data/lib/midas_client/subscription.rb +21 -39
- data/lib/midas_client/transaction.rb +69 -51
- data/lib/midas_client/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 949740b14437d4db4de04a152052379dc0c4a779
|
4
|
+
data.tar.gz: 27271aba5cbcef7c04ba2ae89252f2361a91c89b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 90935d84f635edefd4e8e65e6df770c7be8ee73d1fe4d457fb5881ad32afd11a6247132d49f920f53c455a53911f33fe6dc880da863b3e169dcb64ac58c41080
|
7
|
+
data.tar.gz: edfe960092329e9cb0ee4dc761ac57c31000c7a718560b9eddbebcfc2964a397b9d0d4a9a78a327350afc7729d98b02bc097a6491ab3c57ecca539f8abc42dfe
|
data/README.md
CHANGED
@@ -42,11 +42,28 @@ Response
|
|
42
42
|
$ [17/05/2017 20:48:06.103][RESPONSE] {:result=>{:success=>true, :code=>"010", :message=>"O cartao jah foi armazenado anteriormente"}, :brand=>"MASTER", :cardToken=>"f887d732863eb3ef2e45c0bd8b57ed33"}
|
43
43
|
|
44
44
|
## Change Releases
|
45
|
+
VERSION - 0.2.0 - 2017/10/11
|
46
|
+
|
47
|
+
- Changing Development API endpoint
|
48
|
+
- read.me
|
49
|
+
|
50
|
+
VERSION - 0.2.0 - 2017/08/26
|
51
|
+
|
52
|
+
- Bugfix for queries
|
53
|
+
- Changing returns from Array to Hash (json)
|
54
|
+
- release up
|
55
|
+
- read.me
|
56
|
+
|
57
|
+
VERSION - 0.1.4.2 - 2017/08/23
|
58
|
+
|
59
|
+
- Bugfix for set_environment
|
60
|
+
- Initial model for Billet operations (Boleto)
|
61
|
+
- read.me
|
62
|
+
|
45
63
|
VERSION - 0.1.4.1 - 2017/07/12
|
46
64
|
|
47
65
|
- Function set_environment to force which environment call
|
48
66
|
- Function query_by_external_id to list all transactions related to an external_id
|
49
|
-
- version pump
|
50
67
|
- read.me
|
51
68
|
|
52
69
|
VERSION - 0.1.4 - 2017/06/01
|
@@ -1,35 +1,30 @@
|
|
1
1
|
module MidasClient
|
2
2
|
module EndPoints
|
3
|
-
@@environment = nil
|
4
3
|
|
5
|
-
def
|
6
|
-
if
|
7
|
-
|
4
|
+
def production?
|
5
|
+
if !self.environment.blank?
|
6
|
+
self.environment.upcase == 'PRODUCTION'
|
8
7
|
else
|
9
|
-
(ENV['RACK_ENV']
|
8
|
+
(ENV['RACK_ENV'].upcase == 'PRODUCTION') || ENV['PRODUCTION'] || ENV['production']
|
10
9
|
end
|
11
10
|
end
|
12
11
|
|
13
|
-
def self.set_environment(e)
|
14
|
-
@@environment = e
|
15
|
-
end
|
16
|
-
|
17
12
|
# alias for set_environment
|
18
|
-
def
|
19
|
-
self.
|
13
|
+
def set_env(e)
|
14
|
+
self.environment=e
|
20
15
|
end
|
21
16
|
|
22
|
-
def
|
23
|
-
|
17
|
+
def get_environment
|
18
|
+
get_env
|
24
19
|
end
|
25
20
|
|
26
21
|
# alias for get_environment
|
27
|
-
def
|
28
|
-
self.production? ? PRODUCTION : DEVELOPMENT
|
22
|
+
def get_env
|
23
|
+
self.production? ? EndPoints::PRODUCTION : EndPoints::DEVELOPMENT
|
29
24
|
end
|
30
25
|
|
31
26
|
DEVELOPMENT ={
|
32
|
-
url: '
|
27
|
+
url: 'http://api.sandbox.ansertecnologia.net',
|
33
28
|
management_auth: 'Basic bWlkYXM6bXRmYndZQDE5Nzc='
|
34
29
|
}
|
35
30
|
|
@@ -48,7 +43,6 @@ module MidasClient
|
|
48
43
|
cancel: '/transaction/creditcard/{transactionToken}/cancel',
|
49
44
|
refund: '/transaction/creditcard/{transactionToken}/refund',
|
50
45
|
query_by_transaction: '/transaction/{transactionToken}',
|
51
|
-
query_by_external_id: '/transactions/external-id/{externalId}',
|
52
46
|
callback: 'http://matricula.crossfitlendarios.com.br/callback'
|
53
47
|
}
|
54
48
|
|
@@ -67,6 +61,7 @@ module MidasClient
|
|
67
61
|
|
68
62
|
QUERIES = {
|
69
63
|
context: '/midas-query/v2',
|
64
|
+
by_external_id: '/transactions/external-id/{externalId}',
|
70
65
|
by_period: '/transactions?startDate={startDate}&endDate={endDate}&status={status}',
|
71
66
|
}
|
72
67
|
|
@@ -1,9 +1,7 @@
|
|
1
1
|
module MidasClient
|
2
2
|
class Management < Request
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
# This method LIST all POS in MIDAS.
|
4
|
+
#= This method LIST all POS in MIDAS.
|
7
5
|
# This is a is synchronous operation, using method GET
|
8
6
|
#
|
9
7
|
# Params:
|
@@ -34,17 +32,17 @@ module MidasClient
|
|
34
32
|
method = :get
|
35
33
|
|
36
34
|
# monta a URL de chamada da requisição
|
37
|
-
endpoint =
|
35
|
+
endpoint = get_env[:url] + EndPoints::MANAGEMENTS[:context] + EndPoints::MANAGEMENTS[:list_pos]
|
38
36
|
|
39
37
|
# monta authorization base64 no header
|
40
|
-
headers={content_type: :json, accept: :json, authorization:
|
38
|
+
headers={content_type: :json, accept: :json, authorization: get_env[:management_auth]}
|
41
39
|
|
42
40
|
# faz a chamada a plataforma de pagamento (MIDAS)
|
43
41
|
external_request(method, endpoint, {}, headers)
|
44
42
|
|
45
43
|
end
|
46
44
|
|
47
|
-
|
45
|
+
#= This method creates an POS in midas.
|
48
46
|
# This is a is synchronous operation, using method POST
|
49
47
|
#
|
50
48
|
# Params:
|
@@ -65,18 +63,16 @@ module MidasClient
|
|
65
63
|
method = :post
|
66
64
|
|
67
65
|
# monta a URL de chamada da requisição
|
68
|
-
endpoint =
|
66
|
+
endpoint = get_env[:url] + EndPoints::MANAGEMENTS[:context] + EndPoints::MANAGEMENTS[:create_pos]
|
69
67
|
|
70
68
|
# monta os parâmetros da requisição na url
|
71
69
|
params = { code: code, description: description}
|
72
70
|
|
73
71
|
# monta authorization base64 no header
|
74
|
-
headers={content_type: :json, accept: :json, authorization:
|
72
|
+
headers={content_type: :json, accept: :json, authorization: get_env[:management_auth]}
|
75
73
|
|
76
74
|
# faz a chamada a plataforma de pagamento (MIDAS)
|
77
|
-
|
78
|
-
|
79
|
-
return response[:result], response[:acessToken]
|
75
|
+
external_request(method, endpoint, params, headers)
|
80
76
|
|
81
77
|
end
|
82
78
|
end
|
data/lib/midas_client/query.rb
CHANGED
@@ -1,9 +1,7 @@
|
|
1
1
|
module MidasClient
|
2
2
|
class Queries < Request
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
# This method performs a query by a range date.
|
4
|
+
#= This method performs a query by a range date.
|
7
5
|
# This is a is synchronous operation, using method GET
|
8
6
|
#
|
9
7
|
# Params:
|
@@ -23,7 +21,7 @@ module MidasClient
|
|
23
21
|
method = :get
|
24
22
|
|
25
23
|
# monta a URL de chamada da requisição
|
26
|
-
endpoint =
|
24
|
+
endpoint = get_env[:url] + EndPoints::QUERIES[:context] + EndPoints::QUERIES[:by_period].gsub("{startDate}", start_date).gsub("{endDate}", end_date)
|
27
25
|
|
28
26
|
# monta os parâmetros da requisição na url
|
29
27
|
endpoint = status.blank? ? endpoint.gsub("{status}", '') : endpoint.gsub("{status}", status)
|
@@ -41,8 +39,35 @@ module MidasClient
|
|
41
39
|
transactions = transaction_array
|
42
40
|
end
|
43
41
|
|
44
|
-
|
42
|
+
response[:result] = result
|
43
|
+
response[:pagging] = pagging
|
44
|
+
response[:transactions] = transactions
|
45
|
+
|
46
|
+
response
|
45
47
|
end
|
46
48
|
|
47
49
|
end
|
50
|
+
|
51
|
+
#= This method performs a query by a specific transaction's identifier, called external ID.
|
52
|
+
# This is a is synchronous operation, using method GET
|
53
|
+
#
|
54
|
+
# Params:
|
55
|
+
# transactionToken: string (Transaction unique identification generated by customer)
|
56
|
+
#
|
57
|
+
#
|
58
|
+
# Response:
|
59
|
+
# result: {
|
60
|
+
# success: true/false
|
61
|
+
# code: "XXX"
|
62
|
+
# message: "Some message to you"
|
63
|
+
# }
|
64
|
+
def query_external_id(externalId)
|
65
|
+
# define o método de envio da requisição
|
66
|
+
method = :get
|
67
|
+
|
68
|
+
# monta a URL de chamada da requisição
|
69
|
+
endpoint = get_env[:url] + EndPoints::QUERIES[:context] + EndPoints::QUERIES[:by_external_id].gsub('{externalId}', externalId)
|
70
|
+
|
71
|
+
request(method, endpoint, login, password, {})
|
72
|
+
end
|
48
73
|
end
|
data/lib/midas_client/request.rb
CHANGED
@@ -2,12 +2,14 @@ module MidasClient
|
|
2
2
|
class Request
|
3
3
|
include Util
|
4
4
|
include RestClient
|
5
|
+
include EndPoints
|
5
6
|
|
6
|
-
attr_accessor :login, :password
|
7
|
+
attr_accessor :login, :password, :environment
|
7
8
|
|
8
|
-
def initialize(login=nil, password=nil, option={})
|
9
|
+
def initialize(login=nil, password=nil, environment='DEVELOPMENT', option={})
|
9
10
|
@login = login
|
10
11
|
@password = password
|
12
|
+
@environment = environment
|
11
13
|
login.blank? ? log("POS STATIC INITIALIZED!") : log("POS #{login} INITIALIZED!")
|
12
14
|
end
|
13
15
|
|
@@ -1,9 +1,8 @@
|
|
1
1
|
module MidasClient
|
2
2
|
|
3
3
|
class Subscription < Request
|
4
|
-
include EndPoints
|
5
4
|
|
6
|
-
|
5
|
+
#= This method creates a subscription.
|
7
6
|
# It is a synchronous operation, using method POST
|
8
7
|
#
|
9
8
|
# Params:
|
@@ -63,23 +62,17 @@ module MidasClient
|
|
63
62
|
method = :post
|
64
63
|
|
65
64
|
# monta a URL de chamada da requisição
|
66
|
-
endpoint=
|
65
|
+
endpoint= get_env[:url] + EndPoints::SUBSCRIPTIONS[:context] + EndPoints::SUBSCRIPTIONS[:create]
|
67
66
|
|
68
67
|
|
69
68
|
params[:externalDate] = (params[:externalDate].blank? ? Time.now.iso8601(1) : params[:externalDate])
|
70
69
|
params[:invoicesCount]= (params[:invoicesCount].blank? ? 12 : params[:invoicesCount])
|
71
70
|
|
72
71
|
# faz a chamada a plataforma de pagamento (MIDAS)
|
73
|
-
|
74
|
-
|
75
|
-
result = response[:result]
|
76
|
-
subscription_token = response[:subscriptionToken]
|
77
|
-
first_invoice_result = response[:firstInvoiceResult]
|
78
|
-
|
79
|
-
return result, subscription_token, first_invoice_result
|
72
|
+
request(method, endpoint, self.login, self.password, params)
|
80
73
|
end
|
81
74
|
|
82
|
-
|
75
|
+
#= This method cancel a subscription.
|
83
76
|
# This is a is synchronous operation.
|
84
77
|
#
|
85
78
|
# Params:
|
@@ -97,15 +90,13 @@ module MidasClient
|
|
97
90
|
method = :put
|
98
91
|
|
99
92
|
# monta a URL de chamada da requisição
|
100
|
-
endpoint =
|
93
|
+
endpoint = get_env[:url] + EndPoints::SUBSCRIPTIONS[:context] + EndPoints::SUBSCRIPTIONS[:cancel].gsub('{subscriptionToken}', subscription_token)
|
101
94
|
|
102
95
|
# faz a chamada a plataforma de pagamento (MIDAS)
|
103
|
-
|
104
|
-
|
105
|
-
response[:result]
|
96
|
+
request(method, endpoint, self.login, self.password, {})
|
106
97
|
end
|
107
98
|
|
108
|
-
|
99
|
+
#= This method updates a subscription callback, amount and updates opened invoices' amount.
|
109
100
|
# This is a is synchronous operation.
|
110
101
|
#
|
111
102
|
# Params:
|
@@ -126,7 +117,7 @@ module MidasClient
|
|
126
117
|
method = :put
|
127
118
|
|
128
119
|
# monta a URL de chamada da requisição
|
129
|
-
endpoint =
|
120
|
+
endpoint = get_env[:url] + EndPoints::SUBSCRIPTIONS[:context] + EndPoints::SUBSCRIPTIONS[:update].gsub('{subscriptionToken}', subscription_token)
|
130
121
|
|
131
122
|
# faz a chamada a plataforma de pagamento (MIDAS) para atualizar o valor de face e callback da assinatura
|
132
123
|
response = request(method, endpoint, self.login, self.password, params)
|
@@ -141,11 +132,10 @@ module MidasClient
|
|
141
132
|
opened_invoices.each do |inv|
|
142
133
|
update_invoice(inv[:token], {amount: params[:amount]})
|
143
134
|
end
|
144
|
-
|
145
|
-
response[:result]
|
135
|
+
response
|
146
136
|
end
|
147
137
|
|
148
|
-
|
138
|
+
#= This method performs a query by a specific transaction.
|
149
139
|
# This is a is synchronous operation, using method GET
|
150
140
|
#
|
151
141
|
# Params:
|
@@ -188,15 +178,13 @@ module MidasClient
|
|
188
178
|
method = :get
|
189
179
|
|
190
180
|
# monta a URL de chamada da requisição
|
191
|
-
endpoint =
|
181
|
+
endpoint = get_env[:url] + EndPoints::SUBSCRIPTIONS[:context] + EndPoints::SUBSCRIPTIONS[:by_token].gsub('{subscriptionToken}', subscription_token)
|
192
182
|
|
193
183
|
# faz a chamada a plataforma de pagamento (MIDAS)
|
194
|
-
|
195
|
-
|
196
|
-
return response[:result], response[:subscription]
|
184
|
+
request(method, endpoint, self.login, self.password, {})
|
197
185
|
end
|
198
186
|
|
199
|
-
|
187
|
+
#= This method performs a query by a specific transaction.
|
200
188
|
# This is a is synchronous operation, using method GET
|
201
189
|
#
|
202
190
|
# Params:
|
@@ -225,15 +213,13 @@ module MidasClient
|
|
225
213
|
method = :get
|
226
214
|
|
227
215
|
# monta a URL de chamada da requisição
|
228
|
-
endpoint =
|
216
|
+
endpoint = get_env[:url] + EndPoints::SUBSCRIPTIONS[:context] + EndPoints::SUBSCRIPTIONS[:invoices].gsub('{subscriptionToken}', subscription_token)
|
229
217
|
|
230
218
|
# faz a chamada a plataforma de pagamento (MIDAS)
|
231
|
-
|
232
|
-
|
233
|
-
return response[:result], response[:invoices]
|
219
|
+
request(method, endpoint, self.login, self.password, {})
|
234
220
|
end
|
235
221
|
|
236
|
-
|
222
|
+
#= This method updates the credit card information associated to the subscription.
|
237
223
|
# This is a is synchronous operation, using method PUT
|
238
224
|
#
|
239
225
|
# Params:
|
@@ -255,19 +241,17 @@ module MidasClient
|
|
255
241
|
method = :put
|
256
242
|
|
257
243
|
# monta a URL de chamada da requisição
|
258
|
-
endpoint =
|
244
|
+
endpoint = get_env[:url] + EndPoints::SUBSCRIPTIONS[:context] + EndPoints::SUBSCRIPTIONS[:update_card].gsub('{subscriptionToken}', subscription_token)
|
259
245
|
|
260
246
|
params = {
|
261
247
|
cardToken: new_card_token
|
262
248
|
}
|
263
249
|
|
264
250
|
# faz a chamada a plataforma de pagamento (MIDAS)
|
265
|
-
|
266
|
-
|
267
|
-
response[:result]
|
251
|
+
request(method, endpoint, self.login, self.password, params)
|
268
252
|
end
|
269
253
|
|
270
|
-
|
254
|
+
#= This method updates a subscription.
|
271
255
|
# This is a is synchronous operation.
|
272
256
|
#
|
273
257
|
# Params:
|
@@ -288,12 +272,10 @@ module MidasClient
|
|
288
272
|
method = :put
|
289
273
|
|
290
274
|
# monta a URL de chamada da requisição
|
291
|
-
endpoint =
|
275
|
+
endpoint = get_env[:url] + EndPoints::SUBSCRIPTIONS[:context] + EndPoints::SUBSCRIPTIONS[:update_invoice].gsub('{invoiceToken}', invoice_token)
|
292
276
|
|
293
277
|
# faz a chamada a plataforma de pagamento (MIDAS)
|
294
|
-
|
295
|
-
|
296
|
-
response[:result]
|
278
|
+
request(method, endpoint, self.login, self.password, params)
|
297
279
|
end
|
298
280
|
|
299
281
|
end
|
@@ -1,9 +1,7 @@
|
|
1
1
|
module MidasClient
|
2
2
|
class Transaction < Request
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
# This method securely stores credit card's data (pan, expiration...)
|
4
|
+
#= This method securely stores credit card's data (pan, expiration...)
|
7
5
|
# and returns a token to be used to perform payment transactions.
|
8
6
|
#
|
9
7
|
# Params:
|
@@ -43,15 +41,14 @@ module MidasClient
|
|
43
41
|
method = :post
|
44
42
|
|
45
43
|
# monta a URL de chamada da requisição
|
46
|
-
endpoint=
|
44
|
+
endpoint= get_env[:url] + EndPoints::OPERATIONS[:context] + EndPoints::OPERATIONS[:store]
|
47
45
|
|
48
46
|
# faz a chamada a plataforma de pagamento (MIDAS)
|
49
|
-
|
47
|
+
request(method, endpoint, login, password, params)
|
50
48
|
|
51
|
-
return response[:result], response[:cardToken]
|
52
49
|
end
|
53
50
|
|
54
|
-
|
51
|
+
#= This method creates a payment transaction, already performing
|
55
52
|
# the authorization and capture in only one step.
|
56
53
|
#
|
57
54
|
# Params:
|
@@ -80,18 +77,17 @@ module MidasClient
|
|
80
77
|
method = :post
|
81
78
|
|
82
79
|
# monta a URL de chamada da requisição
|
83
|
-
endpoint=
|
80
|
+
endpoint= get_env[:url] + EndPoints::OPERATIONS[:context] + EndPoints::OPERATIONS[:synchronous_transaction]
|
84
81
|
|
85
82
|
# regulariza o formato da data
|
86
83
|
params[:externalDate] = params[:externalDate].blank? ? Time.now.iso8601(1) : params[:externalDate]
|
87
84
|
|
88
85
|
# faz a chamada a plataforma de pagamento (MIDAS)
|
89
|
-
|
86
|
+
request(method, endpoint, self.login, self.password, params)
|
90
87
|
|
91
|
-
return response[:result], response[:transactionToken], response[:nsu]
|
92
88
|
end
|
93
89
|
|
94
|
-
|
90
|
+
#= This method dispatches a payment transaction creation request, already performing
|
95
91
|
# the authorization and capture in only one step, but sending the response using the
|
96
92
|
# informed callback URL, in an asynchronous away.
|
97
93
|
#
|
@@ -122,18 +118,17 @@ module MidasClient
|
|
122
118
|
method = :post
|
123
119
|
|
124
120
|
# monta a URL de chamada da requisição
|
125
|
-
endpoint=
|
121
|
+
endpoint= get_env[:url] + EndPoints::OPERATIONS[:context] + EndPoints::OPERATIONS[:asynchronous_transaction]
|
126
122
|
|
127
123
|
# regulariza o formato da data
|
128
124
|
params[:externalDate] = (params[:externalDate].blank? ? Time.now.iso8601(1) : params[:externalDate])
|
129
125
|
|
130
126
|
# faz a chamada a plataforma de pagamento (MIDAS)
|
131
|
-
|
127
|
+
request(method, endpoint, self.login, self.password, params)
|
132
128
|
|
133
|
-
return response[:result], response[:transactionToken]
|
134
129
|
end
|
135
130
|
|
136
|
-
|
131
|
+
#= This method dispatches a debit payment transaction request, that's receive an authorization URL,
|
137
132
|
# where the payer must authorize the transaction.
|
138
133
|
#
|
139
134
|
# Params:
|
@@ -169,18 +164,16 @@ module MidasClient
|
|
169
164
|
method = :post
|
170
165
|
|
171
166
|
# monta a URL de chamada da requisição
|
172
|
-
endpoint=
|
167
|
+
endpoint= get_env[:url] + EndPoints::OPERATIONS[:context] + EndPoints::OPERATIONS[:asynchronous_debit_transaction]
|
173
168
|
|
174
169
|
# regulariza formato da data
|
175
170
|
params[:externalDate] = (params[:externalDate].blank? ? Time.now.iso8601(1) : params[:externalDate])
|
176
171
|
|
177
172
|
# faz a chamada a plataforma de pagamento (MIDAS)
|
178
|
-
|
179
|
-
|
180
|
-
return response[:result], response[:authenticationUrl], response[:transactionToken]
|
173
|
+
request(method, endpoint, self.login, self.password, params)
|
181
174
|
end
|
182
175
|
|
183
|
-
|
176
|
+
#= This method performs a payment authorization. This is a is synchronous operation.
|
184
177
|
# To confirm the payment and finish the transaction you must send a capture request
|
185
178
|
#
|
186
179
|
# Params:
|
@@ -218,18 +211,17 @@ module MidasClient
|
|
218
211
|
method = :post
|
219
212
|
|
220
213
|
# monta a URL de chamada da requisição
|
221
|
-
endpoint=
|
214
|
+
endpoint= get_env[:url] + EndPoints::OPERATIONS[:context] + EndPoints::OPERATIONS[:authorize]
|
222
215
|
|
223
216
|
# regulariza o formato da data
|
224
217
|
params[:externalDate] = (params[:externalDate].blank? ? Time.now.iso8601(1) : params[:externalDate])
|
225
218
|
|
226
219
|
# faz a chamada a plataforma de pagamento (MIDAS)
|
227
|
-
|
220
|
+
request(method, endpoint, self.login, self.password, params)
|
228
221
|
|
229
|
-
return response[:result], response[:transactionToken]
|
230
222
|
end
|
231
223
|
|
232
|
-
|
224
|
+
#= This method performs a capture (confirmation) in a already authorized transaction.
|
233
225
|
# This is a is synchronous operation.
|
234
226
|
#
|
235
227
|
# Params:
|
@@ -247,15 +239,14 @@ module MidasClient
|
|
247
239
|
method = :put
|
248
240
|
|
249
241
|
# monta a URL de chamada da requisição
|
250
|
-
endpoint =
|
242
|
+
endpoint = get_env[:url] + EndPoints::OPERATIONS[:context] + EndPoints::OPERATIONS[:confirm].gsub('{transactionToken}', transaction_token)
|
251
243
|
|
252
244
|
# faz a chamada a plataforma de pagamento (MIDAS)
|
253
|
-
|
245
|
+
request(method, endpoint, self.login, self.password, {})
|
254
246
|
|
255
|
-
response[:result]
|
256
247
|
end
|
257
248
|
|
258
|
-
|
249
|
+
#= This method performs a cancellation in a already authorized transaction.
|
259
250
|
# This is a is synchronous operation.
|
260
251
|
#
|
261
252
|
# Params:
|
@@ -273,15 +264,14 @@ module MidasClient
|
|
273
264
|
method = :put
|
274
265
|
|
275
266
|
# monta a URL de chamada da requisição
|
276
|
-
endpoint =
|
267
|
+
endpoint = get_env[:url] + EndPoints::OPERATIONS[:context] + EndPoints::OPERATIONS[:cancel].gsub('{transactionToken}', transaction_token)
|
277
268
|
|
278
269
|
# faz a chamada a plataforma de pagamento (MIDAS)
|
279
|
-
|
270
|
+
request(method, endpoint, self.login, self.password, {})
|
280
271
|
|
281
|
-
response[:result]
|
282
272
|
end
|
283
273
|
|
284
|
-
|
274
|
+
#= This method performs a refund in a captured authorized transaction.
|
285
275
|
# This is a is synchronous operation.
|
286
276
|
#
|
287
277
|
# Params:
|
@@ -300,15 +290,14 @@ module MidasClient
|
|
300
290
|
method = :put
|
301
291
|
|
302
292
|
# monta a URL de chamada da requisição
|
303
|
-
endpoint =
|
293
|
+
endpoint = get_env[:url] + EndPoints::OPERATIONS[:context] + EndPoints::OPERATIONS[:refund].gsub('{transactionToken}', transaction_token)
|
304
294
|
|
305
295
|
# faz a chamada a plataforma de pagamento (MIDAS)
|
306
|
-
|
296
|
+
request(method, endpoint, self.login, self.password, {})
|
307
297
|
|
308
|
-
response[:result]
|
309
298
|
end
|
310
299
|
|
311
|
-
|
300
|
+
#= This method performs a query by a specific transaction.
|
312
301
|
# This is a is synchronous operation, using method GET
|
313
302
|
#
|
314
303
|
# Params:
|
@@ -327,36 +316,65 @@ module MidasClient
|
|
327
316
|
method = :get
|
328
317
|
|
329
318
|
# monta a URL de chamada da requisição
|
330
|
-
endpoint =
|
319
|
+
endpoint = get_env[:url] + EndPoints::OPERATIONS[:context] + EndPoints::OPERATIONS[:query_by_transaction].gsub('{transactionToken}', transaction_token)
|
331
320
|
|
332
|
-
|
333
|
-
|
334
|
-
response[:result]
|
321
|
+
request(method, endpoint, login, password, {})
|
335
322
|
end
|
336
323
|
|
337
|
-
|
324
|
+
#= This method performs a query by a specific transaction's identifier, called external ID.
|
338
325
|
# This is a is synchronous operation, using method GET
|
339
326
|
#
|
340
327
|
# Params:
|
341
328
|
# transactionToken: string (Transaction unique identification generated by customer)
|
342
329
|
#
|
343
330
|
#
|
344
|
-
#
|
345
|
-
#
|
346
|
-
#
|
347
|
-
#
|
348
|
-
#
|
349
|
-
#
|
331
|
+
# {
|
332
|
+
# "result": {
|
333
|
+
# "success": true,
|
334
|
+
# "code": "000",
|
335
|
+
# "message": "Sucesso"
|
336
|
+
# },
|
337
|
+
# "pagging": {
|
338
|
+
# "limit": 1,
|
339
|
+
# "count": 1,
|
340
|
+
# "current": 1
|
341
|
+
# },
|
342
|
+
# "transactions": [
|
343
|
+
# {
|
344
|
+
# "externalId": "906cb7ec",
|
345
|
+
# "externalDate": "2017-08-26T03:02:28.7",
|
346
|
+
# "paymentMethod": "CREDIT_CARD",
|
347
|
+
# "creditCard": {
|
348
|
+
# "brand": "VISA",
|
349
|
+
# "panLastDigits": "0308",
|
350
|
+
# "expirationMonth": 12,
|
351
|
+
# "expirationYear": 2020,
|
352
|
+
# "holderName": "CARLOS A C OLIVEIRA",
|
353
|
+
# "customer": {
|
354
|
+
# "documentType": "CPF",
|
355
|
+
# "documentNumber": "07564954744"
|
356
|
+
# }
|
357
|
+
# },
|
358
|
+
# "amount": 12000,
|
359
|
+
# "instalments": 5,
|
360
|
+
# "callbackUrl": "http://coliveira.dynu.com:3001/callback/906cb7ec",
|
361
|
+
# "nsu": "464672",
|
362
|
+
# "authorizationCode": "123456",
|
363
|
+
# "token": "8935aa77e9e4ed962d594910f96bf73f",
|
364
|
+
# "status": "CAPTURED"
|
365
|
+
# }
|
366
|
+
# ]
|
367
|
+
# }
|
368
|
+
#
|
369
|
+
#
|
350
370
|
def query_external_id(externalId)
|
351
371
|
# define o método de envio da requisição
|
352
372
|
method = :get
|
353
373
|
|
354
374
|
# monta a URL de chamada da requisição
|
355
|
-
endpoint =
|
356
|
-
|
357
|
-
response = request(method, endpoint, login, password, params)
|
375
|
+
endpoint = get_env[:url] + EndPoints::QUERIES[:context] + EndPoints::QUERIES[:by_external_id].gsub('{externalId}', externalId)
|
358
376
|
|
359
|
-
|
377
|
+
request(method, endpoint, login, password, {})
|
360
378
|
end
|
361
379
|
|
362
380
|
end
|
data/lib/midas_client/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: midas_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carlos Andre Oliveira
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-10-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -97,6 +97,7 @@ files:
|
|
97
97
|
- README.md
|
98
98
|
- Rakefile
|
99
99
|
- lib/midas_client.rb
|
100
|
+
- lib/midas_client/billet.rb
|
100
101
|
- lib/midas_client/endpoints.rb
|
101
102
|
- lib/midas_client/management.rb
|
102
103
|
- lib/midas_client/query.rb
|