mundipagg 1.4.1 → 1.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +191 -191
- data/README.md +118 -118
- data/lib/mundipagg.rb +13 -13
- data/lib/mundipagg/BoletoTransaction.rb +30 -30
- data/lib/mundipagg/Buyer.rb +81 -81
- data/lib/mundipagg/BuyerAddress.rb +68 -68
- data/lib/mundipagg/CreateOrderRequest.rb +66 -66
- data/lib/mundipagg/CreditCardTransaction.rb +81 -81
- data/lib/mundipagg/ManageOrderRequest.rb +51 -51
- data/lib/mundipagg/QueryOrderRequest.rb +28 -27
- data/lib/mundipagg/Recurrency.rb +38 -38
- data/lib/mundipagg/ShoppingCart.rb +15 -15
- data/lib/mundipagg/ShoppingCartItem.rb +23 -23
- data/lib/mundipagg/gateway.rb +401 -401
- data/lib/mundipagg/post_notification.rb +30 -30
- data/lib/mundipagg/version.rb +9 -9
- data/mundipagg.gemspec +18 -18
- data/tests/features/boleto.feature +9 -9
- data/tests/features/credit_card.feature +43 -43
- data/tests/features/post_notification.feature +9 -9
- data/tests/features/step_definitions/boleto_steps.rb +50 -50
- data/tests/features/step_definitions/credit_card_steps.rb +167 -167
- data/tests/features/step_definitions/post_notification.rb +92 -92
- data/tests/features/support/env.rb +6 -6
- data/tests/test_configuration.rb +5 -5
- data/tests/test_helper.rb +68 -68
- metadata +14 -18
@@ -1,31 +1,31 @@
|
|
1
|
-
require 'nori'
|
2
|
-
|
3
|
-
module Mundipagg
|
4
|
-
# Class who handles Mundipagg post notification XML
|
5
|
-
class PostNotification
|
6
|
-
|
7
|
-
# This method parse the Xml sent by Mundipagg when notify a change in a transaction.
|
8
|
-
#
|
9
|
-
# @param request [String] XML received in the Mundipagg POST request.
|
10
|
-
# @return [Hash<Symbol, String>] A hash collection containing the XML data parsed.
|
11
|
-
def self.ParseNotification(xml)
|
12
|
-
|
13
|
-
nori = Nori.new(:convert_tags_to => lambda { |tag| PostNotification.to_underscore(tag).to_sym })
|
14
|
-
xml_hash = nori.parse(CGI::unescapeHTML(xml))
|
15
|
-
|
16
|
-
return xml_hash
|
17
|
-
end
|
18
|
-
|
19
|
-
# Converts a string in Camel Case format to lower case with underscore.
|
20
|
-
#
|
21
|
-
# @param Example: 'StatusNotification' outputs 'status_notification'
|
22
|
-
# @returns [String] lower case string separated with underscore
|
23
|
-
def self.to_underscore(camel_case_string)
|
24
|
-
return camel_case_string.gsub(/::/, '/').
|
25
|
-
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
|
26
|
-
gsub(/([a-z\d])([A-Z])/,'\1_\2').
|
27
|
-
tr("-", "_").
|
28
|
-
downcase
|
29
|
-
end
|
30
|
-
end
|
1
|
+
require 'nori'
|
2
|
+
|
3
|
+
module Mundipagg
|
4
|
+
# Class who handles Mundipagg post notification XML
|
5
|
+
class PostNotification
|
6
|
+
|
7
|
+
# This method parse the Xml sent by Mundipagg when notify a change in a transaction.
|
8
|
+
#
|
9
|
+
# @param request [String] XML received in the Mundipagg POST request.
|
10
|
+
# @return [Hash<Symbol, String>] A hash collection containing the XML data parsed.
|
11
|
+
def self.ParseNotification(xml)
|
12
|
+
|
13
|
+
nori = Nori.new(:convert_tags_to => lambda { |tag| PostNotification.to_underscore(tag).to_sym })
|
14
|
+
xml_hash = nori.parse(CGI::unescapeHTML(xml))
|
15
|
+
|
16
|
+
return xml_hash
|
17
|
+
end
|
18
|
+
|
19
|
+
# Converts a string in Camel Case format to lower case with underscore.
|
20
|
+
#
|
21
|
+
# @param Example: 'StatusNotification' outputs 'status_notification'
|
22
|
+
# @returns [String] lower case string separated with underscore
|
23
|
+
def self.to_underscore(camel_case_string)
|
24
|
+
return camel_case_string.gsub(/::/, '/').
|
25
|
+
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
|
26
|
+
gsub(/([a-z\d])([A-Z])/,'\1_\2').
|
27
|
+
tr("-", "_").
|
28
|
+
downcase
|
29
|
+
end
|
30
|
+
end
|
31
31
|
end
|
data/lib/mundipagg/version.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
module Mundipagg
|
2
|
-
module Version
|
3
|
-
Major = 1
|
4
|
-
Minor = 4
|
5
|
-
Revision =
|
6
|
-
|
7
|
-
String = "#{Major}.#{Minor}.#{Revision}"
|
8
|
-
end
|
9
|
-
end
|
1
|
+
module Mundipagg
|
2
|
+
module Version
|
3
|
+
Major = 1
|
4
|
+
Minor = 4
|
5
|
+
Revision = 2
|
6
|
+
|
7
|
+
String = "#{Major}.#{Minor}.#{Revision}"
|
8
|
+
end
|
9
|
+
end
|
data/mundipagg.gemspec
CHANGED
@@ -1,18 +1,18 @@
|
|
1
|
-
$:.push File.expand_path("../lib", __FILE__)
|
2
|
-
require "mundipagg/version"
|
3
|
-
|
4
|
-
Gem::Specification.new do |s|
|
5
|
-
s.name = "mundipagg"
|
6
|
-
s.summary = "MundiPagg Ruby Client Library"
|
7
|
-
s.description = "Ruby library for integrating with the MundiPagg payment web services"
|
8
|
-
s.version = Mundipagg::Version::String
|
9
|
-
s.author = "MundiPagg"
|
10
|
-
s.email = "github@mundipagg.com"
|
11
|
-
s.homepage = "http://www.mundipagg.com/"
|
12
|
-
s.files = Dir.glob ["README.md", "LICENSE", "lib/**/*.{rb}", "tests/**/*", "*.gemspec"]
|
13
|
-
s.add_dependency "savon", "~> 2.3"
|
14
|
-
s.required_ruby_version = '>= 1.9.2'
|
15
|
-
s.license = "Apache 2.0"
|
16
|
-
|
17
|
-
|
18
|
-
end
|
1
|
+
$:.push File.expand_path("../lib", __FILE__)
|
2
|
+
require "mundipagg/version"
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = "mundipagg"
|
6
|
+
s.summary = "MundiPagg Ruby Client Library"
|
7
|
+
s.description = "Ruby library for integrating with the MundiPagg payment web services"
|
8
|
+
s.version = Mundipagg::Version::String
|
9
|
+
s.author = "MundiPagg"
|
10
|
+
s.email = "github@mundipagg.com"
|
11
|
+
s.homepage = "http://www.mundipagg.com/"
|
12
|
+
s.files = Dir.glob ["README.md", "LICENSE", "lib/**/*.{rb}", "tests/**/*", "*.gemspec"]
|
13
|
+
s.add_dependency "savon", "~> 2.3"
|
14
|
+
s.required_ruby_version = '>= 1.9.2'
|
15
|
+
s.license = "Apache 2.0"
|
16
|
+
|
17
|
+
|
18
|
+
end
|
@@ -1,9 +1,9 @@
|
|
1
|
-
Feature: Boleto transaction
|
2
|
-
I want to create a order with one boleto transaction.
|
3
|
-
|
4
|
-
Scenario: Send a Boleto Transaction to One
|
5
|
-
Given I have purchase two products with a total cost of BRL 50.00
|
6
|
-
And I will pay using Boleto with 15 days to expire
|
7
|
-
And I will send to Mundipagg
|
8
|
-
Then The order amount in cents should be 5000
|
9
|
-
And The boleto status should be Generated
|
1
|
+
Feature: Boleto transaction
|
2
|
+
I want to create a order with one boleto transaction.
|
3
|
+
|
4
|
+
Scenario: Send a Boleto Transaction to One
|
5
|
+
Given I have purchase two products with a total cost of BRL 50.00
|
6
|
+
And I will pay using Boleto with 15 days to expire
|
7
|
+
And I will send to Mundipagg
|
8
|
+
Then The order amount in cents should be 5000
|
9
|
+
And The boleto status should be Generated
|
@@ -1,43 +1,43 @@
|
|
1
|
-
Feature: Credit Card Transaction
|
2
|
-
I want to create a order with one credit card transaction.
|
3
|
-
|
4
|
-
Scenario: Pay a order using credit card and installment
|
5
|
-
Given I have purchase three products with a total cost of BRL 250
|
6
|
-
And I will pay using a Visa credit card in 3 installments
|
7
|
-
And I will send to Mundipagg
|
8
|
-
Then the order amount in cents should be 25000
|
9
|
-
And the transaction status should be Captured
|
10
|
-
|
11
|
-
Scenario: Pay a order using credit card without installment
|
12
|
-
Given I have purchase three products with a total cost of BRL 100,29
|
13
|
-
And I will pay using a Visa credit card without installment
|
14
|
-
And I will send to Mundipagg
|
15
|
-
Then the order amount in cents should be 10029
|
16
|
-
And the transaction status should be Captured
|
17
|
-
|
18
|
-
Scenario: Keeping sensible information unlogged
|
19
|
-
Given I have purchase three products with a total cost of BRL 100,29
|
20
|
-
And I will pay using a Visa credit card without installment
|
21
|
-
And I will send to Mundipagg
|
22
|
-
Then the log file doesn't contain sensible information
|
23
|
-
|
24
|
-
Scenario: Pay a order using credit card using instant buy key
|
25
|
-
Given I have purchase three products with a total cost of BRL 100,29
|
26
|
-
And I will pay using a Visa credit card without installment
|
27
|
-
And I will send to Mundipagg
|
28
|
-
When I pay another order with the instant buy key
|
29
|
-
Then the transaction status should be Captured
|
30
|
-
|
31
|
-
Scenario: Pay a order using credit card and installment
|
32
|
-
Given I have purchase three products with Shopping Cart a total cost of BRL 300
|
33
|
-
And I will pay using a Visa credit card in 3 installments
|
34
|
-
And I will send to Mundipagg
|
35
|
-
Then the order amount in cents should be 30000
|
36
|
-
And the transaction status should be Captured
|
37
|
-
|
38
|
-
Scenario: Pay a order using credit card and installment
|
39
|
-
Given I have purchase three products with Buyer data and a total cost of BRL 300
|
40
|
-
And I will pay using a Visa credit card in 3 installments
|
41
|
-
And I will send to Mundipagg
|
42
|
-
Then the order amount in cents should be 30000
|
43
|
-
And the transaction status should be Captured
|
1
|
+
Feature: Credit Card Transaction
|
2
|
+
I want to create a order with one credit card transaction.
|
3
|
+
|
4
|
+
Scenario: Pay a order using credit card and installment
|
5
|
+
Given I have purchase three products with a total cost of BRL 250
|
6
|
+
And I will pay using a Visa credit card in 3 installments
|
7
|
+
And I will send to Mundipagg
|
8
|
+
Then the order amount in cents should be 25000
|
9
|
+
And the transaction status should be Captured
|
10
|
+
|
11
|
+
Scenario: Pay a order using credit card without installment
|
12
|
+
Given I have purchase three products with a total cost of BRL 100,29
|
13
|
+
And I will pay using a Visa credit card without installment
|
14
|
+
And I will send to Mundipagg
|
15
|
+
Then the order amount in cents should be 10029
|
16
|
+
And the transaction status should be Captured
|
17
|
+
|
18
|
+
Scenario: Keeping sensible information unlogged
|
19
|
+
Given I have purchase three products with a total cost of BRL 100,29
|
20
|
+
And I will pay using a Visa credit card without installment
|
21
|
+
And I will send to Mundipagg
|
22
|
+
Then the log file doesn't contain sensible information
|
23
|
+
|
24
|
+
Scenario: Pay a order using credit card using instant buy key
|
25
|
+
Given I have purchase three products with a total cost of BRL 100,29
|
26
|
+
And I will pay using a Visa credit card without installment
|
27
|
+
And I will send to Mundipagg
|
28
|
+
When I pay another order with the instant buy key
|
29
|
+
Then the transaction status should be Captured
|
30
|
+
|
31
|
+
Scenario: Pay a order using credit card and installment
|
32
|
+
Given I have purchase three products with Shopping Cart a total cost of BRL 300
|
33
|
+
And I will pay using a Visa credit card in 3 installments
|
34
|
+
And I will send to Mundipagg
|
35
|
+
Then the order amount in cents should be 30000
|
36
|
+
And the transaction status should be Captured
|
37
|
+
|
38
|
+
Scenario: Pay a order using credit card and installment
|
39
|
+
Given I have purchase three products with Buyer data and a total cost of BRL 300
|
40
|
+
And I will pay using a Visa credit card in 3 installments
|
41
|
+
And I will send to Mundipagg
|
42
|
+
Then the order amount in cents should be 30000
|
43
|
+
And the transaction status should be Captured
|
@@ -1,9 +1,9 @@
|
|
1
|
-
Feature: Post Notification
|
2
|
-
I want capture a transaction and receive a post notification telling my transaction has been captured.
|
3
|
-
|
4
|
-
|
5
|
-
Scenario: Receiving a POST notification
|
6
|
-
Given I have pre authorized a credit card transaction of BRL 100.00
|
7
|
-
And I captured the transaction
|
8
|
-
Then I will receive a POST notification telling my transaction has been Captured
|
9
|
-
And the amount captured should be BRL 100.00
|
1
|
+
Feature: Post Notification
|
2
|
+
I want capture a transaction and receive a post notification telling my transaction has been captured.
|
3
|
+
|
4
|
+
|
5
|
+
Scenario: Receiving a POST notification
|
6
|
+
Given I have pre authorized a credit card transaction of BRL 100.00
|
7
|
+
And I captured the transaction
|
8
|
+
Then I will receive a POST notification telling my transaction has been Captured
|
9
|
+
And the amount captured should be BRL 100.00
|
@@ -1,50 +1,50 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
Before do
|
4
|
-
@client = Mundipagg::Gateway.new :test
|
5
|
-
@client.log_level = :debug
|
6
|
-
@order = Mundipagg::CreateOrderRequest.new
|
7
|
-
@boleto = Mundipagg::BoletoTransaction.new
|
8
|
-
@response = Hash.new
|
9
|
-
@order.merchantKey = TestConfiguration::Merchant::MerchantKey
|
10
|
-
$world = self
|
11
|
-
end
|
12
|
-
|
13
|
-
|
14
|
-
Given(/^I have purchase two products with a total cost of (\w+) (\d+)\.(\d+)$/) do |currency,amount,cents|
|
15
|
-
amount = amount+'.'+cents
|
16
|
-
amount = BigDecimal.new(amount.gsub(',', '.'))
|
17
|
-
@order.amountInCents = (amount * 100).to_i
|
18
|
-
@order.amountInCentsToConsiderPaid = (amount * 100).to_i
|
19
|
-
@order.currencyIsoEnum = 'BRL'
|
20
|
-
end
|
21
|
-
|
22
|
-
Given(/^I will pay using (\w+) with (\d+) days to expire$/) do |type,daysToExpire|
|
23
|
-
if type.downcase == 'boleto'
|
24
|
-
|
25
|
-
@boleto.amountInCents = @order.amountInCents
|
26
|
-
@boleto.bankNumber = 1
|
27
|
-
@boleto.nossoNumero = 989790
|
28
|
-
@boleto.transactionReference = rand(389546232)
|
29
|
-
@boleto.daysToAddInBoletoExpirationDate = daysToExpire
|
30
|
-
@boleto.instructions = 'Não receber após o vencimento'
|
31
|
-
|
32
|
-
@order.boletoTransactionCollection << @boleto
|
33
|
-
@order.creditCardTransactionCollection = nil
|
34
|
-
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
Given(/^I send to Mundipagg$/) do
|
39
|
-
@response = @client.CreateOrder(@order)
|
40
|
-
end
|
41
|
-
|
42
|
-
Then(/^The order amount in cents should be (\d+)$/) do |amountInCents|
|
43
|
-
transaction = @response[:create_order_response][:create_order_result][:boleto_transaction_result_collection][:boleto_transaction_result]
|
44
|
-
transaction[:amount_in_cents].to_s.should == amountInCents
|
45
|
-
end
|
46
|
-
|
47
|
-
Then(/^The boleto status should be (\w+)$/) do |status|
|
48
|
-
transaction = @response[:create_order_response][:create_order_result][:boleto_transaction_result_collection][:boleto_transaction_result]
|
49
|
-
transaction[:boleto_transaction_status_enum].to_s == status
|
50
|
-
end
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
Before do
|
4
|
+
@client = Mundipagg::Gateway.new :test
|
5
|
+
@client.log_level = :debug
|
6
|
+
@order = Mundipagg::CreateOrderRequest.new
|
7
|
+
@boleto = Mundipagg::BoletoTransaction.new
|
8
|
+
@response = Hash.new
|
9
|
+
@order.merchantKey = TestConfiguration::Merchant::MerchantKey
|
10
|
+
$world = self
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
Given(/^I have purchase two products with a total cost of (\w+) (\d+)\.(\d+)$/) do |currency,amount,cents|
|
15
|
+
amount = amount+'.'+cents
|
16
|
+
amount = BigDecimal.new(amount.gsub(',', '.'))
|
17
|
+
@order.amountInCents = (amount * 100).to_i
|
18
|
+
@order.amountInCentsToConsiderPaid = (amount * 100).to_i
|
19
|
+
@order.currencyIsoEnum = 'BRL'
|
20
|
+
end
|
21
|
+
|
22
|
+
Given(/^I will pay using (\w+) with (\d+) days to expire$/) do |type,daysToExpire|
|
23
|
+
if type.downcase == 'boleto'
|
24
|
+
|
25
|
+
@boleto.amountInCents = @order.amountInCents
|
26
|
+
@boleto.bankNumber = 1
|
27
|
+
@boleto.nossoNumero = 989790
|
28
|
+
@boleto.transactionReference = rand(389546232)
|
29
|
+
@boleto.daysToAddInBoletoExpirationDate = daysToExpire
|
30
|
+
@boleto.instructions = 'Não receber após o vencimento'
|
31
|
+
|
32
|
+
@order.boletoTransactionCollection << @boleto
|
33
|
+
@order.creditCardTransactionCollection = nil
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
Given(/^I send to Mundipagg$/) do
|
39
|
+
@response = @client.CreateOrder(@order)
|
40
|
+
end
|
41
|
+
|
42
|
+
Then(/^The order amount in cents should be (\d+)$/) do |amountInCents|
|
43
|
+
transaction = @response[:create_order_response][:create_order_result][:boleto_transaction_result_collection][:boleto_transaction_result]
|
44
|
+
transaction[:amount_in_cents].to_s.should == amountInCents
|
45
|
+
end
|
46
|
+
|
47
|
+
Then(/^The boleto status should be (\w+)$/) do |status|
|
48
|
+
transaction = @response[:create_order_response][:create_order_result][:boleto_transaction_result_collection][:boleto_transaction_result]
|
49
|
+
transaction[:boleto_transaction_status_enum].to_s == status
|
50
|
+
end
|
@@ -1,167 +1,167 @@
|
|
1
|
-
|
2
|
-
#Scenario 1:
|
3
|
-
Before do
|
4
|
-
|
5
|
-
@client = Mundipagg::Gateway.new :test
|
6
|
-
@client.log_level = :debug
|
7
|
-
@order = Mundipagg::CreateOrderRequest.new
|
8
|
-
@order.merchantKey = TestConfiguration::Merchant::MerchantKey
|
9
|
-
@transaction = Mundipagg::CreditCardTransaction.new
|
10
|
-
@order.creditCardTransactionCollection << @transaction
|
11
|
-
@buyer = Mundipagg::Buyer.new
|
12
|
-
@response = Hash.new
|
13
|
-
@shoppingCart = Mundipagg::ShoppingCart.new
|
14
|
-
@shoppingCartItem = Mundipagg::ShoppingCartItem.new
|
15
|
-
@order.shoppingCartCollection << @shoppingCart
|
16
|
-
|
17
|
-
end
|
18
|
-
|
19
|
-
|
20
|
-
Given(/^I have purchase three products with a total cost of (\w+) (\d+)$/) do |currency,amount|
|
21
|
-
amount = BigDecimal.new(amount.gsub(',', '.'))
|
22
|
-
@order.amountInCents = (amount * 100).to_i
|
23
|
-
@order.amountInCentsToConsiderPaid = (amount * 100).to_i
|
24
|
-
@order.currencyIsoEnum = 'BRL'
|
25
|
-
end
|
26
|
-
|
27
|
-
Given(/^I have purchase three products with Shopping Cart a total cost of (\w+) (\d+)$/) do |currency,amount|
|
28
|
-
amount = BigDecimal.new(amount.gsub(',', '.'))
|
29
|
-
@order.amountInCents = (amount * 100).to_i
|
30
|
-
@order.amountInCentsToConsiderPaid = (amount * 100).to_i
|
31
|
-
@order.currencyIsoEnum = 'BRL'
|
32
|
-
|
33
|
-
@shoppingCartItem.itemReference = 'Test'
|
34
|
-
@shoppingCartItem.description = 'Test'
|
35
|
-
@shoppingCartItem.name = 'Test'
|
36
|
-
@shoppingCartItem.quantity = 3
|
37
|
-
@shoppingCartItem.totalCostInCents = 3000
|
38
|
-
@shoppingCartItem.unitCostInCents = 1000
|
39
|
-
|
40
|
-
|
41
|
-
@shoppingCart.freightCostInCents = 30
|
42
|
-
@shoppingCart.shoppingCartItemCollection << @shoppingCartItem
|
43
|
-
|
44
|
-
@order.shoppingCartCollection << @shoppingCart
|
45
|
-
|
46
|
-
end
|
47
|
-
|
48
|
-
|
49
|
-
Given(/^I have purchase three products with Buyer data and a total cost of (\w+) (\d+)$/) do |currency,amount|
|
50
|
-
amount = BigDecimal.new(amount.gsub(',', '.'))
|
51
|
-
@order.amountInCents = (amount * 100).to_i
|
52
|
-
@order.amountInCentsToConsiderPaid = (amount * 100).to_i
|
53
|
-
@order.currencyIsoEnum = 'BRL'
|
54
|
-
|
55
|
-
@buyer.buyerReference = 'Test'
|
56
|
-
@buyer.email = 'a@a.com'
|
57
|
-
@buyer.homePhone = '999999999'
|
58
|
-
@buyer.mobilePhone = '999999999'
|
59
|
-
@buyer.workPhone = '999999999'
|
60
|
-
@buyer.name = 'Test'
|
61
|
-
@buyer.taxDocumentNumber = '02156968975'
|
62
|
-
|
63
|
-
|
64
|
-
@order.buyer = @buyer
|
65
|
-
end
|
66
|
-
|
67
|
-
|
68
|
-
Given(/^I will pay using a (\w+) credit card in (\d+) installments$/) do |brand,installments|
|
69
|
-
@transaction.creditCardBrandEnum = brand
|
70
|
-
@transaction.installmentCount = installments
|
71
|
-
@transaction.paymentMethodCode = 1
|
72
|
-
@transaction.amountInCents = @order.amountInCents
|
73
|
-
@transaction.holderName = 'Ruby Unit Test'
|
74
|
-
@transaction.creditCardNumber = '41111111111111111'
|
75
|
-
@transaction.securityCode = '123'
|
76
|
-
@transaction.expirationMonth = 5
|
77
|
-
@transaction.expirationYear = 2018
|
78
|
-
@transaction.creditCardOperationEnum = Mundipagg::CreditCardTransaction.OperationEnum[:AuthAndCapture]
|
79
|
-
end
|
80
|
-
|
81
|
-
Given(/^I will send to Mundipagg$/) do
|
82
|
-
old_stdout = $stdout
|
83
|
-
@stdout = StringIO.new
|
84
|
-
$stdout = @stdout
|
85
|
-
@client.log_level = :debug
|
86
|
-
begin
|
87
|
-
@response = @client.CreateOrder(@order)
|
88
|
-
ensure
|
89
|
-
$stdout = old_stdout
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
Then(/^the order amount in cents should be (\d+)$/) do |amountInCents|
|
94
|
-
|
95
|
-
transaction = @response[:create_order_response][:create_order_result][:credit_card_transaction_result_collection][:credit_card_transaction_result]
|
96
|
-
transaction[:amount_in_cents].to_s.should == amountInCents
|
97
|
-
end
|
98
|
-
|
99
|
-
Then(/^the transaction status should be (\w+)$/) do |status|
|
100
|
-
transaction = @response[:create_order_response][:create_order_result][:credit_card_transaction_result_collection][:credit_card_transaction_result]
|
101
|
-
transaction[:credit_card_transaction_status_enum].to_s.downcase.should == status.downcase
|
102
|
-
end
|
103
|
-
|
104
|
-
|
105
|
-
#Scenario 2:
|
106
|
-
|
107
|
-
Given(/^I have purchase three products with a total cost of (\w+) (\d+),(\d+)$/) do |currency, amount, cents|
|
108
|
-
amount = amount+'.'+cents
|
109
|
-
amount = BigDecimal.new(amount.gsub(',', '.'))
|
110
|
-
@order.amountInCents = (amount * 100).to_i
|
111
|
-
@order.amountInCentsToConsiderPaid = (amount * 100).to_i
|
112
|
-
@order.currencyIsoEnum = currency
|
113
|
-
|
114
|
-
end
|
115
|
-
|
116
|
-
Given(/^I will pay using a (\w+) credit card without installment$/) do |brand|
|
117
|
-
@transaction.creditCardBrandEnum = brand
|
118
|
-
@transaction.installmentCount = 1
|
119
|
-
@transaction.paymentMethodCode = 1
|
120
|
-
@transaction.amountInCents = @order.amountInCents
|
121
|
-
@transaction.holderName = 'Ruby Unit Test'
|
122
|
-
@transaction.creditCardNumber = '41111111111111111'
|
123
|
-
@transaction.securityCode = '123'
|
124
|
-
@transaction.expirationMonth = 5
|
125
|
-
@transaction.expirationYear = 2018
|
126
|
-
@transaction.creditCardOperationEnum = Mundipagg::CreditCardTransaction.OperationEnum[:AuthAndCapture]
|
127
|
-
|
128
|
-
end
|
129
|
-
|
130
|
-
#Scenario 3:
|
131
|
-
|
132
|
-
Then(/^the log file doesn't contain sensible information$/) do
|
133
|
-
@stdout.string.should_not include(@transaction.creditCardNumber)
|
134
|
-
@stdout.string.should_not include(@transaction.securityCode)
|
135
|
-
@stdout.string.should_not include(@order.merchantKey)
|
136
|
-
end
|
137
|
-
|
138
|
-
#Scenario 4:
|
139
|
-
When(/^I pay another order with the instant buy key$/) do
|
140
|
-
@order = Mundipagg::CreateOrderRequest.new
|
141
|
-
@order.merchantKey = TestConfiguration::Merchant::MerchantKey
|
142
|
-
amount = 100
|
143
|
-
@transaction = Mundipagg::CreditCardTransaction.new
|
144
|
-
@order.creditCardTransactionCollection << @transaction
|
145
|
-
|
146
|
-
@order.amountInCents = (amount * 100).to_i
|
147
|
-
@order.amountInCentsToConsiderPaid = (amount * 100).to_i
|
148
|
-
@order.currencyIsoEnum = 'BRL'
|
149
|
-
|
150
|
-
@transaction.creditCardBrandEnum = 'Visa'
|
151
|
-
@transaction.instantBuyKey = @response[:create_order_response][:create_order_result][:credit_card_transaction_result_collection][:credit_card_transaction_result][:instant_buy_key]
|
152
|
-
@transaction.installmentCount = 1
|
153
|
-
@transaction.paymentMethodCode = 1
|
154
|
-
@transaction.amountInCents = @order.amountInCents
|
155
|
-
@transaction.creditCardOperationEnum = Mundipagg::CreditCardTransaction.OperationEnum[:AuthAndCapture]
|
156
|
-
|
157
|
-
old_stdout = $stdout
|
158
|
-
@stdout = StringIO.new
|
159
|
-
$stdout = @stdout
|
160
|
-
@client.log_level = :debug
|
161
|
-
begin
|
162
|
-
@response = @client.CreateOrder(@order)
|
163
|
-
ensure
|
164
|
-
$stdout = old_stdout
|
165
|
-
end
|
166
|
-
end
|
167
|
-
|
1
|
+
|
2
|
+
#Scenario 1:
|
3
|
+
Before do
|
4
|
+
|
5
|
+
@client = Mundipagg::Gateway.new :test
|
6
|
+
@client.log_level = :debug
|
7
|
+
@order = Mundipagg::CreateOrderRequest.new
|
8
|
+
@order.merchantKey = TestConfiguration::Merchant::MerchantKey
|
9
|
+
@transaction = Mundipagg::CreditCardTransaction.new
|
10
|
+
@order.creditCardTransactionCollection << @transaction
|
11
|
+
@buyer = Mundipagg::Buyer.new
|
12
|
+
@response = Hash.new
|
13
|
+
@shoppingCart = Mundipagg::ShoppingCart.new
|
14
|
+
@shoppingCartItem = Mundipagg::ShoppingCartItem.new
|
15
|
+
@order.shoppingCartCollection << @shoppingCart
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
Given(/^I have purchase three products with a total cost of (\w+) (\d+)$/) do |currency,amount|
|
21
|
+
amount = BigDecimal.new(amount.gsub(',', '.'))
|
22
|
+
@order.amountInCents = (amount * 100).to_i
|
23
|
+
@order.amountInCentsToConsiderPaid = (amount * 100).to_i
|
24
|
+
@order.currencyIsoEnum = 'BRL'
|
25
|
+
end
|
26
|
+
|
27
|
+
Given(/^I have purchase three products with Shopping Cart a total cost of (\w+) (\d+)$/) do |currency,amount|
|
28
|
+
amount = BigDecimal.new(amount.gsub(',', '.'))
|
29
|
+
@order.amountInCents = (amount * 100).to_i
|
30
|
+
@order.amountInCentsToConsiderPaid = (amount * 100).to_i
|
31
|
+
@order.currencyIsoEnum = 'BRL'
|
32
|
+
|
33
|
+
@shoppingCartItem.itemReference = 'Test'
|
34
|
+
@shoppingCartItem.description = 'Test'
|
35
|
+
@shoppingCartItem.name = 'Test'
|
36
|
+
@shoppingCartItem.quantity = 3
|
37
|
+
@shoppingCartItem.totalCostInCents = 3000
|
38
|
+
@shoppingCartItem.unitCostInCents = 1000
|
39
|
+
|
40
|
+
|
41
|
+
@shoppingCart.freightCostInCents = 30
|
42
|
+
@shoppingCart.shoppingCartItemCollection << @shoppingCartItem
|
43
|
+
|
44
|
+
@order.shoppingCartCollection << @shoppingCart
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
|
49
|
+
Given(/^I have purchase three products with Buyer data and a total cost of (\w+) (\d+)$/) do |currency,amount|
|
50
|
+
amount = BigDecimal.new(amount.gsub(',', '.'))
|
51
|
+
@order.amountInCents = (amount * 100).to_i
|
52
|
+
@order.amountInCentsToConsiderPaid = (amount * 100).to_i
|
53
|
+
@order.currencyIsoEnum = 'BRL'
|
54
|
+
|
55
|
+
@buyer.buyerReference = 'Test'
|
56
|
+
@buyer.email = 'a@a.com'
|
57
|
+
@buyer.homePhone = '999999999'
|
58
|
+
@buyer.mobilePhone = '999999999'
|
59
|
+
@buyer.workPhone = '999999999'
|
60
|
+
@buyer.name = 'Test'
|
61
|
+
@buyer.taxDocumentNumber = '02156968975'
|
62
|
+
|
63
|
+
|
64
|
+
@order.buyer = @buyer
|
65
|
+
end
|
66
|
+
|
67
|
+
|
68
|
+
Given(/^I will pay using a (\w+) credit card in (\d+) installments$/) do |brand,installments|
|
69
|
+
@transaction.creditCardBrandEnum = brand
|
70
|
+
@transaction.installmentCount = installments
|
71
|
+
@transaction.paymentMethodCode = 1
|
72
|
+
@transaction.amountInCents = @order.amountInCents
|
73
|
+
@transaction.holderName = 'Ruby Unit Test'
|
74
|
+
@transaction.creditCardNumber = '41111111111111111'
|
75
|
+
@transaction.securityCode = '123'
|
76
|
+
@transaction.expirationMonth = 5
|
77
|
+
@transaction.expirationYear = 2018
|
78
|
+
@transaction.creditCardOperationEnum = Mundipagg::CreditCardTransaction.OperationEnum[:AuthAndCapture]
|
79
|
+
end
|
80
|
+
|
81
|
+
Given(/^I will send to Mundipagg$/) do
|
82
|
+
old_stdout = $stdout
|
83
|
+
@stdout = StringIO.new
|
84
|
+
$stdout = @stdout
|
85
|
+
@client.log_level = :debug
|
86
|
+
begin
|
87
|
+
@response = @client.CreateOrder(@order)
|
88
|
+
ensure
|
89
|
+
$stdout = old_stdout
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
Then(/^the order amount in cents should be (\d+)$/) do |amountInCents|
|
94
|
+
|
95
|
+
transaction = @response[:create_order_response][:create_order_result][:credit_card_transaction_result_collection][:credit_card_transaction_result]
|
96
|
+
transaction[:amount_in_cents].to_s.should == amountInCents
|
97
|
+
end
|
98
|
+
|
99
|
+
Then(/^the transaction status should be (\w+)$/) do |status|
|
100
|
+
transaction = @response[:create_order_response][:create_order_result][:credit_card_transaction_result_collection][:credit_card_transaction_result]
|
101
|
+
transaction[:credit_card_transaction_status_enum].to_s.downcase.should == status.downcase
|
102
|
+
end
|
103
|
+
|
104
|
+
|
105
|
+
#Scenario 2:
|
106
|
+
|
107
|
+
Given(/^I have purchase three products with a total cost of (\w+) (\d+),(\d+)$/) do |currency, amount, cents|
|
108
|
+
amount = amount+'.'+cents
|
109
|
+
amount = BigDecimal.new(amount.gsub(',', '.'))
|
110
|
+
@order.amountInCents = (amount * 100).to_i
|
111
|
+
@order.amountInCentsToConsiderPaid = (amount * 100).to_i
|
112
|
+
@order.currencyIsoEnum = currency
|
113
|
+
|
114
|
+
end
|
115
|
+
|
116
|
+
Given(/^I will pay using a (\w+) credit card without installment$/) do |brand|
|
117
|
+
@transaction.creditCardBrandEnum = brand
|
118
|
+
@transaction.installmentCount = 1
|
119
|
+
@transaction.paymentMethodCode = 1
|
120
|
+
@transaction.amountInCents = @order.amountInCents
|
121
|
+
@transaction.holderName = 'Ruby Unit Test'
|
122
|
+
@transaction.creditCardNumber = '41111111111111111'
|
123
|
+
@transaction.securityCode = '123'
|
124
|
+
@transaction.expirationMonth = 5
|
125
|
+
@transaction.expirationYear = 2018
|
126
|
+
@transaction.creditCardOperationEnum = Mundipagg::CreditCardTransaction.OperationEnum[:AuthAndCapture]
|
127
|
+
|
128
|
+
end
|
129
|
+
|
130
|
+
#Scenario 3:
|
131
|
+
|
132
|
+
Then(/^the log file doesn't contain sensible information$/) do
|
133
|
+
@stdout.string.should_not include(@transaction.creditCardNumber)
|
134
|
+
@stdout.string.should_not include(@transaction.securityCode)
|
135
|
+
@stdout.string.should_not include(@order.merchantKey)
|
136
|
+
end
|
137
|
+
|
138
|
+
#Scenario 4:
|
139
|
+
When(/^I pay another order with the instant buy key$/) do
|
140
|
+
@order = Mundipagg::CreateOrderRequest.new
|
141
|
+
@order.merchantKey = TestConfiguration::Merchant::MerchantKey
|
142
|
+
amount = 100
|
143
|
+
@transaction = Mundipagg::CreditCardTransaction.new
|
144
|
+
@order.creditCardTransactionCollection << @transaction
|
145
|
+
|
146
|
+
@order.amountInCents = (amount * 100).to_i
|
147
|
+
@order.amountInCentsToConsiderPaid = (amount * 100).to_i
|
148
|
+
@order.currencyIsoEnum = 'BRL'
|
149
|
+
|
150
|
+
@transaction.creditCardBrandEnum = 'Visa'
|
151
|
+
@transaction.instantBuyKey = @response[:create_order_response][:create_order_result][:credit_card_transaction_result_collection][:credit_card_transaction_result][:instant_buy_key]
|
152
|
+
@transaction.installmentCount = 1
|
153
|
+
@transaction.paymentMethodCode = 1
|
154
|
+
@transaction.amountInCents = @order.amountInCents
|
155
|
+
@transaction.creditCardOperationEnum = Mundipagg::CreditCardTransaction.OperationEnum[:AuthAndCapture]
|
156
|
+
|
157
|
+
old_stdout = $stdout
|
158
|
+
@stdout = StringIO.new
|
159
|
+
$stdout = @stdout
|
160
|
+
@client.log_level = :debug
|
161
|
+
begin
|
162
|
+
@response = @client.CreateOrder(@order)
|
163
|
+
ensure
|
164
|
+
$stdout = old_stdout
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|