mundipagg 1.4.1 → 1.4.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,92 +1,92 @@
1
- # encoding: UTF-8
2
- Before do
3
-
4
- @client = Mundipagg::Gateway.new :production
5
- @client.log_level = :none
6
-
7
- @order = Mundipagg::CreateOrderRequest.new
8
- @manage_order = Mundipagg::ManageOrderRequest.new
9
-
10
- @manage_order.merchantKey = TestConfiguration::Merchant::MerchantKey
11
- @order.merchantKey = TestConfiguration::Merchant::MerchantKey
12
-
13
- @transaction = Mundipagg::CreditCardTransaction.new
14
- @order.creditCardTransactionCollection << @transaction
15
-
16
- $world = self
17
- end
18
-
19
- Given(/^I have pre authorized a credit card transaction of (\w+) (\d+)\.(\d+)$/) do |currency, amount, cents|
20
-
21
- amount_decimal = TestHelper.JoinAndConvertAmountAndCents(amount, cents)
22
-
23
- @order.currencyIsoEnum = currency
24
- @order.amountInCents = (amount_decimal * 100).to_i
25
- @order.amountInCentsToConsiderPaid = (amount_decimal * 100).to_i
26
-
27
-
28
- @transaction.amountInCents = @order.amountInCents;
29
- @transaction.creditCardBrandEnum = Mundipagg::CreditCardTransaction.BrandEnum[:Visa]
30
- @transaction.creditCardOperationEnum = Mundipagg::CreditCardTransaction.OperationEnum[:AuthOnly] #Pre-authorization
31
- @transaction.creditCardNumber = '4111111111111111'
32
- @transaction.holderName = 'Bruce Wayne'
33
- @transaction.installmentCount = 1
34
- @transaction.paymentMethodCode = 1
35
- @transaction.securityCode = 123
36
- @transaction.transactionReference = 'Custom Transaction Identifier'
37
- @transaction.expirationMonth = 5
38
- @transaction.expirationYear = 2020
39
-
40
- response_hash = @client.CreateOrder(@order)
41
- @response = response_hash[:create_order_response][:create_order_result]
42
- @credit_card_result = @response[:credit_card_transaction_result_collection][:credit_card_transaction_result]
43
-
44
- @response[:success].should == true
45
- @response[:order_status_enum].should == 'Opened'
46
- @credit_card_result[:amount_in_cents].to_i.should == @order.amountInCents
47
- @credit_card_result[:credit_card_operation_enum].should == 'AuthOnly'
48
- @credit_card_result[:credit_card_transaction_status_enum].should == 'AuthorizedPendingCapture'
49
- end
50
-
51
- Given(/^I captured the transaction$/) do
52
-
53
- @manage_order.orderKey = @response[:order_key]
54
-
55
- @manage_order.manageOrderOperationEnum = Mundipagg::ManageOrderRequest.OperationEnum[:Capture]
56
-
57
- @manage_order.transactionCollection << Mundipagg::ManageTransactionRequest.new
58
- @manage_order.transactionCollection[0].amountInCents = @credit_card_result[:amount_in_cents]
59
- @manage_order.transactionCollection[0].transactionKey = @credit_card_result[:transaction_key]
60
-
61
- response_hash = @client.ManageOrder(@manage_order)
62
- @response_manage = response_hash[:manage_order_response][:manage_order_result]
63
-
64
- @response_manage[:manage_order_operation_enum].should == 'Capture'
65
- @response_manage[:order_status_enum].should == 'Paid'
66
- @response_manage[:success].should == true
67
- @response_manage[:credit_card_transaction_result_collection].should_not == nil
68
- @response_manage[:credit_card_transaction_result_collection][:credit_card_transaction_result].should_not == nil
69
-
70
- transaction_result_hash = @response_manage[:credit_card_transaction_result_collection][:credit_card_transaction_result]
71
-
72
- transaction_result_hash[:amount_in_cents].to_i.should == @order.amountInCents
73
- transaction_result_hash[:success].should == true
74
-
75
-
76
- end
77
-
78
- Then(/^I will receive a POST notification telling my transaction has been (\w+)$/) do |return_status|
79
- xml = TestHelper.CreateFakePostNotification(@response, @response_manage)
80
-
81
- @notification_hash = Mundipagg::PostNotification.ParseNotification(xml)
82
- pp @notification_hash, :indent => true
83
-
84
- @notification_hash.should_not == nil
85
- @notification_hash.count.should > 0
86
- @notification_hash[:status_notification][:credit_card_transaction][:credit_card_transaction_status].downcase.should == return_status.downcase
87
- end
88
-
89
- Then(/^the amount captured should be (\w+) (\d+)\.(\d+)$/) do |currency, amount, cents|
90
- amount_decimal = TestHelper.JoinAndConvertAmountAndCents(amount, cents)
91
- @notification_hash[:status_notification][:credit_card_transaction][:captured_amount_in_cents].to_i.should == (amount_decimal.to_i) *100
92
- end
1
+ # encoding: UTF-8
2
+ Before do
3
+
4
+ @client = Mundipagg::Gateway.new :production
5
+ @client.log_level = :none
6
+
7
+ @order = Mundipagg::CreateOrderRequest.new
8
+ @manage_order = Mundipagg::ManageOrderRequest.new
9
+
10
+ @manage_order.merchantKey = TestConfiguration::Merchant::MerchantKey
11
+ @order.merchantKey = TestConfiguration::Merchant::MerchantKey
12
+
13
+ @transaction = Mundipagg::CreditCardTransaction.new
14
+ @order.creditCardTransactionCollection << @transaction
15
+
16
+ $world = self
17
+ end
18
+
19
+ Given(/^I have pre authorized a credit card transaction of (\w+) (\d+)\.(\d+)$/) do |currency, amount, cents|
20
+
21
+ amount_decimal = TestHelper.JoinAndConvertAmountAndCents(amount, cents)
22
+
23
+ @order.currencyIsoEnum = currency
24
+ @order.amountInCents = (amount_decimal * 100).to_i
25
+ @order.amountInCentsToConsiderPaid = (amount_decimal * 100).to_i
26
+
27
+
28
+ @transaction.amountInCents = @order.amountInCents;
29
+ @transaction.creditCardBrandEnum = Mundipagg::CreditCardTransaction.BrandEnum[:Visa]
30
+ @transaction.creditCardOperationEnum = Mundipagg::CreditCardTransaction.OperationEnum[:AuthOnly] #Pre-authorization
31
+ @transaction.creditCardNumber = '4111111111111111'
32
+ @transaction.holderName = 'Bruce Wayne'
33
+ @transaction.installmentCount = 1
34
+ @transaction.paymentMethodCode = 1
35
+ @transaction.securityCode = 123
36
+ @transaction.transactionReference = 'Custom Transaction Identifier'
37
+ @transaction.expirationMonth = 5
38
+ @transaction.expirationYear = 2020
39
+
40
+ response_hash = @client.CreateOrder(@order)
41
+ @response = response_hash[:create_order_response][:create_order_result]
42
+ @credit_card_result = @response[:credit_card_transaction_result_collection][:credit_card_transaction_result]
43
+
44
+ @response[:success].should == true
45
+ @response[:order_status_enum].should == 'Opened'
46
+ @credit_card_result[:amount_in_cents].to_i.should == @order.amountInCents
47
+ @credit_card_result[:credit_card_operation_enum].should == 'AuthOnly'
48
+ @credit_card_result[:credit_card_transaction_status_enum].should == 'AuthorizedPendingCapture'
49
+ end
50
+
51
+ Given(/^I captured the transaction$/) do
52
+
53
+ @manage_order.orderKey = @response[:order_key]
54
+
55
+ @manage_order.manageOrderOperationEnum = Mundipagg::ManageOrderRequest.OperationEnum[:Capture]
56
+
57
+ @manage_order.transactionCollection << Mundipagg::ManageTransactionRequest.new
58
+ @manage_order.transactionCollection[0].amountInCents = @credit_card_result[:amount_in_cents]
59
+ @manage_order.transactionCollection[0].transactionKey = @credit_card_result[:transaction_key]
60
+
61
+ response_hash = @client.ManageOrder(@manage_order)
62
+ @response_manage = response_hash[:manage_order_response][:manage_order_result]
63
+
64
+ @response_manage[:manage_order_operation_enum].should == 'Capture'
65
+ @response_manage[:order_status_enum].should == 'Paid'
66
+ @response_manage[:success].should == true
67
+ @response_manage[:credit_card_transaction_result_collection].should_not == nil
68
+ @response_manage[:credit_card_transaction_result_collection][:credit_card_transaction_result].should_not == nil
69
+
70
+ transaction_result_hash = @response_manage[:credit_card_transaction_result_collection][:credit_card_transaction_result]
71
+
72
+ transaction_result_hash[:amount_in_cents].to_i.should == @order.amountInCents
73
+ transaction_result_hash[:success].should == true
74
+
75
+
76
+ end
77
+
78
+ Then(/^I will receive a POST notification telling my transaction has been (\w+)$/) do |return_status|
79
+ xml = TestHelper.CreateFakePostNotification(@response, @response_manage)
80
+
81
+ @notification_hash = Mundipagg::PostNotification.ParseNotification(xml)
82
+ pp @notification_hash, :indent => true
83
+
84
+ @notification_hash.should_not == nil
85
+ @notification_hash.count.should > 0
86
+ @notification_hash[:status_notification][:credit_card_transaction][:credit_card_transaction_status].downcase.should == return_status.downcase
87
+ end
88
+
89
+ Then(/^the amount captured should be (\w+) (\d+)\.(\d+)$/) do |currency, amount, cents|
90
+ amount_decimal = TestHelper.JoinAndConvertAmountAndCents(amount, cents)
91
+ @notification_hash[:status_notification][:credit_card_transaction][:captured_amount_in_cents].to_i.should == (amount_decimal.to_i) *100
92
+ end
@@ -1,6 +1,6 @@
1
- begin require 'rspec/expectations'; rescue LoadError; require 'spec/expectations'; end
2
- $:.unshift(File.dirname(__FILE__) + '/../../../lib')
3
- require 'mundipagg'
4
- require 'bigdecimal'
5
- require_relative '../../test_helper.rb'
6
- require_relative '../../test_configuration.rb'
1
+ begin require 'rspec/expectations'; rescue LoadError; require 'spec/expectations'; end
2
+ $:.unshift(File.dirname(__FILE__) + '/../../../lib')
3
+ require 'mundipagg'
4
+ require 'bigdecimal'
5
+ require_relative '../../test_helper.rb'
6
+ require_relative '../../test_configuration.rb'
@@ -1,5 +1,5 @@
1
- module TestConfiguration
2
- module Merchant
3
- MerchantKey = ''
4
- end
5
- end
1
+ module TestConfiguration
2
+ module Merchant
3
+ MerchantKey = ''
4
+ end
5
+ end
@@ -1,69 +1,69 @@
1
- require 'nori'
2
- require 'gyoku'
3
- class TestHelper
4
-
5
- def self.JoinAndConvertAmountAndCents(amount, cents)
6
- amount_with_cents = amount.gsub(',', '.')
7
- return BigDecimal.new(amount_with_cents)
8
- end
9
-
10
- def self.CreateFakePostNotification(create_order_result, manage_order_result)
11
- xml = '<StatusNotification xmlns="http://schemas.datacontract.org/2004/07/MundiPagg.NotificationService.DataContract"
12
- xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
13
- <AmountInCents>?</AmountInCents>
14
- <AmountPaidInCents>?</AmountPaidInCents>
15
- <BoletoTransaction i:nil="true"/>
16
- <CreditCardTransaction>
17
- <Acquirer>Cielo</Acquirer>
18
- <AmountInCents>?</AmountInCents>
19
- <AuthorizedAmountInCents>?</AuthorizedAmountInCents>
20
- <CapturedAmountInCents>?</CapturedAmountInCents>
21
- <CreditCardBrand>?</CreditCardBrand>
22
- <RefundedAmountInCents i:nil="true"/>
23
- <StatusChangedDate>?</StatusChangedDate>
24
- <TransactionIdentifier>?</TransactionIdentifier>
25
- <TransactionKey>?</TransactionKey>
26
- <TransactionReference>?</TransactionReference>
27
- <UniqueSequentialNumber>?</UniqueSequentialNumber>
28
- <VoidedAmountInCents i:nil="true"/>
29
- <PreviousCreditCardTransactionStatus>?</PreviousCreditCardTransactionStatus>
30
- <CreditCardTransactionStatus>?</CreditCardTransactionStatus>
31
- </CreditCardTransaction>
32
- <MerchantKey>?</MerchantKey>
33
- <OrderKey>?</OrderKey>
34
- <OrderReference>?</OrderReference>
35
- <OrderStatus>?</OrderStatus>
36
- </StatusNotification>'
37
-
38
- parser = Nori.new(:convert_tags_to => lambda { |tag| tag })
39
- hash = parser.parse(xml)
40
-
41
- credit_card_result = create_order_result[:credit_card_transaction_result_collection][:credit_card_transaction_result]
42
- manage_transaction_reuslt = manage_order_result[:credit_card_transaction_result_collection][:credit_card_transaction_result]
43
-
44
- root = hash['StatusNotification']
45
-
46
- root['AmountPaidInCents'] = 0
47
- root['CreditCardTransaction'] = {
48
- 'Acquirer' => 'Cielo',
49
- 'AmountInCents' =>credit_card_result[:amount_in_cents],
50
- 'AuthorizedAmountInCents'=> credit_card_result[:amount_in_cents],
51
- 'CapturedAmountInCents' =>credit_card_result[:amount_in_cents],
52
- 'CreditCardBrand' => 'Visa',
53
- 'RefundedAmountInCents' => nil,
54
- 'StatusChangedDate' => DateTime.now,
55
- 'TransactionIdentifier' => Array.new(12){[*'0'..'9', *'A'..'Z'].sample}.join,
56
- 'TransactionKey'=> credit_card_result[:transaction_key],
57
- 'TransactionReference'=> credit_card_result[:transaction_reference],
58
- 'UniqueSequentialNumber' => Array.new(6){[*'0'..'9'].sample}.join,
59
- 'PreviousCreditCardTransactionStatus' => credit_card_result[:credit_card_transaction_status_enum],
60
- 'CreditCardTransactionStatus' => manage_transaction_reuslt[:credit_card_transaction_status_enum]
61
- }
62
- root['MerchantKey'] = create_order_result[:merchant_key]
63
- root['OrderKey'] = create_order_result[:order_key]
64
- root['OrderReference'] = create_order_result[:order_reference]
65
- root['OrderStatus'] = manage_transaction_reuslt[:order_status_enum]
66
-
67
- return CGI::escapeHTML(Gyoku.xml(hash))
68
- end
1
+ require 'nori'
2
+ require 'gyoku'
3
+ class TestHelper
4
+
5
+ def self.JoinAndConvertAmountAndCents(amount, cents)
6
+ amount_with_cents = amount.gsub(',', '.')
7
+ return BigDecimal.new(amount_with_cents)
8
+ end
9
+
10
+ def self.CreateFakePostNotification(create_order_result, manage_order_result)
11
+ xml = '<StatusNotification xmlns="http://schemas.datacontract.org/2004/07/MundiPagg.NotificationService.DataContract"
12
+ xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
13
+ <AmountInCents>?</AmountInCents>
14
+ <AmountPaidInCents>?</AmountPaidInCents>
15
+ <BoletoTransaction i:nil="true"/>
16
+ <CreditCardTransaction>
17
+ <Acquirer>Cielo</Acquirer>
18
+ <AmountInCents>?</AmountInCents>
19
+ <AuthorizedAmountInCents>?</AuthorizedAmountInCents>
20
+ <CapturedAmountInCents>?</CapturedAmountInCents>
21
+ <CreditCardBrand>?</CreditCardBrand>
22
+ <RefundedAmountInCents i:nil="true"/>
23
+ <StatusChangedDate>?</StatusChangedDate>
24
+ <TransactionIdentifier>?</TransactionIdentifier>
25
+ <TransactionKey>?</TransactionKey>
26
+ <TransactionReference>?</TransactionReference>
27
+ <UniqueSequentialNumber>?</UniqueSequentialNumber>
28
+ <VoidedAmountInCents i:nil="true"/>
29
+ <PreviousCreditCardTransactionStatus>?</PreviousCreditCardTransactionStatus>
30
+ <CreditCardTransactionStatus>?</CreditCardTransactionStatus>
31
+ </CreditCardTransaction>
32
+ <MerchantKey>?</MerchantKey>
33
+ <OrderKey>?</OrderKey>
34
+ <OrderReference>?</OrderReference>
35
+ <OrderStatus>?</OrderStatus>
36
+ </StatusNotification>'
37
+
38
+ parser = Nori.new(:convert_tags_to => lambda { |tag| tag })
39
+ hash = parser.parse(xml)
40
+
41
+ credit_card_result = create_order_result[:credit_card_transaction_result_collection][:credit_card_transaction_result]
42
+ manage_transaction_reuslt = manage_order_result[:credit_card_transaction_result_collection][:credit_card_transaction_result]
43
+
44
+ root = hash['StatusNotification']
45
+
46
+ root['AmountPaidInCents'] = 0
47
+ root['CreditCardTransaction'] = {
48
+ 'Acquirer' => 'Cielo',
49
+ 'AmountInCents' =>credit_card_result[:amount_in_cents],
50
+ 'AuthorizedAmountInCents'=> credit_card_result[:amount_in_cents],
51
+ 'CapturedAmountInCents' =>credit_card_result[:amount_in_cents],
52
+ 'CreditCardBrand' => 'Visa',
53
+ 'RefundedAmountInCents' => nil,
54
+ 'StatusChangedDate' => DateTime.now,
55
+ 'TransactionIdentifier' => Array.new(12){[*'0'..'9', *'A'..'Z'].sample}.join,
56
+ 'TransactionKey'=> credit_card_result[:transaction_key],
57
+ 'TransactionReference'=> credit_card_result[:transaction_reference],
58
+ 'UniqueSequentialNumber' => Array.new(6){[*'0'..'9'].sample}.join,
59
+ 'PreviousCreditCardTransactionStatus' => credit_card_result[:credit_card_transaction_status_enum],
60
+ 'CreditCardTransactionStatus' => manage_transaction_reuslt[:credit_card_transaction_status_enum]
61
+ }
62
+ root['MerchantKey'] = create_order_result[:merchant_key]
63
+ root['OrderKey'] = create_order_result[:order_key]
64
+ root['OrderReference'] = create_order_result[:order_reference]
65
+ root['OrderStatus'] = manage_transaction_reuslt[:order_status_enum]
66
+
67
+ return CGI::escapeHTML(Gyoku.xml(hash))
68
+ end
69
69
  end
metadata CHANGED
@@ -1,30 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mundipagg
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
5
- prerelease:
4
+ version: 1.4.2
6
5
  platform: ruby
7
6
  authors:
8
7
  - MundiPagg
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2015-07-07 00:00:00.000000000 Z
11
+ date: 2015-08-19 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: savon
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ~>
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
19
  version: '2.3'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ~>
24
+ - - "~>"
28
25
  - !ruby/object:Gem::Version
29
26
  version: '2.3'
30
27
  description: Ruby library for integrating with the MundiPagg payment web services
@@ -33,22 +30,23 @@ executables: []
33
30
  extensions: []
34
31
  extra_rdoc_files: []
35
32
  files:
36
- - README.md
37
33
  - LICENSE
34
+ - README.md
35
+ - lib/mundipagg.rb
38
36
  - lib/mundipagg/BoletoTransaction.rb
39
37
  - lib/mundipagg/Buyer.rb
40
38
  - lib/mundipagg/BuyerAddress.rb
41
39
  - lib/mundipagg/CreateOrderRequest.rb
42
40
  - lib/mundipagg/CreditCardTransaction.rb
43
- - lib/mundipagg/gateway.rb
44
41
  - lib/mundipagg/ManageOrderRequest.rb
45
- - lib/mundipagg/post_notification.rb
46
42
  - lib/mundipagg/QueryOrderRequest.rb
47
43
  - lib/mundipagg/Recurrency.rb
48
44
  - lib/mundipagg/ShoppingCart.rb
49
45
  - lib/mundipagg/ShoppingCartItem.rb
46
+ - lib/mundipagg/gateway.rb
47
+ - lib/mundipagg/post_notification.rb
50
48
  - lib/mundipagg/version.rb
51
- - lib/mundipagg.rb
49
+ - mundipagg.gemspec
52
50
  - tests/features/boleto.feature
53
51
  - tests/features/credit_card.feature
54
52
  - tests/features/post_notification.feature
@@ -58,30 +56,28 @@ files:
58
56
  - tests/features/support/env.rb
59
57
  - tests/test_configuration.rb
60
58
  - tests/test_helper.rb
61
- - mundipagg.gemspec
62
59
  homepage: http://www.mundipagg.com/
63
60
  licenses:
64
61
  - Apache 2.0
62
+ metadata: {}
65
63
  post_install_message:
66
64
  rdoc_options: []
67
65
  require_paths:
68
66
  - lib
69
67
  required_ruby_version: !ruby/object:Gem::Requirement
70
- none: false
71
68
  requirements:
72
- - - ! '>='
69
+ - - ">="
73
70
  - !ruby/object:Gem::Version
74
71
  version: 1.9.2
75
72
  required_rubygems_version: !ruby/object:Gem::Requirement
76
- none: false
77
73
  requirements:
78
- - - ! '>='
74
+ - - ">="
79
75
  - !ruby/object:Gem::Version
80
76
  version: '0'
81
77
  requirements: []
82
78
  rubyforge_project:
83
- rubygems_version: 1.8.29
79
+ rubygems_version: 2.4.5
84
80
  signing_key:
85
- specification_version: 3
81
+ specification_version: 4
86
82
  summary: MundiPagg Ruby Client Library
87
83
  test_files: []