mundipagg 1.3.1 → 1.4.0

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 = '8A2DD57F-1ED9-4153-B4CE-69683EFADAD5'
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,29 +1,32 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mundipagg
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.4.0
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - MundiPagg
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2014-07-16 00:00:00.000000000 Z
12
+ date: 2015-06-29 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: savon
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
- - - '='
19
+ - - ~>
18
20
  - !ruby/object:Gem::Version
19
- version: 2.3.0
21
+ version: '2.3'
20
22
  type: :runtime
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
23
26
  requirements:
24
- - - '='
27
+ - - ~>
25
28
  - !ruby/object:Gem::Version
26
- version: 2.3.0
29
+ version: '2.3'
27
30
  description: Ruby library for integrating with the MundiPagg payment web services
28
31
  email: github@mundipagg.com
29
32
  executables: []
@@ -42,6 +45,8 @@ files:
42
45
  - lib/mundipagg/post_notification.rb
43
46
  - lib/mundipagg/QueryOrderRequest.rb
44
47
  - lib/mundipagg/Recurrency.rb
48
+ - lib/mundipagg/ShoppingCart.rb
49
+ - lib/mundipagg/ShoppingCartItem.rb
45
50
  - lib/mundipagg/version.rb
46
51
  - lib/mundipagg.rb
47
52
  - tests/features/boleto.feature
@@ -57,26 +62,26 @@ files:
57
62
  homepage: http://www.mundipagg.com/
58
63
  licenses:
59
64
  - Apache 2.0
60
- metadata: {}
61
65
  post_install_message:
62
66
  rdoc_options: []
63
67
  require_paths:
64
68
  - lib
65
69
  required_ruby_version: !ruby/object:Gem::Requirement
70
+ none: false
66
71
  requirements:
67
- - - '>='
72
+ - - ! '>='
68
73
  - !ruby/object:Gem::Version
69
74
  version: 1.9.2
70
75
  required_rubygems_version: !ruby/object:Gem::Requirement
76
+ none: false
71
77
  requirements:
72
- - - '>='
78
+ - - ! '>='
73
79
  - !ruby/object:Gem::Version
74
80
  version: '0'
75
81
  requirements: []
76
82
  rubyforge_project:
77
- rubygems_version: 2.1.10
83
+ rubygems_version: 1.8.29
78
84
  signing_key:
79
- specification_version: 4
85
+ specification_version: 3
80
86
  summary: MundiPagg Ruby Client Library
81
87
  test_files: []
82
- has_rdoc:
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: eff638b17781813199b2dfe7d25beba303baac0a
4
- data.tar.gz: 04cc197003b40df4efa9927becff6aa52fe9cf68
5
- SHA512:
6
- metadata.gz: 84622e17da97110b348ffb17353369d421b5ef1a135d6a1e37039e39f1cb8773834cbcde3cf1d7db90430d7abb0c6f5feb77a55990da39b8e7372796eb59e096
7
- data.tar.gz: 13402994cbb62c3fec40c8cef0639420f68026dc526f83492a5872eda870cdda7570e0f69b6b769f358e5e3860518efb6cef3d08b0cd16abc706c0319fcbb2ef