mundipagg_sdk 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +61 -61
- data/lib/gateway/Address/billing_address.rb +32 -32
- data/lib/gateway/Address/buyer_address.rb +36 -36
- data/lib/gateway/Address/delivery_address.rb +32 -32
- data/lib/gateway/AntiFraud/anti_fraud_analysis_result.rb +47 -47
- data/lib/gateway/AntiFraud/query_sale_anti_fraud_analysis_data.rb +51 -51
- data/lib/gateway/AntiFraud/query_sale_anti_fraud_analysis_history_data.rb +41 -41
- data/lib/gateway/BaseRequest.rb +10 -10
- data/lib/gateway/BaseResponse.rb +17 -17
- data/lib/gateway/BoletoTransaction/boleto_transaction.rb +43 -43
- data/lib/gateway/BoletoTransaction/boleto_transaction_data.rb +43 -43
- data/lib/gateway/BoletoTransaction/boleto_transaction_options.rb +14 -14
- data/lib/gateway/BoletoTransaction/boleto_transaction_report_file.rb +19 -19
- data/lib/gateway/BoletoTransaction/boleto_transaction_result.rb +34 -34
- data/lib/gateway/CreditCardTransaction/credit_card.rb +29 -29
- data/lib/gateway/CreditCardTransaction/credit_card_transaction.rb +31 -31
- data/lib/gateway/CreditCardTransaction/credit_card_transaction_data.rb +103 -103
- data/lib/gateway/CreditCardTransaction/credit_card_transaction_options.rb +26 -26
- data/lib/gateway/CreditCardTransaction/credit_card_transaction_report_file.rb +28 -28
- data/lib/gateway/CreditCardTransaction/manage_credit_card_transaction.rb +11 -11
- data/lib/gateway/CreditCardTransaction/retry_sale_credit_card_transaction.rb +12 -12
- data/lib/gateway/ErrorItem.rb +17 -17
- data/lib/gateway/ErrorReport.rb +18 -18
- data/lib/gateway/Gateway.rb +441 -444
- data/lib/gateway/InstantBuy/credit_card_data.rb +40 -40
- data/lib/gateway/InstantBuy/get_instant_buy_data_response.rb +17 -17
- data/lib/gateway/Merchant/merchant.rb +10 -10
- data/lib/gateway/OnlineDebit/online_debit_transaction_report_file.rb +17 -17
- data/lib/gateway/Order/order.rb +10 -10
- data/lib/gateway/Order/order_transaction_report_file.rb +5 -5
- data/lib/gateway/Parsers/boleto_transaction_parser.rb +30 -30
- data/lib/gateway/Parsers/credit_card_transaction_parser.rb +39 -39
- data/lib/gateway/Parsers/header_parser.rb +13 -13
- data/lib/gateway/Parsers/online_debit_transaction_parser.rb +29 -29
- data/lib/gateway/Parsers/trailer_parser.rb +14 -14
- data/lib/gateway/Person/buyer.rb +32 -32
- data/lib/gateway/Person/person.rb +46 -46
- data/lib/gateway/Recurrency/recurrency.rb +22 -22
- data/lib/gateway/Sale/create_sale_request.rb +35 -35
- data/lib/gateway/Sale/create_sale_response.rb +24 -24
- data/lib/gateway/Sale/manage_sale_request.rb +16 -16
- data/lib/gateway/Sale/manage_sale_response.rb +14 -14
- data/lib/gateway/Sale/query_sale_request.rb +35 -35
- data/lib/gateway/Sale/query_sale_response.rb +17 -17
- data/lib/gateway/Sale/request_data.rb +19 -19
- data/lib/gateway/Sale/retry_sale_options.rb +13 -13
- data/lib/gateway/Sale/retry_sale_request.rb +21 -21
- data/lib/gateway/Sale/retry_sale_response.rb +13 -13
- data/lib/gateway/Sale/sale_data.rb +32 -32
- data/lib/gateway/Sale/sale_order_data.rb +16 -16
- data/lib/gateway/SalesOption.rb +17 -17
- data/lib/gateway/ShoppingCart/shopping_cart.rb +25 -25
- data/lib/gateway/ShoppingCart/shopping_cart_item.rb +22 -22
- data/lib/gateway/Trailer.rb +5 -5
- data/lib/gateway/address.rb +24 -24
- data/lib/gateway/header.rb +4 -4
- data/lib/gateway/post_notification.rb +28 -28
- data/lib/gateway/transaction_report_file.rb +44 -44
- data/lib/mundipagg_sdk.rb +70 -70
- data/mundipagg_sdk.gemspec +18 -18
- data/spec/integration/gateway_spec.rb +733 -651
- data/spec/integration/test_helper.rb +68 -68
- metadata +2 -2
data/lib/gateway/header.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
class Header
|
2
|
-
attr_accessor :TransactionProcessedDate
|
3
|
-
attr_accessor :ReportFileCreateDate
|
4
|
-
attr_accessor :Version
|
1
|
+
class Header
|
2
|
+
attr_accessor :TransactionProcessedDate
|
3
|
+
attr_accessor :ReportFileCreateDate
|
4
|
+
attr_accessor :Version
|
5
5
|
end
|
@@ -1,29 +1,29 @@
|
|
1
|
-
require 'nori'
|
2
|
-
|
3
|
-
# Class who handles Gateway post notification XML
|
4
|
-
class PostNotification
|
5
|
-
|
6
|
-
# This method parse the Xml sent by Gateway when notify a change in a transaction.
|
7
|
-
#
|
8
|
-
# @param request [String] XML received in the Gateway POST request.
|
9
|
-
# @return [Hash<Symbol, String>] A hash collection containing the XML data parsed.
|
10
|
-
def self.ParseNotification(xml)
|
11
|
-
|
12
|
-
nori = Nori.new(:convert_tags_to => lambda { |tag| PostNotification.to_underscore(tag).to_sym })
|
13
|
-
xml_hash = nori.parse(CGI::unescapeHTML(xml))
|
14
|
-
|
15
|
-
return xml_hash
|
16
|
-
end
|
17
|
-
|
18
|
-
# Converts a string in Camel Case format to lower case with underscore.
|
19
|
-
#
|
20
|
-
# @param Example: 'StatusNotification' outputs 'status_notification'
|
21
|
-
# @returns [String] lower case string separated with underscore
|
22
|
-
def self.to_underscore(camel_case_string)
|
23
|
-
return camel_case_string.gsub(/::/, '/').
|
24
|
-
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
|
25
|
-
gsub(/([a-z\d])([A-Z])/,'\1_\2').
|
26
|
-
tr("-", "_").
|
27
|
-
downcase
|
28
|
-
end
|
1
|
+
require 'nori'
|
2
|
+
|
3
|
+
# Class who handles Gateway post notification XML
|
4
|
+
class PostNotification
|
5
|
+
|
6
|
+
# This method parse the Xml sent by Gateway when notify a change in a transaction.
|
7
|
+
#
|
8
|
+
# @param request [String] XML received in the Gateway POST request.
|
9
|
+
# @return [Hash<Symbol, String>] A hash collection containing the XML data parsed.
|
10
|
+
def self.ParseNotification(xml)
|
11
|
+
|
12
|
+
nori = Nori.new(:convert_tags_to => lambda { |tag| PostNotification.to_underscore(tag).to_sym })
|
13
|
+
xml_hash = nori.parse(CGI::unescapeHTML(xml))
|
14
|
+
|
15
|
+
return xml_hash
|
16
|
+
end
|
17
|
+
|
18
|
+
# Converts a string in Camel Case format to lower case with underscore.
|
19
|
+
#
|
20
|
+
# @param Example: 'StatusNotification' outputs 'status_notification'
|
21
|
+
# @returns [String] lower case string separated with underscore
|
22
|
+
def self.to_underscore(camel_case_string)
|
23
|
+
return camel_case_string.gsub(/::/, '/').
|
24
|
+
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
|
25
|
+
gsub(/([a-z\d])([A-Z])/,'\1_\2').
|
26
|
+
tr("-", "_").
|
27
|
+
downcase
|
28
|
+
end
|
29
29
|
end
|
@@ -1,45 +1,45 @@
|
|
1
|
-
class TransactionReportFile
|
2
|
-
def TransactionReportFileParser(file_to_parse)
|
3
|
-
response = {}
|
4
|
-
response['CreditCardTransaction'] = []
|
5
|
-
response['OnlineDebitTransaction'] = []
|
6
|
-
response['BoletoTransaction'] = []
|
7
|
-
|
8
|
-
header_parser = HeaderParser.new
|
9
|
-
credit_card_parser = CreditCardTransactionParser.new
|
10
|
-
boleto_parser = BoletoTransactionParser.new
|
11
|
-
online_debit_parser = OnlineDebitTransactionParser.new
|
12
|
-
trailer_parser = TrailerParser.new
|
13
|
-
|
14
|
-
begin
|
15
|
-
response_splited = file_to_parse.split("\n")
|
16
|
-
|
17
|
-
response_splited.each do |item|
|
18
|
-
|
19
|
-
to_parse_item = item.split(',')
|
20
|
-
if to_parse_item[0] == '01'
|
21
|
-
response['Header'] = header_parser.Parse(to_parse_item)
|
22
|
-
end
|
23
|
-
|
24
|
-
if to_parse_item[0] == '20'
|
25
|
-
response['CreditCardTransaction'] << credit_card_parser.Parse(to_parse_item)
|
26
|
-
end
|
27
|
-
|
28
|
-
if to_parse_item[0] == '40'
|
29
|
-
response['OnlineDebitTransaction'] << online_debit_parser.Parse(to_parse_item)
|
30
|
-
end
|
31
|
-
|
32
|
-
if to_parse_item[0] == '30'
|
33
|
-
response['BoletoTransaction'] << boleto_parser.Parse(to_parse_item)
|
34
|
-
end
|
35
|
-
|
36
|
-
if to_parse_item[0] == '99'
|
37
|
-
response['Trailer'] = trailer_parser.Parse(to_parse_item)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
rescue Exception=>err
|
41
|
-
return err
|
42
|
-
end
|
43
|
-
return response
|
44
|
-
end
|
1
|
+
class TransactionReportFile
|
2
|
+
def TransactionReportFileParser(file_to_parse)
|
3
|
+
response = {}
|
4
|
+
response['CreditCardTransaction'] = []
|
5
|
+
response['OnlineDebitTransaction'] = []
|
6
|
+
response['BoletoTransaction'] = []
|
7
|
+
|
8
|
+
header_parser = HeaderParser.new
|
9
|
+
credit_card_parser = CreditCardTransactionParser.new
|
10
|
+
boleto_parser = BoletoTransactionParser.new
|
11
|
+
online_debit_parser = OnlineDebitTransactionParser.new
|
12
|
+
trailer_parser = TrailerParser.new
|
13
|
+
|
14
|
+
begin
|
15
|
+
response_splited = file_to_parse.split("\n")
|
16
|
+
|
17
|
+
response_splited.each do |item|
|
18
|
+
|
19
|
+
to_parse_item = item.split(',')
|
20
|
+
if to_parse_item[0] == '01'
|
21
|
+
response['Header'] = header_parser.Parse(to_parse_item)
|
22
|
+
end
|
23
|
+
|
24
|
+
if to_parse_item[0] == '20'
|
25
|
+
response['CreditCardTransaction'] << credit_card_parser.Parse(to_parse_item)
|
26
|
+
end
|
27
|
+
|
28
|
+
if to_parse_item[0] == '40'
|
29
|
+
response['OnlineDebitTransaction'] << online_debit_parser.Parse(to_parse_item)
|
30
|
+
end
|
31
|
+
|
32
|
+
if to_parse_item[0] == '30'
|
33
|
+
response['BoletoTransaction'] << boleto_parser.Parse(to_parse_item)
|
34
|
+
end
|
35
|
+
|
36
|
+
if to_parse_item[0] == '99'
|
37
|
+
response['Trailer'] = trailer_parser.Parse(to_parse_item)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
rescue Exception=>err
|
41
|
+
return err
|
42
|
+
end
|
43
|
+
return response
|
44
|
+
end
|
45
45
|
end
|
data/lib/mundipagg_sdk.rb
CHANGED
@@ -1,70 +1,70 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'bundler/setup'
|
3
|
-
|
4
|
-
require 'json'
|
5
|
-
require 'rest-client'
|
6
|
-
require 'nori'
|
7
|
-
require 'rspec'
|
8
|
-
require 'rexml/document'
|
9
|
-
|
10
|
-
require_relative 'gateway/address'
|
11
|
-
require_relative 'gateway/Address/billing_address'
|
12
|
-
require_relative 'gateway/Address/buyer_address'
|
13
|
-
require_relative 'gateway/Address/delivery_address'
|
14
|
-
|
15
|
-
require_relative 'gateway/AntiFraud/anti_fraud_analysis_result'
|
16
|
-
require_relative 'gateway/AntiFraud/query_sale_anti_fraud_analysis_data'
|
17
|
-
require_relative 'gateway/AntiFraud/query_sale_anti_fraud_analysis_history_data'
|
18
|
-
|
19
|
-
require_relative 'gateway/BoletoTransaction/boleto_transaction'
|
20
|
-
require_relative 'gateway/BoletoTransaction/boleto_transaction_data'
|
21
|
-
require_relative 'gateway/BoletoTransaction/boleto_transaction_options'
|
22
|
-
require_relative 'gateway/BoletoTransaction/boleto_transaction_result'
|
23
|
-
require_relative 'gateway/BoletoTransaction/boleto_transaction_report_file'
|
24
|
-
|
25
|
-
require_relative 'gateway/CreditCardTransaction/credit_card'
|
26
|
-
require_relative 'gateway/CreditCardTransaction/credit_card_transaction'
|
27
|
-
require_relative 'gateway/CreditCardTransaction/credit_card_transaction_data'
|
28
|
-
require_relative 'gateway/CreditCardTransaction/credit_card_transaction_options'
|
29
|
-
require_relative 'gateway/CreditCardTransaction/manage_credit_card_transaction'
|
30
|
-
require_relative 'gateway/CreditCardTransaction/retry_sale_credit_card_transaction'
|
31
|
-
require_relative 'gateway/CreditCardTransaction/credit_card_transaction_report_file'
|
32
|
-
|
33
|
-
require_relative 'gateway/InstantBuy/credit_card_data'
|
34
|
-
require_relative 'gateway/InstantBuy/get_instant_buy_data_response'
|
35
|
-
|
36
|
-
require_relative 'gateway/Merchant/merchant'
|
37
|
-
|
38
|
-
require_relative 'gateway/Order/order'
|
39
|
-
require_relative 'gateway/Order/order_transaction_report_file'
|
40
|
-
|
41
|
-
require_relative 'gateway/OnlineDebit/online_debit_transaction_report_file'
|
42
|
-
|
43
|
-
require_relative 'gateway/Parsers/boleto_transaction_parser'
|
44
|
-
require_relative 'gateway/Parsers/credit_card_transaction_parser'
|
45
|
-
require_relative 'gateway/Parsers/online_debit_transaction_parser'
|
46
|
-
require_relative 'gateway/Parsers/header_parser'
|
47
|
-
require_relative 'gateway/Parsers/trailer_parser'
|
48
|
-
|
49
|
-
require_relative 'gateway/Person/buyer'
|
50
|
-
require_relative 'gateway/Person/person'
|
51
|
-
|
52
|
-
require_relative 'gateway/Recurrency/recurrency'
|
53
|
-
|
54
|
-
require_relative 'gateway/Sale/create_sale_request'
|
55
|
-
require_relative 'gateway/Sale/manage_sale_request'
|
56
|
-
require_relative 'gateway/Sale/query_sale_request'
|
57
|
-
require_relative 'gateway/Sale/request_data'
|
58
|
-
require_relative 'gateway/Sale/retry_sale_options'
|
59
|
-
require_relative 'gateway/Sale/retry_sale_request'
|
60
|
-
require_relative 'gateway/Sale/sale_data'
|
61
|
-
|
62
|
-
require_relative 'gateway/ShoppingCart/shopping_cart'
|
63
|
-
require_relative 'gateway/ShoppingCart/shopping_cart_item'
|
64
|
-
|
65
|
-
require_relative 'gateway/SalesOption'
|
66
|
-
require_relative 'gateway/post_notification'
|
67
|
-
require_relative 'gateway/Gateway'
|
68
|
-
require_relative 'gateway/header'
|
69
|
-
require_relative 'gateway/Trailer'
|
70
|
-
require_relative 'gateway/transaction_report_file'
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler/setup'
|
3
|
+
|
4
|
+
require 'json'
|
5
|
+
require 'rest-client'
|
6
|
+
require 'nori'
|
7
|
+
require 'rspec'
|
8
|
+
require 'rexml/document'
|
9
|
+
|
10
|
+
require_relative 'gateway/address'
|
11
|
+
require_relative 'gateway/Address/billing_address'
|
12
|
+
require_relative 'gateway/Address/buyer_address'
|
13
|
+
require_relative 'gateway/Address/delivery_address'
|
14
|
+
|
15
|
+
require_relative 'gateway/AntiFraud/anti_fraud_analysis_result'
|
16
|
+
require_relative 'gateway/AntiFraud/query_sale_anti_fraud_analysis_data'
|
17
|
+
require_relative 'gateway/AntiFraud/query_sale_anti_fraud_analysis_history_data'
|
18
|
+
|
19
|
+
require_relative 'gateway/BoletoTransaction/boleto_transaction'
|
20
|
+
require_relative 'gateway/BoletoTransaction/boleto_transaction_data'
|
21
|
+
require_relative 'gateway/BoletoTransaction/boleto_transaction_options'
|
22
|
+
require_relative 'gateway/BoletoTransaction/boleto_transaction_result'
|
23
|
+
require_relative 'gateway/BoletoTransaction/boleto_transaction_report_file'
|
24
|
+
|
25
|
+
require_relative 'gateway/CreditCardTransaction/credit_card'
|
26
|
+
require_relative 'gateway/CreditCardTransaction/credit_card_transaction'
|
27
|
+
require_relative 'gateway/CreditCardTransaction/credit_card_transaction_data'
|
28
|
+
require_relative 'gateway/CreditCardTransaction/credit_card_transaction_options'
|
29
|
+
require_relative 'gateway/CreditCardTransaction/manage_credit_card_transaction'
|
30
|
+
require_relative 'gateway/CreditCardTransaction/retry_sale_credit_card_transaction'
|
31
|
+
require_relative 'gateway/CreditCardTransaction/credit_card_transaction_report_file'
|
32
|
+
|
33
|
+
require_relative 'gateway/InstantBuy/credit_card_data'
|
34
|
+
require_relative 'gateway/InstantBuy/get_instant_buy_data_response'
|
35
|
+
|
36
|
+
require_relative 'gateway/Merchant/merchant'
|
37
|
+
|
38
|
+
require_relative 'gateway/Order/order'
|
39
|
+
require_relative 'gateway/Order/order_transaction_report_file'
|
40
|
+
|
41
|
+
require_relative 'gateway/OnlineDebit/online_debit_transaction_report_file'
|
42
|
+
|
43
|
+
require_relative 'gateway/Parsers/boleto_transaction_parser'
|
44
|
+
require_relative 'gateway/Parsers/credit_card_transaction_parser'
|
45
|
+
require_relative 'gateway/Parsers/online_debit_transaction_parser'
|
46
|
+
require_relative 'gateway/Parsers/header_parser'
|
47
|
+
require_relative 'gateway/Parsers/trailer_parser'
|
48
|
+
|
49
|
+
require_relative 'gateway/Person/buyer'
|
50
|
+
require_relative 'gateway/Person/person'
|
51
|
+
|
52
|
+
require_relative 'gateway/Recurrency/recurrency'
|
53
|
+
|
54
|
+
require_relative 'gateway/Sale/create_sale_request'
|
55
|
+
require_relative 'gateway/Sale/manage_sale_request'
|
56
|
+
require_relative 'gateway/Sale/query_sale_request'
|
57
|
+
require_relative 'gateway/Sale/request_data'
|
58
|
+
require_relative 'gateway/Sale/retry_sale_options'
|
59
|
+
require_relative 'gateway/Sale/retry_sale_request'
|
60
|
+
require_relative 'gateway/Sale/sale_data'
|
61
|
+
|
62
|
+
require_relative 'gateway/ShoppingCart/shopping_cart'
|
63
|
+
require_relative 'gateway/ShoppingCart/shopping_cart_item'
|
64
|
+
|
65
|
+
require_relative 'gateway/SalesOption'
|
66
|
+
require_relative 'gateway/post_notification'
|
67
|
+
require_relative 'gateway/Gateway'
|
68
|
+
require_relative 'gateway/header'
|
69
|
+
require_relative 'gateway/Trailer'
|
70
|
+
require_relative 'gateway/transaction_report_file'
|
data/mundipagg_sdk.gemspec
CHANGED
@@ -1,19 +1,19 @@
|
|
1
|
-
Gem::Specification.new do |s|
|
2
|
-
s.name = 'mundipagg_sdk'
|
3
|
-
s.summary = 'MundiPagg Ruby Client Library'
|
4
|
-
s.description = 'Ruby library for integrating with the MundiPagg payment web services'
|
5
|
-
s.version = '1.0.
|
6
|
-
s.author = 'MundiPagg'
|
7
|
-
s.email = 'github@mundipagg.com'
|
8
|
-
s.homepage = 'http://www.mundipagg.com/'
|
9
|
-
s.files = Dir.glob ["README.md", "LICENSE", "lib/**/*.{rb}", "spec/**/*", "*.gemspec"]
|
10
|
-
s.add_dependency 'rest-client', '~> 1.8', '>= 1.8.0'
|
11
|
-
s.add_dependency 'rspec', '~> 3.3', '>= 3.3.0'
|
12
|
-
s.add_dependency 'nori', '~> 2.6', '>= 2.6.0'
|
13
|
-
s.add_dependency 'gyoku', '~> 1.3', '>= 1.3.1'
|
14
|
-
s.add_dependency 'nokogiri', '~> 1.6', '>= 1.6.6.2'
|
15
|
-
s.add_dependency 'ffi', '~> 1.9', '>= 1.9.10'
|
16
|
-
s.add_dependency 'bundler', '~> 1.10', '>= 1.10.6'
|
17
|
-
s.required_ruby_version = '>= 2.1.7'
|
18
|
-
s.license = 'Apache 2.0'
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = 'mundipagg_sdk'
|
3
|
+
s.summary = 'MundiPagg Ruby Client Library'
|
4
|
+
s.description = 'Ruby library for integrating with the MundiPagg payment web services'
|
5
|
+
s.version = '1.0.3' # Major.Minor.Revision
|
6
|
+
s.author = 'MundiPagg'
|
7
|
+
s.email = 'github@mundipagg.com'
|
8
|
+
s.homepage = 'http://www.mundipagg.com/'
|
9
|
+
s.files = Dir.glob ["README.md", "LICENSE", "lib/**/*.{rb}", "spec/**/*", "*.gemspec"]
|
10
|
+
s.add_dependency 'rest-client', '~> 1.8', '>= 1.8.0'
|
11
|
+
s.add_dependency 'rspec', '~> 3.3', '>= 3.3.0'
|
12
|
+
s.add_dependency 'nori', '~> 2.6', '>= 2.6.0'
|
13
|
+
s.add_dependency 'gyoku', '~> 1.3', '>= 1.3.1'
|
14
|
+
s.add_dependency 'nokogiri', '~> 1.6', '>= 1.6.6.2'
|
15
|
+
s.add_dependency 'ffi', '~> 1.9', '>= 1.9.10'
|
16
|
+
s.add_dependency 'bundler', '~> 1.10', '>= 1.10.6'
|
17
|
+
s.required_ruby_version = '>= 2.1.7'
|
18
|
+
s.license = 'Apache 2.0'
|
19
19
|
end
|
@@ -1,651 +1,733 @@
|
|
1
|
-
require_relative '../../lib/mundipagg_sdk'
|
2
|
-
require_relative 'test_helper'
|
3
|
-
|
4
|
-
merchant_key = '85328786-8BA6-420F-9948-5352F5A183EB'
|
5
|
-
gateway = Gateway.new(:sandbox, merchant_key)
|
6
|
-
|
7
|
-
RSpec.describe Gateway do
|
8
|
-
it 'should create a sale with boleto' do
|
9
|
-
createSaleRequest = CreateSaleRequest.new
|
10
|
-
|
11
|
-
boletoTransaction = BoletoTransaction.new
|
12
|
-
boletoTransaction.AmountInCents = 100
|
13
|
-
boletoTransaction.BankNumber = '237'
|
14
|
-
boletoTransaction.DocumentNumber = '12345678901'
|
15
|
-
boletoTransaction.Instructions = 'Pagar antes do vencimento'
|
16
|
-
boletoTransaction.TransactionReference = 'BoletoTest#Ruby01'
|
17
|
-
boletoTransaction.Options.CurrencyIso = 'BRL'
|
18
|
-
boletoTransaction.Options.DaysToAddInBoletoExpirationDate = 5
|
19
|
-
|
20
|
-
createSaleRequest.BoletoTransactionCollection << boletoTransaction
|
21
|
-
|
22
|
-
response = gateway.CreateSale(createSaleRequest)
|
23
|
-
|
24
|
-
expect(response[:ErrorReport]).to eq nil
|
25
|
-
end
|
26
|
-
|
27
|
-
it 'should create a sale with credit card' do
|
28
|
-
createSaleRequest = CreateSaleRequest.new
|
29
|
-
|
30
|
-
buyerAddress = BuyerAddress.new
|
31
|
-
buyerAddress.AddressType = 'Residential'
|
32
|
-
buyerAddress.City = 'Rio de Janeiro'
|
33
|
-
buyerAddress.Complement = '10 Andar'
|
34
|
-
buyerAddress.Country = 'Brazil'
|
35
|
-
buyerAddress.District = 'Centro'
|
36
|
-
buyerAddress.Number = '199'
|
37
|
-
buyerAddress.State = 'RJ'
|
38
|
-
buyerAddress.Street = 'Rua da Quitanda'
|
39
|
-
buyerAddress.ZipCode = '20091005'
|
40
|
-
|
41
|
-
creditCardTransaction = CreditCardTransaction.new
|
42
|
-
creditCardTransaction.AmountInCents = 100
|
43
|
-
creditCardTransaction.InstallmentCount = 1
|
44
|
-
creditCardTransaction.TransactionReference = 'CreditCard One RubySDK Test'
|
45
|
-
creditCardTransaction.Options.PaymentMethodCode = 1
|
46
|
-
creditCardTransaction.Options.SoftDescriptorText = 'My Store Name'
|
47
|
-
creditCardTransaction.CreditCard.CreditCardNumber = '5453010000066167'
|
48
|
-
creditCardTransaction.CreditCard.ExpMonth = 5
|
49
|
-
creditCardTransaction.CreditCard.ExpYear = 18
|
50
|
-
creditCardTransaction.CreditCard.HolderName = 'Maria do Carmo'
|
51
|
-
creditCardTransaction.CreditCard.SecurityCode = '123'
|
52
|
-
creditCardTransaction.CreditCard.CreditCardBrand = 'Mastercard'
|
53
|
-
creditCardTransaction.CreditCard.BillingAddress.City = 'Rio de Janeiro'
|
54
|
-
creditCardTransaction.CreditCard.BillingAddress.Complement = '10 Andar'
|
55
|
-
creditCardTransaction.CreditCard.BillingAddress.Country = 'Brazil'
|
56
|
-
creditCardTransaction.CreditCard.BillingAddress.District = 'Centro'
|
57
|
-
creditCardTransaction.CreditCard.BillingAddress.Number = '199'
|
58
|
-
creditCardTransaction.CreditCard.BillingAddress.State = 'RJ'
|
59
|
-
creditCardTransaction.CreditCard.BillingAddress.Street = 'Rua da Quitanda'
|
60
|
-
creditCardTransaction.CreditCard.BillingAddress.ZipCode = '20091005'
|
61
|
-
|
62
|
-
createSaleRequest.CreditCardTransactionCollection << creditCardTransaction
|
63
|
-
createSaleRequest.Buyer.Birthdate = Date.new(2001, 9, 26).strftime("%Y-%m-%dT%H:%M:%S")
|
64
|
-
createSaleRequest.Buyer.BuyerCategory = 'Normal'
|
65
|
-
createSaleRequest.Buyer.Email = 'mundiBuyer@mundi.com.br'
|
66
|
-
createSaleRequest.Buyer.EmailType = 'Personal'
|
67
|
-
createSaleRequest.Buyer.Gender = 'M'
|
68
|
-
createSaleRequest.Buyer.HomePhone = '22222222'
|
69
|
-
createSaleRequest.Buyer.MobilePhone = '988888888'
|
70
|
-
createSaleRequest.Buyer.WorkPhone = '25555555'
|
71
|
-
createSaleRequest.Buyer.CreateDateInMerchant = (Date.parse(Time.now.to_s)).strftime("%Y-%m-%dT%H:%M:%S")
|
72
|
-
createSaleRequest.Buyer.LastBuyerUpdateInMerchant = (Date.parse(Time.now.to_s)).strftime("%Y-%m-%dT%H:%M:%S")
|
73
|
-
createSaleRequest.Buyer.DocumentNumber = '51212382749'
|
74
|
-
createSaleRequest.Buyer.DocumentType = 'CPF'
|
75
|
-
createSaleRequest.Buyer.Name = 'Jose da Silva Ramos'
|
76
|
-
createSaleRequest.Buyer.PersonType = 'Person'
|
77
|
-
createSaleRequest.Buyer.AddressCollection << buyerAddress
|
78
|
-
|
79
|
-
response = gateway.CreateSale(createSaleRequest)
|
80
|
-
|
81
|
-
expect(response[:ErrorReport]).to eq nil
|
82
|
-
|
83
|
-
end
|
84
|
-
|
85
|
-
it 'should create a sale with all types of transactions and all fields filled' do
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
createSaleRequest =
|
176
|
-
|
177
|
-
createSaleRequest.Buyer.
|
178
|
-
|
179
|
-
createSaleRequest.Buyer.
|
180
|
-
createSaleRequest.Buyer.
|
181
|
-
createSaleRequest.Buyer.
|
182
|
-
createSaleRequest.Buyer.
|
183
|
-
createSaleRequest.Buyer.
|
184
|
-
createSaleRequest.Buyer.
|
185
|
-
createSaleRequest.Buyer.
|
186
|
-
createSaleRequest.Buyer.
|
187
|
-
createSaleRequest.Buyer.
|
188
|
-
createSaleRequest.Buyer.
|
189
|
-
createSaleRequest.Buyer.
|
190
|
-
|
191
|
-
|
192
|
-
createSaleRequest.
|
193
|
-
createSaleRequest.
|
194
|
-
createSaleRequest.
|
195
|
-
createSaleRequest.
|
196
|
-
createSaleRequest.
|
197
|
-
createSaleRequest.
|
198
|
-
createSaleRequest.
|
199
|
-
createSaleRequest.
|
200
|
-
createSaleRequest.
|
201
|
-
createSaleRequest.
|
202
|
-
createSaleRequest.
|
203
|
-
|
204
|
-
|
205
|
-
createSaleRequest.
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
createSaleRequest =
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
createSaleRequest.
|
287
|
-
createSaleRequest.Order.OrderReference = '
|
288
|
-
|
289
|
-
#
|
290
|
-
|
291
|
-
|
292
|
-
#
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
createSaleRequest
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
creditCardTransactionItem
|
355
|
-
creditCardTransactionItem.
|
356
|
-
creditCardTransactionItem.CreditCard.
|
357
|
-
creditCardTransactionItem.
|
358
|
-
creditCardTransactionItem.
|
359
|
-
creditCardTransactionItem.
|
360
|
-
creditCardTransactionItem.
|
361
|
-
creditCardTransactionItem.
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
creditCardTransactionItem
|
397
|
-
creditCardTransactionItem.
|
398
|
-
creditCardTransactionItem.CreditCard.
|
399
|
-
creditCardTransactionItem.
|
400
|
-
creditCardTransactionItem.
|
401
|
-
creditCardTransactionItem.
|
402
|
-
creditCardTransactionItem.
|
403
|
-
creditCardTransactionItem.
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
creditCardTransactionItem =
|
434
|
-
creditCardTransactionItem.
|
435
|
-
creditCardTransactionItem.
|
436
|
-
creditCardTransactionItem.
|
437
|
-
creditCardTransactionItem.
|
438
|
-
creditCardTransactionItem.CreditCard.
|
439
|
-
creditCardTransactionItem.
|
440
|
-
creditCardTransactionItem.
|
441
|
-
creditCardTransactionItem.
|
442
|
-
creditCardTransactionItem.
|
443
|
-
creditCardTransactionItem.
|
444
|
-
|
445
|
-
|
446
|
-
createSaleRequest =
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
#
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
expect(
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
response
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
1
|
+
require_relative '../../lib/mundipagg_sdk'
|
2
|
+
require_relative 'test_helper'
|
3
|
+
|
4
|
+
merchant_key = '85328786-8BA6-420F-9948-5352F5A183EB'
|
5
|
+
gateway = Gateway.new(:sandbox, merchant_key)
|
6
|
+
|
7
|
+
RSpec.describe Gateway do
|
8
|
+
it 'should create a sale with boleto' do
|
9
|
+
createSaleRequest = CreateSaleRequest.new
|
10
|
+
|
11
|
+
boletoTransaction = BoletoTransaction.new
|
12
|
+
boletoTransaction.AmountInCents = 100
|
13
|
+
boletoTransaction.BankNumber = '237'
|
14
|
+
boletoTransaction.DocumentNumber = '12345678901'
|
15
|
+
boletoTransaction.Instructions = 'Pagar antes do vencimento'
|
16
|
+
boletoTransaction.TransactionReference = 'BoletoTest#Ruby01'
|
17
|
+
boletoTransaction.Options.CurrencyIso = 'BRL'
|
18
|
+
boletoTransaction.Options.DaysToAddInBoletoExpirationDate = 5
|
19
|
+
|
20
|
+
createSaleRequest.BoletoTransactionCollection << boletoTransaction
|
21
|
+
|
22
|
+
response = gateway.CreateSale(createSaleRequest)
|
23
|
+
|
24
|
+
expect(response[:ErrorReport]).to eq nil
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'should create a sale with credit card' do
|
28
|
+
createSaleRequest = CreateSaleRequest.new
|
29
|
+
|
30
|
+
buyerAddress = BuyerAddress.new
|
31
|
+
buyerAddress.AddressType = 'Residential'
|
32
|
+
buyerAddress.City = 'Rio de Janeiro'
|
33
|
+
buyerAddress.Complement = '10 Andar'
|
34
|
+
buyerAddress.Country = 'Brazil'
|
35
|
+
buyerAddress.District = 'Centro'
|
36
|
+
buyerAddress.Number = '199'
|
37
|
+
buyerAddress.State = 'RJ'
|
38
|
+
buyerAddress.Street = 'Rua da Quitanda'
|
39
|
+
buyerAddress.ZipCode = '20091005'
|
40
|
+
|
41
|
+
creditCardTransaction = CreditCardTransaction.new
|
42
|
+
creditCardTransaction.AmountInCents = 100
|
43
|
+
creditCardTransaction.InstallmentCount = 1
|
44
|
+
creditCardTransaction.TransactionReference = 'CreditCard One RubySDK Test'
|
45
|
+
creditCardTransaction.Options.PaymentMethodCode = 1
|
46
|
+
creditCardTransaction.Options.SoftDescriptorText = 'My Store Name'
|
47
|
+
creditCardTransaction.CreditCard.CreditCardNumber = '5453010000066167'
|
48
|
+
creditCardTransaction.CreditCard.ExpMonth = 5
|
49
|
+
creditCardTransaction.CreditCard.ExpYear = 18
|
50
|
+
creditCardTransaction.CreditCard.HolderName = 'Maria do Carmo'
|
51
|
+
creditCardTransaction.CreditCard.SecurityCode = '123'
|
52
|
+
creditCardTransaction.CreditCard.CreditCardBrand = 'Mastercard'
|
53
|
+
creditCardTransaction.CreditCard.BillingAddress.City = 'Rio de Janeiro'
|
54
|
+
creditCardTransaction.CreditCard.BillingAddress.Complement = '10 Andar'
|
55
|
+
creditCardTransaction.CreditCard.BillingAddress.Country = 'Brazil'
|
56
|
+
creditCardTransaction.CreditCard.BillingAddress.District = 'Centro'
|
57
|
+
creditCardTransaction.CreditCard.BillingAddress.Number = '199'
|
58
|
+
creditCardTransaction.CreditCard.BillingAddress.State = 'RJ'
|
59
|
+
creditCardTransaction.CreditCard.BillingAddress.Street = 'Rua da Quitanda'
|
60
|
+
creditCardTransaction.CreditCard.BillingAddress.ZipCode = '20091005'
|
61
|
+
|
62
|
+
createSaleRequest.CreditCardTransactionCollection << creditCardTransaction
|
63
|
+
createSaleRequest.Buyer.Birthdate = Date.new(2001, 9, 26).strftime("%Y-%m-%dT%H:%M:%S")
|
64
|
+
createSaleRequest.Buyer.BuyerCategory = 'Normal'
|
65
|
+
createSaleRequest.Buyer.Email = 'mundiBuyer@mundi.com.br'
|
66
|
+
createSaleRequest.Buyer.EmailType = 'Personal'
|
67
|
+
createSaleRequest.Buyer.Gender = 'M'
|
68
|
+
createSaleRequest.Buyer.HomePhone = '22222222'
|
69
|
+
createSaleRequest.Buyer.MobilePhone = '988888888'
|
70
|
+
createSaleRequest.Buyer.WorkPhone = '25555555'
|
71
|
+
createSaleRequest.Buyer.CreateDateInMerchant = (Date.parse(Time.now.to_s)).strftime("%Y-%m-%dT%H:%M:%S")
|
72
|
+
createSaleRequest.Buyer.LastBuyerUpdateInMerchant = (Date.parse(Time.now.to_s)).strftime("%Y-%m-%dT%H:%M:%S")
|
73
|
+
createSaleRequest.Buyer.DocumentNumber = '51212382749'
|
74
|
+
createSaleRequest.Buyer.DocumentType = 'CPF'
|
75
|
+
createSaleRequest.Buyer.Name = 'Jose da Silva Ramos'
|
76
|
+
createSaleRequest.Buyer.PersonType = 'Person'
|
77
|
+
createSaleRequest.Buyer.AddressCollection << buyerAddress
|
78
|
+
|
79
|
+
response = gateway.CreateSale(createSaleRequest)
|
80
|
+
|
81
|
+
expect(response[:ErrorReport]).to eq nil
|
82
|
+
|
83
|
+
end
|
84
|
+
|
85
|
+
it 'should create a sale with all types of transactions and all fields filled' do
|
86
|
+
# creates boleto transaction object
|
87
|
+
boletoTransaction = BoletoTransaction.new
|
88
|
+
|
89
|
+
# 100 reais in cents
|
90
|
+
boletoTransaction.AmountInCents = 10000
|
91
|
+
boletoTransaction.BankNumber = '237'
|
92
|
+
boletoTransaction.BillingAddress.City = 'Tatooine'
|
93
|
+
boletoTransaction.BillingAddress.Complement = ''
|
94
|
+
boletoTransaction.BillingAddress.Country = 'Brazil'
|
95
|
+
boletoTransaction.BillingAddress.District = 'Mos Eisley'
|
96
|
+
boletoTransaction.BillingAddress.Number = '123'
|
97
|
+
boletoTransaction.BillingAddress.State = 'RJ'
|
98
|
+
boletoTransaction.BillingAddress.Street = 'Mos Eisley Cantina'
|
99
|
+
boletoTransaction.BillingAddress.ZipCode = '20001000'
|
100
|
+
boletoTransaction.DocumentNumber = '12345678901'
|
101
|
+
boletoTransaction.Instructions = 'Pagar antes do vencimento'
|
102
|
+
boletoTransaction.Options.CurrencyIso = 'BRL'
|
103
|
+
boletoTransaction.Options.DaysToAddInBoletoExpirationDate = 5
|
104
|
+
boletoTransaction.TransactionReference = 'NumeroDaTransacao'
|
105
|
+
|
106
|
+
|
107
|
+
# create credit card transaction object
|
108
|
+
creditCardTransaction = CreditCardTransaction.new
|
109
|
+
|
110
|
+
# 100 reais in cents
|
111
|
+
creditCardTransaction.AmountInCents = 10000
|
112
|
+
creditCardTransaction.CreditCard.BillingAddress.City = 'Tatooine'
|
113
|
+
creditCardTransaction.CreditCard.BillingAddress.Complement = ''
|
114
|
+
creditCardTransaction.CreditCard.BillingAddress.Country = 'Brazil'
|
115
|
+
creditCardTransaction.CreditCard.BillingAddress.District = 'Mos Eisley'
|
116
|
+
creditCardTransaction.CreditCard.BillingAddress.Number = '123'
|
117
|
+
creditCardTransaction.CreditCard.BillingAddress.State = 'RJ'
|
118
|
+
creditCardTransaction.CreditCard.BillingAddress.Street = 'Mos Eisley Cantina'
|
119
|
+
creditCardTransaction.CreditCard.BillingAddress.ZipCode = '20001000'
|
120
|
+
creditCardTransaction.CreditCard.CreditCardBrand = 'Visa'
|
121
|
+
creditCardTransaction.CreditCard.CreditCardNumber = '4111111111111111'
|
122
|
+
creditCardTransaction.CreditCard.ExpMonth = 10
|
123
|
+
creditCardTransaction.CreditCard.ExpYear = 22
|
124
|
+
creditCardTransaction.CreditCard.HolderName = 'LUKE SKYWALKER'
|
125
|
+
creditCardTransaction.CreditCard.SecurityCode = '123'
|
126
|
+
creditCardTransaction.CreditCardOperation = 'AuthOnly'
|
127
|
+
creditCardTransaction.InstallmentCount = 1
|
128
|
+
creditCardTransaction.Options.CurrencyIso = 'BRL'
|
129
|
+
creditCardTransaction.Options.PaymentMethodCode = 1
|
130
|
+
creditCardTransaction.Options.SoftDescriptorText = 'Jedi Mega Store'
|
131
|
+
|
132
|
+
shoppingCartItem = ShoppingCartItemCollection.new
|
133
|
+
shoppingCartItem.Description = 'Red Lightsaber'
|
134
|
+
shoppingCartItem.DiscountAmountInCents = 0
|
135
|
+
shoppingCartItem.ItemReference = 'NumeroDoProduto'
|
136
|
+
shoppingCartItem.Name = 'Lightsaber'
|
137
|
+
shoppingCartItem.Quantity = 1
|
138
|
+
shoppingCartItem.TotalCostInCents = 18000
|
139
|
+
shoppingCartItem.UnitCostInCents = 18000
|
140
|
+
|
141
|
+
shoppingCartCollection = ShoppingCartCollection.new
|
142
|
+
shoppingCartCollection.DeliveryAddress.City = 'Galaxy far far away'
|
143
|
+
shoppingCartCollection.DeliveryAddress.Complement = 'Bridge'
|
144
|
+
shoppingCartCollection.DeliveryAddress.Country = 'Brazil'
|
145
|
+
shoppingCartCollection.DeliveryAddress.District = 'Command Room'
|
146
|
+
shoppingCartCollection.DeliveryAddress.Number = '321'
|
147
|
+
shoppingCartCollection.DeliveryAddress.State = 'RJ'
|
148
|
+
shoppingCartCollection.DeliveryAddress.Street = 'Death Star'
|
149
|
+
shoppingCartCollection.DeliveryAddress.ZipCode = '10002000'
|
150
|
+
shoppingCartCollection.DeliveryDeadline = DateTime.new(2015, 12, 14, 18, 36, 45).strftime("%Y-%m-%dT%H:%M:%S")
|
151
|
+
shoppingCartCollection.EstimatedDeliveryDate = DateTime.new(2015, 12, 14, 18, 36, 45).strftime("%Y-%m-%dT%H:%M:%S")
|
152
|
+
shoppingCartCollection.FreighCostInCents = 2000
|
153
|
+
shoppingCartCollection.ShippingCompany = 'Empire'
|
154
|
+
shoppingCartCollection.ShoppingCartItemCollection << shoppingCartItem
|
155
|
+
|
156
|
+
# creates request object for transaction creation
|
157
|
+
createSaleRequest = CreateSaleRequest.new
|
158
|
+
|
159
|
+
# adds to the boleto transaction collection
|
160
|
+
createSaleRequest.BoletoTransactionCollection << boletoTransaction
|
161
|
+
|
162
|
+
buyerAddress = BuyerAddress.new
|
163
|
+
buyerAddress.AddressType = 'Residential'
|
164
|
+
buyerAddress.City = 'Tatooine'
|
165
|
+
buyerAddress.Complement = ''
|
166
|
+
buyerAddress.Country = 'Brazil'
|
167
|
+
buyerAddress.District = 'Mos Eisley'
|
168
|
+
buyerAddress.Number = '123'
|
169
|
+
buyerAddress.State = 'RJ'
|
170
|
+
buyerAddress.Street = 'Mos Eisley Cantina'
|
171
|
+
buyerAddress.ZipCode = '20001000'
|
172
|
+
|
173
|
+
createSaleRequest.Buyer.AddressCollection << buyerAddress
|
174
|
+
createSaleRequest.Buyer.Birthdate = DateTime.new(1990,8,20,0,0,0).strftime("%Y-%m-%dT%H:%M:%S")
|
175
|
+
createSaleRequest.Buyer.BuyerCategory = 'Normal'
|
176
|
+
createSaleRequest.Buyer.BuyerReference = 'C3PO'
|
177
|
+
createSaleRequest.Buyer.CreateDateInMerchant = DateTime.new(2015,12,11,18,36,45).strftime("%Y-%m-%dT%H:%M:%S")
|
178
|
+
createSaleRequest.Buyer.DocumentNumber = '12345678901'
|
179
|
+
createSaleRequest.Buyer.DocumentType = 'CPF'
|
180
|
+
createSaleRequest.Buyer.Email = 'lskywalker@r2d2.com'
|
181
|
+
createSaleRequest.Buyer.EmailType = 'Personal'
|
182
|
+
createSaleRequest.Buyer.FacebookId = 'lukeskywalker8917'
|
183
|
+
createSaleRequest.Buyer.Gender = 'M'
|
184
|
+
createSaleRequest.Buyer.HomePhone = '(21)123456789'
|
185
|
+
createSaleRequest.Buyer.MobilePhone = '(21)987654321'
|
186
|
+
createSaleRequest.Buyer.Name = 'Luke Skywalker'
|
187
|
+
createSaleRequest.Buyer.PersonType = 'Person'
|
188
|
+
createSaleRequest.Buyer.TwitterId = '@lukeskywalker8917'
|
189
|
+
createSaleRequest.Buyer.WorkPhone = '(21)28467902'
|
190
|
+
|
191
|
+
# adds to the credit card transaction collection
|
192
|
+
createSaleRequest.CreditCardTransactionCollection << creditCardTransaction
|
193
|
+
createSaleRequest.Merchant.MerchantReference = 'IdDaLojaPlataforma'
|
194
|
+
createSaleRequest.Options.AntiFraudServiceCode = 0
|
195
|
+
createSaleRequest.Options.CurrencyIso = 'BRL'
|
196
|
+
createSaleRequest.Options.IsAntiFraudEnabled = true
|
197
|
+
createSaleRequest.Options.Retries = 1
|
198
|
+
createSaleRequest.Order.OrderReference = 'NumeroDoPedido'
|
199
|
+
createSaleRequest.RequestData.EcommerceCategory = 'B2C'
|
200
|
+
createSaleRequest.RequestData.IpAddress = '127.0.0.1'
|
201
|
+
createSaleRequest.RequestData.Origin = 'SiteDeCompra'
|
202
|
+
createSaleRequest.RequestData.SessionId = 'IdSesssaoNoSite'
|
203
|
+
|
204
|
+
# adds shopping cart collection in the request
|
205
|
+
createSaleRequest.ShoppingCartCollection << shoppingCartCollection
|
206
|
+
|
207
|
+
# make the request and returns a response hash
|
208
|
+
response = gateway.CreateSale(createSaleRequest)
|
209
|
+
|
210
|
+
expect(response[:ErrorReport]).to eq nil
|
211
|
+
end
|
212
|
+
|
213
|
+
it 'should create an anti fraud transaction' do
|
214
|
+
# create credit card transaction object
|
215
|
+
creditCardTransaction = CreditCardTransaction.new
|
216
|
+
|
217
|
+
# 100 reais in cents
|
218
|
+
creditCardTransaction.AmountInCents = 10000
|
219
|
+
creditCardTransaction.CreditCard.BillingAddress.City = 'Tatooine'
|
220
|
+
creditCardTransaction.CreditCard.BillingAddress.Complement = ''
|
221
|
+
creditCardTransaction.CreditCard.BillingAddress.Country = 'Brazil'
|
222
|
+
creditCardTransaction.CreditCard.BillingAddress.District = 'Mos Eisley'
|
223
|
+
creditCardTransaction.CreditCard.BillingAddress.Number = '123'
|
224
|
+
creditCardTransaction.CreditCard.BillingAddress.State = 'RJ'
|
225
|
+
creditCardTransaction.CreditCard.BillingAddress.Street = 'Mos Eisley Cantina'
|
226
|
+
creditCardTransaction.CreditCard.BillingAddress.ZipCode = '20001000'
|
227
|
+
creditCardTransaction.CreditCard.CreditCardBrand = 'Visa'
|
228
|
+
creditCardTransaction.CreditCard.CreditCardNumber = '4111111111111111'
|
229
|
+
creditCardTransaction.CreditCard.ExpMonth = 10
|
230
|
+
creditCardTransaction.CreditCard.ExpYear = 22
|
231
|
+
creditCardTransaction.CreditCard.HolderName = 'LUKE SKYWALKER'
|
232
|
+
creditCardTransaction.CreditCard.SecurityCode = '123'
|
233
|
+
creditCardTransaction.InstallmentCount = 1
|
234
|
+
|
235
|
+
shoppingCartItem = ShoppingCartItemCollection.new
|
236
|
+
shoppingCartItem.Description = 'Red Lightsaber'
|
237
|
+
shoppingCartItem.DiscountAmountInCents = 0
|
238
|
+
shoppingCartItem.ItemReference = 'NumeroDoProduto'
|
239
|
+
shoppingCartItem.Name = 'Lightsaber'
|
240
|
+
shoppingCartItem.Quantity = 1
|
241
|
+
shoppingCartItem.TotalCostInCents = 18000
|
242
|
+
shoppingCartItem.UnitCostInCents = 0
|
243
|
+
|
244
|
+
shoppingCartCollection = ShoppingCartCollection.new
|
245
|
+
shoppingCartCollection.DeliveryAddress.City = 'Galaxy far far away'
|
246
|
+
shoppingCartCollection.DeliveryAddress.Complement = 'Bridge'
|
247
|
+
shoppingCartCollection.DeliveryAddress.Country = 'Brazil'
|
248
|
+
shoppingCartCollection.DeliveryAddress.District = 'Command Room'
|
249
|
+
shoppingCartCollection.DeliveryAddress.Number = '321'
|
250
|
+
shoppingCartCollection.DeliveryAddress.State = 'RJ'
|
251
|
+
shoppingCartCollection.DeliveryAddress.Street = 'Death Star'
|
252
|
+
shoppingCartCollection.DeliveryAddress.ZipCode = '10002000'
|
253
|
+
shoppingCartCollection.FreighCostInCents = 2000
|
254
|
+
shoppingCartCollection.ShoppingCartItemCollection << shoppingCartItem
|
255
|
+
|
256
|
+
# creates request object for transaction creation
|
257
|
+
createSaleRequest = CreateSaleRequest.new
|
258
|
+
|
259
|
+
buyerAddress = BuyerAddress.new
|
260
|
+
buyerAddress.AddressType = 'Residential'
|
261
|
+
buyerAddress.City = 'Tatooine'
|
262
|
+
buyerAddress.Complement = ''
|
263
|
+
buyerAddress.Country = 'Brazil'
|
264
|
+
buyerAddress.District = 'Mos Eisley'
|
265
|
+
buyerAddress.Number = '123'
|
266
|
+
buyerAddress.State = 'RJ'
|
267
|
+
buyerAddress.Street = 'Mos Eisley Cantina'
|
268
|
+
buyerAddress.ZipCode = '20001000'
|
269
|
+
|
270
|
+
createSaleRequest.Buyer.AddressCollection << buyerAddress
|
271
|
+
createSaleRequest.Buyer.Birthdate = DateTime.new(1990,8,20,0,0,0).strftime("%Y-%m-%dT%H:%M:%S")
|
272
|
+
createSaleRequest.Buyer.BuyerReference = 'C3PO'
|
273
|
+
createSaleRequest.Buyer.DocumentNumber = '12345678901'
|
274
|
+
createSaleRequest.Buyer.DocumentType = 'CPF'
|
275
|
+
createSaleRequest.Buyer.Email = 'lskywalker@r2d2.com'
|
276
|
+
createSaleRequest.Buyer.EmailType = 'Personal'
|
277
|
+
createSaleRequest.Buyer.Gender = 'M'
|
278
|
+
createSaleRequest.Buyer.HomePhone = '(21)123456789'
|
279
|
+
createSaleRequest.Buyer.MobilePhone = '(21)987654321'
|
280
|
+
createSaleRequest.Buyer.Name = 'Luke Skywalker'
|
281
|
+
createSaleRequest.Buyer.PersonType = 'Person'
|
282
|
+
createSaleRequest.Buyer.WorkPhone = '(21)28467902'
|
283
|
+
|
284
|
+
# adds to the credit card transaction collection
|
285
|
+
createSaleRequest.CreditCardTransactionCollection << creditCardTransaction
|
286
|
+
createSaleRequest.Options.IsAntiFraudEnabled = true
|
287
|
+
createSaleRequest.Order.OrderReference = 'NumeroDoPedido'
|
288
|
+
|
289
|
+
# adds shopping cart collection in the request
|
290
|
+
createSaleRequest.ShoppingCartCollection << shoppingCartCollection
|
291
|
+
|
292
|
+
# make the request and returns a response hash
|
293
|
+
response = gateway.CreateSale(createSaleRequest)
|
294
|
+
|
295
|
+
expect(response[:ErrorReport]).to eq nil
|
296
|
+
end
|
297
|
+
|
298
|
+
it 'should consult the order with order key' do
|
299
|
+
querySaleRequest = QuerySaleRequest.new
|
300
|
+
createSaleRequest = CreateSaleRequest.new
|
301
|
+
|
302
|
+
boletoTransaction = BoletoTransaction.new
|
303
|
+
boletoTransaction.AmountInCents = 100
|
304
|
+
boletoTransaction.BankNumber = '237'
|
305
|
+
boletoTransaction.DocumentNumber = '12345678901'
|
306
|
+
boletoTransaction.Instructions = 'Pagar antes do vencimento'
|
307
|
+
boletoTransaction.TransactionReference = 'BoletoTest#Ruby01'
|
308
|
+
boletoTransaction.Options.CurrencyIso = 'BRL'
|
309
|
+
boletoTransaction.Options.DaysToAddInBoletoExpirationDate = 5
|
310
|
+
|
311
|
+
createSaleRequest.BoletoTransactionCollection << boletoTransaction
|
312
|
+
|
313
|
+
boleto_response = gateway.CreateSale(createSaleRequest)
|
314
|
+
|
315
|
+
querySaleRequest.OrderKey = boleto_response['OrderResult']['OrderKey']
|
316
|
+
responseQuery = gateway.Query(QuerySaleRequest.QuerySaleRequestEnum[:OrderKey], querySaleRequest.OrderKey)
|
317
|
+
|
318
|
+
orderKey = responseQuery["SaleDataCollection"][0]["OrderData"]["OrderKey"]
|
319
|
+
|
320
|
+
expect(orderKey).to eq querySaleRequest.OrderKey
|
321
|
+
end
|
322
|
+
|
323
|
+
it 'should consult the order with order reference' do
|
324
|
+
querySaleRequest = QuerySaleRequest.new
|
325
|
+
createSaleRequest = CreateSaleRequest.new
|
326
|
+
|
327
|
+
boletoTransaction = BoletoTransaction.new
|
328
|
+
boletoTransaction.AmountInCents = 100
|
329
|
+
boletoTransaction.BankNumber = '237'
|
330
|
+
boletoTransaction.DocumentNumber = '12345678901'
|
331
|
+
boletoTransaction.Instructions = 'Pagar antes do vencimento'
|
332
|
+
boletoTransaction.TransactionReference = 'BoletoTest#Ruby01'
|
333
|
+
boletoTransaction.Options.CurrencyIso = 'BRL'
|
334
|
+
boletoTransaction.Options.DaysToAddInBoletoExpirationDate = 5
|
335
|
+
|
336
|
+
createSaleRequest.Order.OrderReference = 'RubyOrderReferenceUnitTest'
|
337
|
+
createSaleRequest.BoletoTransactionCollection << boletoTransaction
|
338
|
+
|
339
|
+
boleto_response = gateway.CreateSale(createSaleRequest)
|
340
|
+
|
341
|
+
querySaleRequest.OrderReference = boleto_response['OrderResult']['OrderReference']
|
342
|
+
responseQuery = gateway.Query(QuerySaleRequest.QuerySaleRequestEnum[:OrderReference], querySaleRequest.OrderReference)
|
343
|
+
|
344
|
+
orderReference = responseQuery["SaleDataCollection"][0]["OrderData"]["OrderReference"]
|
345
|
+
|
346
|
+
expect(orderReference).to eq querySaleRequest.OrderReference
|
347
|
+
end
|
348
|
+
|
349
|
+
it 'should do a retry method' do
|
350
|
+
retrySaleRequest = RetrySaleRequest.new
|
351
|
+
retrySaleCreditCardTransactionItem = RetrySaleCreditCardTransaction.new
|
352
|
+
|
353
|
+
createSaleRequest = CreateSaleRequest.new
|
354
|
+
creditCardTransactionItem = CreditCardTransaction.new
|
355
|
+
creditCardTransactionItem.AmountInCents = 100
|
356
|
+
creditCardTransactionItem.CreditCard.CreditCardBrand = 'Visa'
|
357
|
+
creditCardTransactionItem.CreditCard.CreditCardNumber = '41111111111111'
|
358
|
+
creditCardTransactionItem.CreditCard.ExpMonth = 10
|
359
|
+
creditCardTransactionItem.CreditCard.ExpYear = 19
|
360
|
+
creditCardTransactionItem.CreditCard.HolderName = 'Maria do Carmo'
|
361
|
+
creditCardTransactionItem.CreditCard.SecurityCode = '123'
|
362
|
+
creditCardTransactionItem.CreditCardOperation = 'AuthAndCapture'
|
363
|
+
creditCardTransactionItem.InstallmentCount = 1
|
364
|
+
creditCardTransactionItem.Options.CurrencyIso = 'BRL'
|
365
|
+
creditCardTransactionItem.Options.PaymentMethodCode = 1
|
366
|
+
creditCardTransactionItem.TransactionReference = 'RubySDK-RetryTest'
|
367
|
+
|
368
|
+
createSaleRequest.CreditCardTransactionCollection << creditCardTransactionItem
|
369
|
+
createSaleRequest.Order.OrderReference = 'RubySDK-RetryTest'
|
370
|
+
|
371
|
+
# cria o pedido que sera usado para retentativa
|
372
|
+
responseCreate = gateway.CreateSale(createSaleRequest)
|
373
|
+
|
374
|
+
# pega o orderkey e o transaction key da resposta que sao necessarios para fazer a retentativa
|
375
|
+
orderKey = responseCreate["OrderResult"]["OrderKey"]
|
376
|
+
transactionKey = responseCreate['CreditCardTransactionResultCollection'][0]['TransactionKey']
|
377
|
+
|
378
|
+
# monta o objeto de retentativa
|
379
|
+
retrySaleCreditCardTransactionItem.SecurityCode = '123'
|
380
|
+
retrySaleCreditCardTransactionItem.TransactionKey = transactionKey
|
381
|
+
retrySaleRequest.OrderKey = orderKey
|
382
|
+
retrySaleRequest.RetrySaleCreditCardTransactionCollection << retrySaleCreditCardTransactionItem
|
383
|
+
|
384
|
+
# faz a requisicao de retentativa
|
385
|
+
response = gateway.Retry(retrySaleRequest)
|
386
|
+
|
387
|
+
# espera que o transaction key seja igual, significa que foi tudo ok no teste
|
388
|
+
responseTransactionKey = response['CreditCardTransactionResultCollection'][0]['TransactionKey']
|
389
|
+
|
390
|
+
expect(responseTransactionKey).to eq transactionKey
|
391
|
+
|
392
|
+
end
|
393
|
+
|
394
|
+
it 'should do a retry method with only order key' do
|
395
|
+
createSaleRequest = CreateSaleRequest.new
|
396
|
+
creditCardTransactionItem = CreditCardTransaction.new
|
397
|
+
creditCardTransactionItem.AmountInCents = 100
|
398
|
+
creditCardTransactionItem.CreditCard.CreditCardBrand = 'Visa'
|
399
|
+
creditCardTransactionItem.CreditCard.CreditCardNumber = '41111111111111'
|
400
|
+
creditCardTransactionItem.CreditCard.ExpMonth = 10
|
401
|
+
creditCardTransactionItem.CreditCard.ExpYear = 22
|
402
|
+
creditCardTransactionItem.CreditCard.HolderName = 'Maria do Carmo'
|
403
|
+
creditCardTransactionItem.CreditCard.SecurityCode = '123'
|
404
|
+
creditCardTransactionItem.CreditCardOperation = 'AuthAndCapture'
|
405
|
+
creditCardTransactionItem.TransactionReference = 'RubySDK-RetryTest'
|
406
|
+
|
407
|
+
createSaleRequest.CreditCardTransactionCollection << creditCardTransactionItem
|
408
|
+
createSaleRequest.Order.OrderReference = 'RubySDK-RetryTest'
|
409
|
+
|
410
|
+
# cria o pedido que sera usado para retentativa
|
411
|
+
responseCreate = gateway.CreateSale(createSaleRequest)
|
412
|
+
|
413
|
+
# pega o orderkey e o transaction key da resposta que sao necessarios para fazer a retentativa
|
414
|
+
orderKey = responseCreate["OrderResult"]["OrderKey"]
|
415
|
+
transactionKey = responseCreate['CreditCardTransactionResultCollection'][0]['TransactionKey']
|
416
|
+
|
417
|
+
retrySaleRequest = RetrySaleRequest.new
|
418
|
+
|
419
|
+
# monta o objeto de retentativa
|
420
|
+
retrySaleRequest.OrderKey = orderKey
|
421
|
+
|
422
|
+
# faz a requisicao de retentativa
|
423
|
+
response = gateway.Retry(retrySaleRequest)
|
424
|
+
|
425
|
+
expect(response['ErrorReport']).to eq nil
|
426
|
+
|
427
|
+
end
|
428
|
+
|
429
|
+
it 'should cancel a transaction' do
|
430
|
+
createSaleRequest = CreateSaleRequest.new
|
431
|
+
creditCardTransactionItem = CreditCardTransaction.new
|
432
|
+
creditCardTransactionItem.AmountInCents = 100
|
433
|
+
creditCardTransactionItem.CreditCard.CreditCardBrand = 'Visa'
|
434
|
+
creditCardTransactionItem.CreditCard.CreditCardNumber = '41111111111111'
|
435
|
+
creditCardTransactionItem.CreditCard.ExpMonth = 10
|
436
|
+
creditCardTransactionItem.CreditCard.ExpYear = 19
|
437
|
+
creditCardTransactionItem.CreditCard.HolderName = 'Maria do Carmo'
|
438
|
+
creditCardTransactionItem.CreditCard.SecurityCode = '123'
|
439
|
+
creditCardTransactionItem.CreditCardOperation = 'AuthAndCapture'
|
440
|
+
creditCardTransactionItem.InstallmentCount = 1
|
441
|
+
creditCardTransactionItem.Options.CurrencyIso = 'BRL'
|
442
|
+
creditCardTransactionItem.Options.PaymentMethodCode = 1
|
443
|
+
creditCardTransactionItem.TransactionReference = 'RubySDK-CancelTest'
|
444
|
+
|
445
|
+
createSaleRequest.CreditCardTransactionCollection << creditCardTransactionItem
|
446
|
+
createSaleRequest.Order.OrderReference = 'RubySDK-CancelTest'
|
447
|
+
|
448
|
+
# cria o pedido que sera usado para cancelamento
|
449
|
+
responseCreate = gateway.CreateSale(createSaleRequest)
|
450
|
+
|
451
|
+
# pega o orderkey e o transaction key da resposta que sao necessarios para fazer o cancelamento
|
452
|
+
orderKey = responseCreate["OrderResult"]["OrderKey"]
|
453
|
+
transactionKey = responseCreate['CreditCardTransactionResultCollection'][0]['TransactionKey']
|
454
|
+
|
455
|
+
# itens necessarios para cancelamento da transacao de cartao de credito
|
456
|
+
cancelCreditCardTransactionItem = ManageCreditCardTransaction.new
|
457
|
+
cancelCreditCardTransactionItem.AmountInCents = 100
|
458
|
+
cancelCreditCardTransactionItem.TransactionKey = transactionKey
|
459
|
+
cancelCreditCardTransactionItem.TransactionReference = 'RubySDK-CancelTest'
|
460
|
+
|
461
|
+
# monta o objeto para cancelamento de transacao
|
462
|
+
cancelSaleRequest = ManageSaleRequest.new
|
463
|
+
cancelSaleRequest.OrderKey = orderKey
|
464
|
+
cancelSaleRequest.CreditCardTransactionCollection << cancelCreditCardTransactionItem
|
465
|
+
|
466
|
+
response = gateway.Cancel(cancelSaleRequest)
|
467
|
+
|
468
|
+
expect(response[:ErrorReport]).to eq nil
|
469
|
+
end
|
470
|
+
|
471
|
+
it 'should capture a transaction' do
|
472
|
+
createSaleRequest = CreateSaleRequest.new
|
473
|
+
creditCardTransactionItem = CreditCardTransaction.new
|
474
|
+
creditCardTransactionItem.AmountInCents = 100
|
475
|
+
creditCardTransactionItem.CreditCard.CreditCardBrand = 'Visa'
|
476
|
+
creditCardTransactionItem.CreditCard.CreditCardNumber = '41111111111111'
|
477
|
+
creditCardTransactionItem.CreditCard.ExpMonth = 10
|
478
|
+
creditCardTransactionItem.CreditCard.ExpYear = 19
|
479
|
+
creditCardTransactionItem.CreditCard.HolderName = 'Maria do Carmo'
|
480
|
+
creditCardTransactionItem.CreditCard.SecurityCode = '123'
|
481
|
+
creditCardTransactionItem.CreditCardOperation = 'AuthAndCapture'
|
482
|
+
creditCardTransactionItem.InstallmentCount = 1
|
483
|
+
creditCardTransactionItem.Options.CurrencyIso = 'BRL'
|
484
|
+
creditCardTransactionItem.Options.PaymentMethodCode = 1
|
485
|
+
creditCardTransactionItem.TransactionReference = 'RubySDK-CaptureTest'
|
486
|
+
|
487
|
+
createSaleRequest.CreditCardTransactionCollection << creditCardTransactionItem
|
488
|
+
createSaleRequest.Order.OrderReference = 'RubySDK-CaptureTest'
|
489
|
+
|
490
|
+
# cria o pedido que sera usado para captura
|
491
|
+
responseCreate = gateway.CreateSale(createSaleRequest)
|
492
|
+
|
493
|
+
# pega o orderkey e o transaction key da resposta que sao necessarios para fazer a captura
|
494
|
+
orderKey = responseCreate["OrderResult"]["OrderKey"]
|
495
|
+
transactionKey = responseCreate['CreditCardTransactionResultCollection'][0]['TransactionKey']
|
496
|
+
|
497
|
+
# itens necessarios para captura da transacao de cartao de credito
|
498
|
+
captureCreditCardTransactionItem = ManageCreditCardTransaction.new
|
499
|
+
captureCreditCardTransactionItem.AmountInCents = 100
|
500
|
+
captureCreditCardTransactionItem.TransactionKey = transactionKey
|
501
|
+
captureCreditCardTransactionItem.TransactionReference = 'RubySDK-CaptureTest'
|
502
|
+
|
503
|
+
# monta o objeto para cancelamento de transacao
|
504
|
+
captureSaleRequest = ManageSaleRequest.new
|
505
|
+
captureSaleRequest.OrderKey = orderKey
|
506
|
+
captureSaleRequest.CreditCardTransactionCollection << captureCreditCardTransactionItem
|
507
|
+
|
508
|
+
response = gateway.Capture(captureSaleRequest)
|
509
|
+
|
510
|
+
# espera que o ErrorReport seja nulo, significa que foi tudo ok na transação
|
511
|
+
expect(response['ErrorReport']).to eq nil
|
512
|
+
end
|
513
|
+
|
514
|
+
it 'should do a parse xml to notification interpretation' do
|
515
|
+
creditCardTransactionItem = CreditCardTransaction.new
|
516
|
+
creditCardTransactionItem.AmountInCents = 100
|
517
|
+
creditCardTransactionItem.TransactionReference = 'Ruby PostNotification Test'
|
518
|
+
creditCardTransactionItem.InstallmentCount = 1
|
519
|
+
creditCardTransactionItem.CreditCardOperation = 'AuthAndCapture'
|
520
|
+
creditCardTransactionItem.CreditCard.CreditCardBrand = 'Visa'
|
521
|
+
creditCardTransactionItem.CreditCard.CreditCardNumber = '4111111111111111'
|
522
|
+
creditCardTransactionItem.CreditCard.HolderName = 'Bruce Wayne'
|
523
|
+
creditCardTransactionItem.CreditCard.SecurityCode = '123'
|
524
|
+
creditCardTransactionItem.CreditCard.ExpMonth = 5
|
525
|
+
creditCardTransactionItem.CreditCard.ExpYear = 20
|
526
|
+
creditCardTransactionItem.Options.PaymentMethodCode = 1
|
527
|
+
|
528
|
+
createSaleRequest = CreateSaleRequest.new
|
529
|
+
createSaleRequest.CreditCardTransactionCollection << creditCardTransactionItem
|
530
|
+
|
531
|
+
response_hash = gateway.CreateSale(createSaleRequest)
|
532
|
+
|
533
|
+
credit_card_result = response_hash['CreditCardTransactionResultCollection'][0]
|
534
|
+
|
535
|
+
expect(credit_card_result['Success']).to eq true
|
536
|
+
# expect(credit_card_result['CreditCardOperation']).to eq 'AuthOnly'
|
537
|
+
# expect(credit_card_result['CreditCardTransactionStatus']).to eq 'AuthorizedPendingCapture'
|
538
|
+
|
539
|
+
captureCreditCardTransactionItem = ManageCreditCardTransaction.new
|
540
|
+
captureCreditCardTransactionItem.AmountInCents = creditCardTransactionItem.AmountInCents
|
541
|
+
captureCreditCardTransactionItem.TransactionKey = credit_card_result['TransactionKey']
|
542
|
+
captureCreditCardTransactionItem.TransactionReference = creditCardTransactionItem.TransactionReference
|
543
|
+
|
544
|
+
captureSale = ManageSaleRequest.new
|
545
|
+
captureSale.OrderKey = response_hash['OrderResult']['OrderKey']
|
546
|
+
captureSale.CreditCardTransactionCollection << captureCreditCardTransactionItem
|
547
|
+
|
548
|
+
captureResponse = gateway.Capture(captureSale)
|
549
|
+
|
550
|
+
expect(captureResponse['ErrorReport']).to eq nil
|
551
|
+
|
552
|
+
|
553
|
+
xml = TestHelper.CreateFakePostNotification(response_hash, captureResponse)
|
554
|
+
|
555
|
+
response = gateway.ParseXmlToNotification(xml)
|
556
|
+
|
557
|
+
expect(response.nil?).to eq false
|
558
|
+
end
|
559
|
+
|
560
|
+
it 'should do a parse on online debit xml' do
|
561
|
+
xml = '<StatusNotification xmlns="http://schemas.datacontract.org/2004/07/Gateway.NotificationService.DataContract"
|
562
|
+
xmlns:i="http://www.w3.org/2001/XMLSchema-instance"
|
563
|
+
i:schemaLocation="http://schemas.datacontract.org/2004/07/Gateway.NotificationService.DataContract StatusNotificationXmlSchema.xsd">
|
564
|
+
<AmountInCents>500</AmountInCents>
|
565
|
+
<AmountPaidInCents>0</AmountPaidInCents>
|
566
|
+
<BoletoTransaction>
|
567
|
+
<AmountInCents>500</AmountInCents>
|
568
|
+
<AmountPaidInCents>0</AmountPaidInCents>
|
569
|
+
<BoletoExpirationDate>2013-02-08T00:00:00</BoletoExpirationDate>
|
570
|
+
<NossoNumero>0123456789</NossoNumero>
|
571
|
+
<StatusChangedDate>2012-11-06T08:55:49.753</StatusChangedDate>
|
572
|
+
<TransactionKey>4111D523-9A83-4BE3-94D2-160F1BC9C4BD</TransactionKey>
|
573
|
+
<TransactionReference>B2E32108</TransactionReference>
|
574
|
+
<PreviousBoletoTransactionStatus>Generated</PreviousBoletoTransactionStatus>
|
575
|
+
<BoletoTransactionStatus>Paid</BoletoTransactionStatus>
|
576
|
+
</BoletoTransaction>
|
577
|
+
<CreditCardTransaction>
|
578
|
+
<Acquirer>Simulator</Acquirer>
|
579
|
+
<AmountInCents>2000</AmountInCents>
|
580
|
+
<AuthorizedAmountInCents>2000</AuthorizedAmountInCents>
|
581
|
+
<CapturedAmountInCents>2000</CapturedAmountInCents>
|
582
|
+
<CreditCardBrand>Visa</CreditCardBrand>
|
583
|
+
<RefundedAmountInCents i:nil="true"/>
|
584
|
+
<StatusChangedDate>2012-11-06T10:52:55.93</StatusChangedDate>
|
585
|
+
<TransactionIdentifier>123456</TransactionIdentifier>
|
586
|
+
<TransactionKey>351FC96A-7F42-4269-AF3C-1E3C179C1CD0</TransactionKey>
|
587
|
+
<TransactionReference>24de0432</TransactionReference>
|
588
|
+
<UniqueSequentialNumber>123456</UniqueSequentialNumber>
|
589
|
+
<VoidedAmountInCents i:nil="true"/>
|
590
|
+
<PreviousCreditCardTransactionStatus>AuthorizedPendingCapture</PreviousCreditCardTransactionStatus>
|
591
|
+
<CreditCardTransactionStatus>Captured</CreditCardTransactionStatus>
|
592
|
+
</CreditCardTransaction>
|
593
|
+
|
594
|
+
<OnlineDebitTransaction>
|
595
|
+
<AmountInCents>100</AmountInCents>
|
596
|
+
<AmountPaidInCents>0</AmountPaidInCents>
|
597
|
+
<StatusChangedDate>2013-06-27T19:46:46.87</StatusChangedDate>
|
598
|
+
<TransactionKey>fb3f158a-0309-4ae3-b8ef-3c5ac2d603d2</TransactionKey>
|
599
|
+
<TransactionReference>30bfee13-c908-4e3b-9f70-1f84dbe79fbf</TransactionReference>
|
600
|
+
<PreviousOnlineDebitTransactionStatus>OpenedPendingPayment</PreviousOnlineDebitTransactionStatus>
|
601
|
+
<OnlineDebitTransactionStatus>NotPaid</OnlineDebitTransactionStatus>
|
602
|
+
</OnlineDebitTransaction>
|
603
|
+
|
604
|
+
<MerchantKey>B1B1092C-8681-40C2-A734-500F22683D9B</MerchantKey>
|
605
|
+
<OrderKey>18471F05-9F6D-4497-9C24-D60D5BBB6BBE</OrderKey>
|
606
|
+
<OrderReference>64a85875</OrderReference>
|
607
|
+
<OrderStatus>Paid</OrderStatus>
|
608
|
+
</StatusNotification>'
|
609
|
+
|
610
|
+
response = gateway.ParseXmlToNotification(xml)
|
611
|
+
|
612
|
+
expect(response.nil?).to eq false
|
613
|
+
end
|
614
|
+
|
615
|
+
it 'should bring the transaction report file' do
|
616
|
+
date = Date.new(2015, 9, 19)
|
617
|
+
result = gateway.TransactionReportFile(date)
|
618
|
+
split_commas = result.split(',')
|
619
|
+
|
620
|
+
expect(split_commas[1]).to eq '20150919'
|
621
|
+
end
|
622
|
+
|
623
|
+
it 'should parse the transaction report file received' do
|
624
|
+
date = Date.new(2015, 9, 19)
|
625
|
+
request_to_parse = gateway.TransactionReportFile(date)
|
626
|
+
result = gateway.TransactionReportFileParser(request_to_parse)
|
627
|
+
|
628
|
+
expect(result['Header'].TransactionProcessedDate).to eq '20150919'
|
629
|
+
end
|
630
|
+
|
631
|
+
it 'should save the transaction report file at selected path' do
|
632
|
+
date = Date.new(2015, 9, 19)
|
633
|
+
|
634
|
+
file = Tempfile.new('Test')
|
635
|
+
gateway.TransactionReportFileDownloader(date, 'Test', file.path)
|
636
|
+
|
637
|
+
file_path = file.path.to_s + 'Test.txt'
|
638
|
+
file_exist = File.exist?(file_path)
|
639
|
+
|
640
|
+
file.close
|
641
|
+
file.unlink
|
642
|
+
|
643
|
+
expect(file_exist).to eq true
|
644
|
+
end
|
645
|
+
|
646
|
+
it 'should consult transaction with instant buy key' do
|
647
|
+
credit_card_transaction = CreditCardTransaction.new
|
648
|
+
credit_card_transaction.CreditCard.CreditCardNumber = '4111111111111111'
|
649
|
+
credit_card_transaction.CreditCard.CreditCardBrand = 'Visa'
|
650
|
+
credit_card_transaction.CreditCard.ExpMonth = 10
|
651
|
+
credit_card_transaction.CreditCard.ExpYear = 2018
|
652
|
+
credit_card_transaction.CreditCard.SecurityCode = '123'
|
653
|
+
credit_card_transaction.CreditCard.HolderName = 'Luke Skywalker'
|
654
|
+
credit_card_transaction.AmountInCents = 100
|
655
|
+
|
656
|
+
sale_request = CreateSaleRequest.new
|
657
|
+
sale_request.CreditCardTransactionCollection << credit_card_transaction
|
658
|
+
|
659
|
+
sale_response = gateway.CreateSale(sale_request)
|
660
|
+
|
661
|
+
expect(sale_response['ErrorReport']).to eq nil
|
662
|
+
|
663
|
+
instant_buy_key = sale_response['CreditCardTransactionResultCollection'][0]['CreditCard']['InstantBuyKey']
|
664
|
+
|
665
|
+
response = gateway.InstantBuyKey(instant_buy_key)
|
666
|
+
|
667
|
+
expect(response['ErrorReport']).to eq nil
|
668
|
+
end
|
669
|
+
|
670
|
+
it 'should consult transaction with buyer key' do
|
671
|
+
|
672
|
+
credit_card_transaction = CreditCardTransaction.new
|
673
|
+
credit_card_transaction.CreditCard.CreditCardNumber = '4111111111111111'
|
674
|
+
credit_card_transaction.CreditCard.CreditCardBrand = 'Visa'
|
675
|
+
credit_card_transaction.CreditCard.ExpMonth = 10
|
676
|
+
credit_card_transaction.CreditCard.ExpYear = 2018
|
677
|
+
credit_card_transaction.CreditCard.SecurityCode = '123'
|
678
|
+
credit_card_transaction.CreditCard.HolderName = 'Luke Skywalker'
|
679
|
+
credit_card_transaction.AmountInCents = 100
|
680
|
+
|
681
|
+
sale_request = CreateSaleRequest.new
|
682
|
+
sale_request.Buyer.Name = 'Anakin Skywalker'
|
683
|
+
sale_request.Buyer.Birthdate = Date.new(1994, 9, 26).strftime("%Y-%m-%dT%H:%M:%S")
|
684
|
+
sale_request.Buyer.DocumentNumber = '12345678901'
|
685
|
+
sale_request.Buyer.DocumentType = 'CPF'
|
686
|
+
sale_request.Buyer.PersonType = 'Person'
|
687
|
+
sale_request.Buyer.Gender = 'M'
|
688
|
+
sale_request.CreditCardTransactionCollection << credit_card_transaction
|
689
|
+
|
690
|
+
sale_response = gateway.CreateSale(sale_request)
|
691
|
+
|
692
|
+
expect(sale_response['ErrorReport']).to eq nil
|
693
|
+
|
694
|
+
response = gateway.BuyerKey(sale_response['BuyerKey'])
|
695
|
+
|
696
|
+
expect(response['ErrorReport']).to eq nil
|
697
|
+
end
|
698
|
+
|
699
|
+
it 'should do a credit card transaction with instant buy key' do
|
700
|
+
credit_card_transaction = CreditCardTransaction.new
|
701
|
+
credit_card_transaction.CreditCard.CreditCardNumber = '4111111111111111'
|
702
|
+
credit_card_transaction.CreditCard.CreditCardBrand = 'Visa'
|
703
|
+
credit_card_transaction.CreditCard.ExpMonth = 10
|
704
|
+
credit_card_transaction.CreditCard.ExpYear = 2018
|
705
|
+
credit_card_transaction.CreditCard.SecurityCode = '123'
|
706
|
+
credit_card_transaction.CreditCard.HolderName = 'Luke Skywalker'
|
707
|
+
credit_card_transaction.AmountInCents = 100
|
708
|
+
|
709
|
+
sale_request = CreateSaleRequest.new
|
710
|
+
sale_request.CreditCardTransactionCollection << credit_card_transaction
|
711
|
+
|
712
|
+
sale_response = gateway.CreateSale(sale_request)
|
713
|
+
|
714
|
+
expect(sale_response['ErrorReport']).to eq nil
|
715
|
+
|
716
|
+
instant_buy_key = sale_response['CreditCardTransactionResultCollection'][0]['CreditCard']['InstantBuyKey']
|
717
|
+
|
718
|
+
# coleta dados do cartao
|
719
|
+
creditCardTransaction = CreditCardTransaction.new
|
720
|
+
creditCardTransaction.AmountInCents = 100
|
721
|
+
creditCardTransaction.CreditCard.InstantBuyKey = instant_buy_key
|
722
|
+
|
723
|
+
# cria a transacao
|
724
|
+
createSaleRequest = CreateSaleRequest.new
|
725
|
+
createSaleRequest.CreditCardTransactionCollection << creditCardTransaction
|
726
|
+
|
727
|
+
# faz a requisicao de criação de transacao, retorna um hash com a resposta
|
728
|
+
response = gateway.CreateSale(createSaleRequest)
|
729
|
+
|
730
|
+
expect(response['ErrorReport']).to eq nil
|
731
|
+
end
|
732
|
+
|
733
|
+
end
|