mundipagg_api 1.1.1 → 1.3.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e32af1ee4d31b551605303c418ae31b0b4e1e982
4
- data.tar.gz: 146ec794891328fc98b5fe83c649eab26cc9ceb5
3
+ metadata.gz: c356b5b113df964073244c23876bd7a5a781e1f2
4
+ data.tar.gz: 1677acc186ac1efe7ab597f9e18f50f20e7eefdc
5
5
  SHA512:
6
- metadata.gz: 0f03a9117c3a2baf57315eb5598473250ea31d0c2524f4c8327b11b9f16ba72283953fe67a333191bdf390e8ea337b9d402f2a9088f399148f64ea0e7d9a1c5f
7
- data.tar.gz: e4b23313b6108b3564d39b2f3a85c6e939302ba5001c193f70c2b4e59897e28995c080e7376ecb7f4aba01d3c74c6444ead1ded530e419af25a07653efe33b64
6
+ metadata.gz: 181094efd30571f5d8520b6b56356712a89708e7fbce52ebaac85070bea2d22cfe2768d6216b82dccff83399f526ed5a1cf6a743b0d2d94ebd9f5f555244691f
7
+ data.tar.gz: e6465f80f84abab0df44f3674f9420cfbc1155c651865daef57151094fbdaf08eb5d8ea43767eef402cec47d003a27dee067e3fbb8f3821a59ff762f633386e8
data/README.md CHANGED
@@ -60,269 +60,4 @@ $ rake
60
60
 
61
61
  ## Code Examples
62
62
 
63
- ### Create a Credit Card Transaction
64
- ```ruby
65
- require 'mundipagg_api'
66
-
67
- # passa a merchantKey na variável
68
- merchantKey = 'sua merchantKey'
69
-
70
- # instancia classe com métodos de requisição
71
- # :staging ou nada para ambiente sandbox e :production para ambiente de produção
72
- gateway = MundipaggApi.new(:production, merchantKey)
73
-
74
- # coleta dados do cartão
75
- creditCardTransaction = CreditCardTransaction.new
76
- creditCardTransaction.AmountInCents = 100
77
- creditCardTransaction.InstallmentCount = 1
78
- creditCardTransaction.TransactionReference = 'CreditCard One RubySDK Test'
79
- creditCardTransaction.CreditCardOperation = 'AuthOnly'
80
- creditCardTransaction.Options.PaymentMethodCode = 1
81
- creditCardTransaction.Options.SoftDescriptorText = 'My Store Name'
82
- creditCardTransaction.CreditCard.CreditCardNumber = '5453010000066167'
83
- creditCardTransaction.CreditCard.ExpMonth = 5
84
- creditCardTransaction.CreditCard.ExpYear = 18
85
- creditCardTransaction.CreditCard.HolderName = 'Maria do Carmo'
86
- creditCardTransaction.CreditCard.SecurityCode = '123'
87
- creditCardTransaction.CreditCard.CreditCardBrand = 'Mastercard'
88
-
89
- # cria a transação
90
- createSaleRequest = CreateSaleRequest.new
91
- createSaleRequest.CreditCardTransactionCollection << creditCardTransaction
92
-
93
- # faz a requisição de criação de transação, retorna um hash com a resposta
94
- response = gateway.CreateSale(createSaleRequest)
95
- ```
96
-
97
-
98
- ### Create a BoletoTransaction
99
- ```ruby
100
- require 'mundipagg_api'
101
-
102
- # passa a merchantKey na variável
103
- merchantKey = 'sua merchantKey'
104
-
105
- # instancia classe com métodos de requisição
106
- # :staging ou nada para ambiente sandbox e :production para ambiente de produção
107
- gateway = MundipaggApi.new(:production, merchantKey)
108
-
109
- # instancia um objeto de transação de boleto
110
- boletoTransaction = BoletoTransaction.new
111
- boletoTransaction.AmountInCents = 100
112
- boletoTransaction.BankNumber = '237'
113
- boletoTransaction.DocumentNumber = '12345678901'
114
- boletoTransaction.Instructions = 'Pagar antes do vencimento'
115
- boletoTransaction.TransactionReference = 'BoletoTest#Ruby01'
116
- boletoTransaction.Options.CurrencyIso = 'BRL'
117
- boletoTransaction.Options.DaysToAddInBoletoExpirationDate = 5
118
-
119
- # instancia um objeto de request para fazer a criação de transação
120
- createSaleRequest = CreateSaleRequest.new
121
-
122
- # incrementa na coleção de boletos a transação de boleto criada
123
- createSaleRequest.BoletoTransactionCollection << boletoTransaction
124
-
125
- # faz a requisição de criação de transação, retorna um hash com a resposta
126
- response = gateway.CreateSale(createSaleRequest)
127
- ```
128
-
129
-
130
- ### Cancel Method
131
- ```ruby
132
- require 'mundipagg_api'
133
-
134
- merchantKey = 'Sua Merchant Key'
135
-
136
- # instancia classe com métodos de requisição
137
- # :staging para ambiente sandbox e :production para ambiente de produção
138
- gateway = MundipaggApi.new(:staging, merchantKey)
139
-
140
- # preenche um item de colecao, necessario para cancelamento da transacao de cartao de credito
141
- cancelCreditCardTransactionItem = ManageCreditCardTransaction.new
142
- cancelCreditCardTransactionItem.AmountInCents = 100
143
- cancelCreditCardTransactionItem.TransactionKey = 'TransactionKey da transação'
144
- cancelCreditCardTransactionItem.TransactionReference = 'RubySDK-CancelTest'
145
-
146
- # monta o objeto para cancelamento de transação
147
- cancelSaleRequest = ManageSaleRequest.new
148
- cancelSaleRequest.OrderKey = 'OrderKey AQUI'
149
- cancelSaleRequest.CreditCardTransactionCollection << cancelCreditCardTransactionItem
150
-
151
- # faz a requisição de cancelamento, retorna um hash com a resposta
152
- response = gateway.Cancel(cancelSaleRequest)
153
- ```
154
-
155
-
156
- ### Capture Method
157
- ```ruby
158
- require 'mundipagg_api'
159
-
160
- # merchant key
161
- merchantKey = 'sua merchantKey'
162
-
163
- # inicializa a classe com métodos de requisição
164
- # :staging ou nada para ambiente de sandbox e :production para ambiente de produção
165
- gateway = MundipaggApi.new(merchantKey)
166
-
167
- # itens necessários para captura da transacão
168
- captureCreditCardTransactionItem = ManageCreditCardTransaction.new
169
- captureCreditCardTransactionItem.AmountInCents = 100
170
- captureCreditCardTransactionItem.TransactionKey = 'transactionKey da transação'
171
- captureCreditCardTransactionItem.TransactionReference = 'RubySDK-CaptureTest (referência da transação)'
172
-
173
- # monta o objeto para captura de transação
174
- captureSaleRequest = ManageSaleRequest.new
175
- captureSaleRequest.OrderKey = 'orderkey da transação'
176
-
177
- # incrementa na coleção de CreditCardTransactionCollection
178
- captureSaleRequest.CreditCardTransactionCollection << captureCreditCardTransactionItem
179
-
180
- # faz a requisição de captura e salva na variável response
181
- response = gateway.Capture(captureSaleRequest)
182
- ```
183
-
184
-
185
- ### Retry Method
186
- ```ruby
187
- require 'mundipagg_api'
188
-
189
- merchantKey = 'Sua Merchant Key'
190
-
191
- # instancia classe com métodos de requisição
192
- # :staging para ambiente sandbox e :production para ambiente de produção
193
- gateway = MundipaggApi.new(:staging, merchantKey)
194
-
195
- retrySaleRequest = RetrySaleRequest.new
196
- retrySaleCreditCardTransactionItem = RetrySaleCreditCardTransaction.new
197
-
198
- # preenche um item de coleção
199
- retrySaleCreditCardTransactionItem.SecurityCode = '123'
200
- retrySaleCreditCardTransactionItem.TransactionKey = 'Transaction Key AQUI'
201
-
202
- # monta o objeto de retentativa
203
- retrySaleRequest.OrderKey = 'OrderKey AQUI'
204
-
205
- # incrementa na coleção o item de retry
206
- retrySaleRequest.RetrySaleCreditCardTransactionCollection << retrySaleCreditCardTransactionItem
207
-
208
- # faz a requisição de retentativa, retorna um hash com a resposta
209
- response = gateway.Retry(retrySaleRequest)
210
- ```
211
-
212
-
213
- ### Query Method
214
- ```ruby
215
- require 'mundipagg_api'
216
-
217
- # merchant key
218
- merchantKey = 'sua merchantKey'
219
-
220
- # inicializa a classe com métodos de requisição
221
- # :staging ou nada para ambiente de sandbox e :production para ambiente de produção
222
- gateway = MundipaggApi.new(merchantKey)
223
-
224
- # inicializa a QuerySaleRequest
225
- querySaleRequest = QuerySaleRequest.new
226
-
227
- # preenche o campo de OrderKey para enviar um request de OrderKey
228
- querySaleRequest.OrderKey = 'sua OrderKey'
229
-
230
- # faz a requisição de Query passando QuerySaleRequest.QuerySaleRequestEnum[:OrderKey] para indicar
231
- # que o método irá procurar por OrderKey e passa a OrderKey como segundo parâmetro
232
- # retorna um hash com a resposta
233
- responseQuery = gateway.Query(QuerySaleRequest.QuerySaleRequestEnum[:OrderKey], querySaleRequest.OrderKey)
234
-
235
- # se a requisição for por OrderReference ela é bem parecida com a de cima, mudando apenas algumas coisas:
236
- querySaleRequest.OrderReference = 'sua OrderReference'
237
-
238
- responseQuery = gateway.Query(QuerySaleRequest.QuerySaleRequestEnum[:OrderReference], querySaleRequest.OrderReference)
239
- ```
240
-
241
-
242
- ### ParseXmlToNotification
243
- The ParseXmlToNotification takes an XML and convert it to a hash variable.
244
-
245
- O ParseXmlToNotification converte um XML para uma variável hash.
246
-
247
- ```ruby
248
- require 'mundipagg_api'
249
-
250
- # merchant key
251
- merchantKey = 'sua merchantKey'
252
-
253
- # inicializa a classe com métodos de requisição
254
- # :staging ou nada para ambiente de sandbox e :production para ambiente de produção
255
- gateway = MundipaggApi.new(merchantKey)
256
-
257
- xml = 'xml que será passsado na variável'
258
-
259
- # faz a requisição de PostNotification (parse do XML) e retorna um hash do XML passado
260
- response = gateway.ParseXmlToNotification(xml)
261
- ```
262
-
263
-
264
- ### TransactionReportFile Method
265
- ```ruby
266
- require 'mundipagg_api'
267
-
268
- # merchant key
269
- merchantKey = 'sua merchantKey'
270
-
271
- # inicializa a classe com métodos de requisição
272
- # :staging ou nada para ambiente de sandbox e :production para ambiente de produção
273
- gateway = MundipaggApi.new(merchantKey)
274
-
275
- # cria uma variável do tipo Date, passando apenas o ano, mês e dia (nessa ordem)
276
- date = Date.new(2014, 12, 10)
277
-
278
- # faz a requisição do TransactionReportFile e retorna uma string com os dados do report
279
- response = gateway.TransactionReportFile(date)
280
- ```
281
-
282
-
283
- ##### TransactionReportFileParser
284
- If you want the string that is received from TransactionReportFile Method to be parsed, there is a method for that.
285
-
286
- Este método faz um parse na string recebida do método TransactionReportFile e retorna um hash.
287
- ```ruby
288
- require 'mundipagg_api'
289
-
290
- # merchant key
291
- merchantKey = 'sua merchantKey'
292
-
293
- # inicializa a classe com métodos de requisição
294
- # :staging ou nada para ambiente de sandbox e :production para ambiente de produção
295
- gateway = MundipaggApi.new(merchantKey)
296
-
297
- # cria uma variável do tipo Date, passando apenas o ano, mês e dia (nessa ordem)
298
- date = Date.new(2014, 12, 10)
299
-
300
- # faz a requisição do TransactionReportFile e retorna uma string com os dados do report
301
- request_to_parse = gateway.TransactionReportFile(date)
302
-
303
- # faz um parse da string do TransactionReportFile e retorna um hash com a resposta
304
- response = gateway.TransactionReportFileParser(request_to_parse)
305
- ```
306
-
307
- ##### TransactionReportFileDownloader
308
- This method download and save the TransactionReportFile to a '.txt' file.
309
-
310
- Este método faz o download e salva o TransactionReportFile em um arquivo '.txt' no local indicado.
311
- ```ruby
312
- require 'mundipagg_api'
313
-
314
- # merchant key
315
- merchantKey = 'sua merchantKey'
316
-
317
- # inicializa a classe com métodos de requisição
318
- # :staging ou nada para ambiente de sandbox e :production para ambiente de produção
319
- gateway = MundipaggApi.new(merchantKey)
320
-
321
- # cria uma variável do tipo Date, passando apenas o ano, mês e dia (nessa ordem)
322
- date = Date.new(2015, 9, 15)
323
-
324
- # faz a requisição do transaction report file e salva no destino passado como parâmetro
325
- # o segundo parâmetro é o nome do arquivo, e o terceiro é o local onde será salvo o arquivo
326
- # é salvo um arquivo em .txt no local indicado
327
- response = gateway.TransactionReportFileDownloader(date, 'Teste', "C:\\Users\\YourUser\\Desktop\\")
328
- ```
63
+ You can access all the code examples [HERE, the Wiki page!](https://github.com/mundipagg/mundipagg-one-ruby/wiki)
@@ -13,12 +13,10 @@ class MundipaggApi
13
13
  end
14
14
 
15
15
  # URL de producao
16
- @@SERVICE_URL_PRODUCTION = 'https://transactionv2.mundipaggone.com/Sale/'
17
- @@SERVICE_URL_PRODUCTION_CREDIT_CARD = 'https://transactionv2.mundipaggone.com/CreditCard/'
16
+ @@SERVICE_URL_PRODUCTION = 'https://transactionv2.mundipaggone.com'
18
17
 
19
18
  # URL de homologacao
20
- @@SERVICE_URL_STAGING = 'https://stagingv2.mundipaggone.com/Sale/'
21
- @@SERVICE_URL_STAGING_CREDIT_CARD = 'https://stagingv2.mundipaggone.com/CreditCard/'
19
+ @@SERVICE_URL_STAGING = 'https://stagingv2.mundipaggone.com'
22
20
 
23
21
  # permite que o integrador adicione uma busca por transacoes utilizando alguns criterios
24
22
  def Query(querySaleRequestEnum, key)
@@ -27,11 +25,11 @@ class MundipaggApi
27
25
 
28
26
  # se for homologacao faz a chamada por aqui
29
27
  if @serviceEnvironment == :staging
30
- response = RestClient.get @@SERVICE_URL_STAGING + '/Query/' + querySaleRequestEnum + '=' + key, headers=@@SERVICE_HEADERS
28
+ response = RestClient.get @@SERVICE_URL_STAGING + '/Sale/Query/' + querySaleRequestEnum + '=' + key, headers=@@SERVICE_HEADERS
31
29
 
32
30
  # se for producao, faz a chamada por aqui
33
31
  elsif @serviceEnvironment == :production
34
- response = RestClient.get @@SERVICE_URL_PRODUCTION + '/Query/' + querySaleRequestEnum + '=' + key, headers=@@SERVICE_HEADERS
32
+ response = RestClient.get @@SERVICE_URL_PRODUCTION + '/Sale/Query/' + querySaleRequestEnum + '=' + key, headers=@@SERVICE_HEADERS
35
33
  end
36
34
 
37
35
  # se der algum erro, trata aqui
@@ -200,9 +198,9 @@ class MundipaggApi
200
198
  end
201
199
 
202
200
  if @serviceEnvironment == :staging
203
- url = @@SERVICE_URL_STAGING
201
+ url = @@SERVICE_URL_STAGING + '/Sale/'
204
202
  elsif @serviceEnvironment == :production
205
- url = @@SERVICE_URL_PRODUCTION
203
+ url = @@SERVICE_URL_PRODUCTION + '/Sale/'
206
204
  end
207
205
  postRequest(saleHash.to_json, url)
208
206
  end
@@ -230,9 +228,9 @@ class MundipaggApi
230
228
  puts e.message
231
229
  end
232
230
  if @serviceEnvironment == :staging
233
- url = @@SERVICE_URL_STAGING + '/Retry'
231
+ url = @@SERVICE_URL_STAGING + '/Sale/Retry'
234
232
  elsif @serviceEnvironment == :production
235
- url = @@SERVICE_URL_PRODUCTION + '/Retry'
233
+ url = @@SERVICE_URL_PRODUCTION + '/Sale/Retry'
236
234
  end
237
235
  postRequest(saleHash.to_json, url)
238
236
  end
@@ -253,9 +251,9 @@ class MundipaggApi
253
251
  puts e.message
254
252
  end
255
253
  if @serviceEnvironment == :staging
256
- url = @@SERVICE_URL_STAGING + '/Cancel'
254
+ url = @@SERVICE_URL_STAGING + '/Sale/Cancel'
257
255
  elsif @serviceEnvironment == :production
258
- url = @@SERVICE_URL_PRODUCTION + '/Cancel'
256
+ url = @@SERVICE_URL_PRODUCTION + '/Sale/Cancel'
259
257
  end
260
258
  postRequest(saleHash.to_json, url)
261
259
  end
@@ -276,9 +274,9 @@ class MundipaggApi
276
274
  puts e.message
277
275
  end
278
276
  if @serviceEnvironment == :staging
279
- url = @@SERVICE_URL_STAGING + '/Capture'
277
+ url = @@SERVICE_URL_STAGING + '/Sale/Capture'
280
278
  elsif @serviceEnvironment == :production
281
- url = @@SERVICE_URL_PRODUCTION + '/Capture'
279
+ url = @@SERVICE_URL_PRODUCTION + '/Sale/Capture'
282
280
  end
283
281
  postRequest(saleHash.to_json, url)
284
282
  end
@@ -304,7 +302,7 @@ class MundipaggApi
304
302
  return response
305
303
  end
306
304
 
307
- # ffaz o download do transaction report file e salva no computador em .txt
305
+ # faz o download do transaction report file e salva no computador em .txt
308
306
  def TransactionReportFileDownloader(date, file_name, path)
309
307
  begin
310
308
  path = path + file_name + '.txt'
@@ -326,17 +324,18 @@ class MundipaggApi
326
324
  return response
327
325
  end
328
326
 
327
+ # faz uma requisicao com instant buy key
329
328
  def InstantBuyKey(instant_buy_key)
330
329
  # try, tenta fazer o request
331
330
  begin
332
331
 
333
332
  # se for homologacao faz a chamada por aqui
334
333
  if @serviceEnvironment == :staging
335
- response = RestClient.get @@SERVICE_URL_STAGING_CREDIT_CARD + instant_buy_key, headers=@@SERVICE_HEADERS
334
+ response = RestClient.get @@SERVICE_URL_STAGING + '/CreditCard/' + instant_buy_key, headers=@@SERVICE_HEADERS
336
335
 
337
336
  # se for producao, faz a chamada por aqui
338
337
  elsif @serviceEnvironment == :production
339
- response = RestClient.get @@SERVICE_URL_PRODUCTION_CREDIT_CARD + instant_buy_key, headers=@@SERVICE_HEADERS
338
+ response = RestClient.get @@SERVICE_URL_PRODUCTION + '/CreditCard/' + instant_buy_key, headers=@@SERVICE_HEADERS
340
339
  end
341
340
 
342
341
  # se der algum erro, trata aqui
@@ -349,17 +348,18 @@ class MundipaggApi
349
348
  instant_buy_response
350
349
  end
351
350
 
351
+ # faz uma requisicao com buyer key
352
352
  def BuyerKey(buyer_key)
353
353
  # try, tenta fazer o request
354
354
  begin
355
355
 
356
356
  # se for homologacao faz a chamada por aqui
357
357
  if @serviceEnvironment == :staging
358
- response = RestClient.get @@SERVICE_URL_STAGING_CREDIT_CARD + buyer_key + '/BuyerKey', headers=@@SERVICE_HEADERS
358
+ response = RestClient.get @@SERVICE_URL_STAGING + '/CreditCard/' + buyer_key + '/BuyerKey', headers=@@SERVICE_HEADERS
359
359
 
360
360
  # se for producao, faz a chamada por aqui
361
361
  elsif @serviceEnvironment == :production
362
- response = RestClient.get @@SERVICE_URL_PRODUCTION_CREDIT_CARD + buyer_key + '/BuyerKey', headers=@@SERVICE_HEADERS
362
+ response = RestClient.get @@SERVICE_URL_PRODUCTION + '/CreditCard/' + buyer_key + '/BuyerKey', headers=@@SERVICE_HEADERS
363
363
  end
364
364
 
365
365
  # se der algum erro, trata aqui
@@ -2,7 +2,7 @@ Gem::Specification.new do |s|
2
2
  s.name = 'mundipagg_api'
3
3
  s.summary = 'MundiPagg Ruby Client Library'
4
4
  s.description = 'Ruby library for integrating with the MundiPagg payment web services'
5
- s.version = '1.1.1' # Major.Minor.Revision
5
+ s.version = '1.3.0' # Major.Minor.Revision
6
6
  s.author = 'MundiPagg'
7
7
  s.email = 'github@mundipagg.com'
8
8
  s.homepage = 'http://www.mundipagg.com/'
@@ -547,4 +547,4 @@ RSpec.describe MundipaggApi do
547
547
  expect(response['ErrorReport']).to eq nil
548
548
  end
549
549
 
550
- end
550
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mundipagg_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - MundiPagg
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-30 00:00:00.000000000 Z
11
+ date: 2015-10-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client