mundipagg_sdk 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -5
- data/lib/gateway/Gateway.rb +31 -2
- data/mundipagg_sdk.gemspec +1 -1
- data/spec/integration/gateway_spec.rb +17 -13
- data/spec/integration/test_helper.rb +3 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2e4570e8accdb1715c95142df6d860df05ed09de
|
4
|
+
data.tar.gz: 6e36566499df37b6329397464b47ed0d31e8e322
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 619aa8d703a8b3c37bfc7ce62d6563279db9c7429a67733603a2e2d4ac85c54ef61313050c5aafea4ef3c72569ce7e5675946d8ea8eb54b57bbdd916963dabd4
|
7
|
+
data.tar.gz: ca5a939b541a37d7c22c0657274172ddd7d54c18a3196b5cace45f53e1cbace3feee3829901011733f593f96ccdde1a1d5b6d3853ac0a75d250cc6cb8cee2d9c
|
data/README.md
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
# mundipagg-one-ruby
|
2
2
|
|
3
3
|
### Mundipagg Gem Download
|
4
|
-
https://rubygems.org/gems/
|
4
|
+
https://rubygems.org/gems/mundipagg_sdk
|
5
5
|
|
6
6
|
```ruby
|
7
|
-
$ gem install
|
7
|
+
$ gem install mundipagg_sdk
|
8
8
|
```
|
9
9
|
|
10
10
|
```ruby
|
11
|
-
require '
|
11
|
+
require 'mundipagg_sdk'
|
12
12
|
```
|
13
13
|
|
14
14
|
Ruby DevKit is required.
|
@@ -17,8 +17,6 @@ Ruby DevKit is required.
|
|
17
17
|
The recommended Windows version of Ruby is Ruby 2.1.
|
18
18
|
For gems work correctly it'll be necessary run the following commands:
|
19
19
|
|
20
|
-
No Windows a versão do Ruby recomendada é a 2.1.
|
21
|
-
Para que todas as gemas funcionem corretamente é necessário realizar o seguinte processo:
|
22
20
|
```ruby
|
23
21
|
$ gem install rubygems-update
|
24
22
|
$ update_rubygems
|
data/lib/gateway/Gateway.rb
CHANGED
@@ -21,6 +21,12 @@ class Gateway
|
|
21
21
|
# URL de sandbox
|
22
22
|
@@SERVICE_URL_SANDBOX = 'https://sandbox.mundipaggone.com'
|
23
23
|
|
24
|
+
# URL do postnotification de producao
|
25
|
+
@@SERVICE_URL_NOTIFICATION_PRODUCTION = 'https://api.mundipaggone.com/TransactionReportFile/GetStream?fileDate='
|
26
|
+
|
27
|
+
# URL do postnotification de sandbox
|
28
|
+
@@SERVICE_URL_NOTIFICATION_SANDBOX = 'https://apisandbox.mundipaggone.com/TransactionReportFile/GetStream?fileDate='
|
29
|
+
|
24
30
|
# permite que o integrador adicione uma busca por transacoes utilizando alguns criterios
|
25
31
|
def Query(querySaleRequestEnum, key)
|
26
32
|
# try, tenta fazer o request
|
@@ -310,7 +316,18 @@ class Gateway
|
|
310
316
|
# faz uma requisicao e retorna uma string com o transaction report file
|
311
317
|
def TransactionReportFile(date)
|
312
318
|
begin
|
313
|
-
response = RestClient.get('https://api.mundipaggone.com/TransactionReportFile/GetStream?fileDate=' + date.strftime("%Y%m%d"), headers={:MerchantKey => "#{@merchantKey}"})
|
319
|
+
#response = RestClient.get('https://api.mundipaggone.com/TransactionReportFile/GetStream?fileDate=' + date.strftime("%Y%m%d"), headers={:MerchantKey => "#{@merchantKey}"})
|
320
|
+
|
321
|
+
if @serviceEnvironment == :staging
|
322
|
+
url = @@SERVICE_URL_NOTIFICATION_PRODUCTION + date.strftime("%Y%m%d")
|
323
|
+
elsif @serviceEnvironment == :production
|
324
|
+
url = @@SERVICE_URL_NOTIFICATION_PRODUCTION + date.strftime("%Y%m%d")
|
325
|
+
elsif @serviceEnvironment == :sandbox
|
326
|
+
url = @@SERVICE_URL_NOTIFICATION_SANDBOX + date.strftime("%Y%m%d")
|
327
|
+
end
|
328
|
+
|
329
|
+
response = getReportFile(url)
|
330
|
+
|
314
331
|
rescue RestClient::ExceptionWithResponse => err
|
315
332
|
return err.response
|
316
333
|
end
|
@@ -321,7 +338,10 @@ class Gateway
|
|
321
338
|
def TransactionReportFileDownloader(date, file_name, path)
|
322
339
|
begin
|
323
340
|
path = path + file_name + '.txt'
|
324
|
-
response = RestClient.get('https://api.mundipaggone.com/TransactionReportFile/GetStream?fileDate=' + date.strftime("%Y%m%d"), headers={:MerchantKey => "#{@merchantKey}"})
|
341
|
+
#response = RestClient.get('https://api.mundipaggone.com/TransactionReportFile/GetStream?fileDate=' + date.strftime("%Y%m%d"), headers={:MerchantKey => "#{@merchantKey}"})
|
342
|
+
|
343
|
+
response = TransactionReportFile(date)
|
344
|
+
|
325
345
|
File.write(path, response)
|
326
346
|
rescue RestClient::ExceptionWithResponse => err
|
327
347
|
return err.response
|
@@ -413,4 +433,13 @@ class Gateway
|
|
413
433
|
json_response = JSON.load response
|
414
434
|
json_response
|
415
435
|
end
|
436
|
+
|
437
|
+
def getReportFile(url)
|
438
|
+
begin
|
439
|
+
response = RestClient.get(url, headers={:MerchantKey => "#{@merchantKey}"})
|
440
|
+
rescue RestClient::ExceptionWithResponse => err
|
441
|
+
return err.response
|
442
|
+
end
|
443
|
+
return response
|
444
|
+
end
|
416
445
|
end
|
data/mundipagg_sdk.gemspec
CHANGED
@@ -2,7 +2,7 @@ Gem::Specification.new do |s|
|
|
2
2
|
s.name = 'mundipagg_sdk'
|
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.0.
|
5
|
+
s.version = '1.0.1' # Major.Minor.Revision
|
6
6
|
s.author = 'MundiPagg'
|
7
7
|
s.email = 'github@mundipagg.com'
|
8
8
|
s.homepage = 'http://www.mundipagg.com/'
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require_relative '../../lib/mundipagg_sdk'
|
2
2
|
require_relative 'test_helper'
|
3
3
|
|
4
|
-
merchant_key = '
|
4
|
+
merchant_key = '85328786-8BA6-420F-9948-5352F5A183EB'
|
5
5
|
gateway = Gateway.new(:sandbox, merchant_key)
|
6
6
|
|
7
7
|
RSpec.describe Gateway do
|
@@ -399,7 +399,7 @@ RSpec.describe Gateway do
|
|
399
399
|
creditCardTransactionItem.AmountInCents = 100
|
400
400
|
creditCardTransactionItem.TransactionReference = 'Ruby PostNotification Test'
|
401
401
|
creditCardTransactionItem.InstallmentCount = 1
|
402
|
-
creditCardTransactionItem.CreditCardOperation = '
|
402
|
+
creditCardTransactionItem.CreditCardOperation = 'AuthAndCapture'
|
403
403
|
creditCardTransactionItem.CreditCard.CreditCardBrand = 'Visa'
|
404
404
|
creditCardTransactionItem.CreditCard.CreditCardNumber = '4111111111111111'
|
405
405
|
creditCardTransactionItem.CreditCard.HolderName = 'Bruce Wayne'
|
@@ -416,8 +416,8 @@ RSpec.describe Gateway do
|
|
416
416
|
credit_card_result = response_hash['CreditCardTransactionResultCollection'][0]
|
417
417
|
|
418
418
|
expect(credit_card_result['Success']).to eq true
|
419
|
-
expect(credit_card_result['CreditCardOperation']).to eq 'AuthOnly'
|
420
|
-
expect(credit_card_result['CreditCardTransactionStatus']).to eq 'AuthorizedPendingCapture'
|
419
|
+
# expect(credit_card_result['CreditCardOperation']).to eq 'AuthOnly'
|
420
|
+
# expect(credit_card_result['CreditCardTransactionStatus']).to eq 'AuthorizedPendingCapture'
|
421
421
|
|
422
422
|
captureCreditCardTransactionItem = ManageCreditCardTransaction.new
|
423
423
|
captureCreditCardTransactionItem.AmountInCents = creditCardTransactionItem.AmountInCents
|
@@ -496,29 +496,33 @@ RSpec.describe Gateway do
|
|
496
496
|
end
|
497
497
|
|
498
498
|
it 'should bring the transaction report file' do
|
499
|
-
date = Date.new(2015, 9,
|
499
|
+
date = Date.new(2015, 9, 19)
|
500
500
|
result = gateway.TransactionReportFile(date)
|
501
501
|
split_commas = result.split(',')
|
502
502
|
|
503
|
-
expect(split_commas[1]).to eq '
|
503
|
+
expect(split_commas[1]).to eq '20150919'
|
504
504
|
end
|
505
505
|
|
506
506
|
it 'should parse the transaction report file received' do
|
507
|
-
date = Date.new(2015, 9,
|
507
|
+
date = Date.new(2015, 9, 19)
|
508
508
|
request_to_parse = gateway.TransactionReportFile(date)
|
509
509
|
result = gateway.TransactionReportFileParser(request_to_parse)
|
510
510
|
|
511
|
-
expect(result['Header'].TransactionProcessedDate).to eq '
|
511
|
+
expect(result['Header'].TransactionProcessedDate).to eq '20150919'
|
512
512
|
end
|
513
513
|
|
514
514
|
it 'should save the transaction report file at selected path' do
|
515
|
-
date = Date.new(2015, 9,
|
516
|
-
|
517
|
-
|
518
|
-
gateway.TransactionReportFileDownloader(date,
|
515
|
+
date = Date.new(2015, 9, 19)
|
516
|
+
|
517
|
+
file = Tempfile.new('Test')
|
518
|
+
gateway.TransactionReportFileDownloader(date, 'Test', file.path)
|
519
519
|
|
520
|
-
file_path =
|
520
|
+
file_path = file.path.to_s + 'Test.txt'
|
521
521
|
file_exist = File.exist?(file_path)
|
522
|
+
|
523
|
+
file.close
|
524
|
+
file.unlink
|
525
|
+
|
522
526
|
expect(file_exist).to eq true
|
523
527
|
end
|
524
528
|
|
@@ -39,7 +39,7 @@ class TestHelper
|
|
39
39
|
hash = parser.parse(xml)
|
40
40
|
|
41
41
|
credit_card_result = create_order_result['CreditCardTransactionResultCollection'][0]
|
42
|
-
|
42
|
+
manage_transaction_result = manage_order_result['CreditCardTransactionResultCollection'][0]
|
43
43
|
|
44
44
|
root = hash['StatusNotification']
|
45
45
|
|
@@ -57,12 +57,12 @@ class TestHelper
|
|
57
57
|
'TransactionReference'=> credit_card_result['TransactionReference'],
|
58
58
|
'UniqueSequentialNumber' => Array.new(6){[*'0'..'9'].sample}.join,
|
59
59
|
'PreviousCreditCardTransactionStatus' => credit_card_result['CreditCardTransactionStatus'],
|
60
|
-
'CreditCardTransactionStatus' =>
|
60
|
+
'CreditCardTransactionStatus' => (manage_transaction_result.nil? == true) ? 'null' : manage_transaction_result['CreditCardTransactionStatus']
|
61
61
|
}
|
62
62
|
root['MerchantKey'] = create_order_result['MerchantKey']
|
63
63
|
root['OrderKey'] = create_order_result['OrderResult']['OrderKey']
|
64
64
|
root['OrderReference'] = create_order_result['OrderResult']['OrderReference']
|
65
|
-
root['OrderStatus'] =
|
65
|
+
root['OrderStatus'] = (manage_transaction_result.nil? == true) ? 'null' : manage_transaction_result['CreditCardTransactionStatus']
|
66
66
|
|
67
67
|
return CGI::escapeHTML(Gyoku.xml(hash))
|
68
68
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mundipagg_sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- MundiPagg
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|