stone_ecommerce 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE +202 -0
- data/README.md +64 -0
- data/lib/gateway/Address/billing_address.rb +32 -0
- data/lib/gateway/Address/buyer_address.rb +36 -0
- data/lib/gateway/Address/delivery_address.rb +32 -0
- data/lib/gateway/AntiFraud/anti_fraud_analysis_result.rb +47 -0
- data/lib/gateway/AntiFraud/query_sale_anti_fraud_analysis_data.rb +51 -0
- data/lib/gateway/AntiFraud/query_sale_anti_fraud_analysis_history_data.rb +41 -0
- data/lib/gateway/BaseRequest.rb +11 -0
- data/lib/gateway/BaseResponse.rb +17 -0
- data/lib/gateway/BoletoTransaction/boleto_transaction.rb +43 -0
- data/lib/gateway/BoletoTransaction/boleto_transaction_data.rb +44 -0
- data/lib/gateway/BoletoTransaction/boleto_transaction_options.rb +14 -0
- data/lib/gateway/BoletoTransaction/boleto_transaction_report_file.rb +20 -0
- data/lib/gateway/BoletoTransaction/boleto_transaction_result.rb +35 -0
- data/lib/gateway/CreditCardTransaction/credit_card.rb +30 -0
- data/lib/gateway/CreditCardTransaction/credit_card_transaction.rb +32 -0
- data/lib/gateway/CreditCardTransaction/credit_card_transaction_data.rb +104 -0
- data/lib/gateway/CreditCardTransaction/credit_card_transaction_options.rb +27 -0
- data/lib/gateway/CreditCardTransaction/credit_card_transaction_report_file.rb +29 -0
- data/lib/gateway/CreditCardTransaction/manage_credit_card_transaction.rb +12 -0
- data/lib/gateway/CreditCardTransaction/retry_sale_credit_card_transaction.rb +13 -0
- data/lib/gateway/ErrorItem.rb +17 -0
- data/lib/gateway/ErrorReport.rb +18 -0
- data/lib/gateway/Gateway.rb +442 -0
- data/lib/gateway/InstantBuy/credit_card_data.rb +41 -0
- data/lib/gateway/InstantBuy/get_instant_buy_data_response.rb +18 -0
- data/lib/gateway/Merchant/merchant.rb +11 -0
- data/lib/gateway/OnlineDebit/online_debit_transaction_report_file.rb +18 -0
- data/lib/gateway/Order/order.rb +11 -0
- data/lib/gateway/Order/order_transaction_report_file.rb +6 -0
- data/lib/gateway/Parsers/boleto_transaction_parser.rb +31 -0
- data/lib/gateway/Parsers/credit_card_transaction_parser.rb +40 -0
- data/lib/gateway/Parsers/header_parser.rb +14 -0
- data/lib/gateway/Parsers/online_debit_transaction_parser.rb +30 -0
- data/lib/gateway/Parsers/trailer_parser.rb +15 -0
- data/lib/gateway/Person/buyer.rb +33 -0
- data/lib/gateway/Person/person.rb +47 -0
- data/lib/gateway/Recurrency/recurrency.rb +23 -0
- data/lib/gateway/Sale/create_sale_request.rb +36 -0
- data/lib/gateway/Sale/create_sale_response.rb +25 -0
- data/lib/gateway/Sale/manage_sale_request.rb +17 -0
- data/lib/gateway/Sale/manage_sale_response.rb +15 -0
- data/lib/gateway/Sale/query_sale_request.rb +36 -0
- data/lib/gateway/Sale/query_sale_response.rb +18 -0
- data/lib/gateway/Sale/request_data.rb +20 -0
- data/lib/gateway/Sale/retry_sale_options.rb +14 -0
- data/lib/gateway/Sale/retry_sale_request.rb +22 -0
- data/lib/gateway/Sale/retry_sale_response.rb +14 -0
- data/lib/gateway/Sale/sale_data.rb +33 -0
- data/lib/gateway/Sale/sale_order_data.rb +17 -0
- data/lib/gateway/SalesOption.rb +17 -0
- data/lib/gateway/ShoppingCart/shopping_cart.rb +26 -0
- data/lib/gateway/ShoppingCart/shopping_cart_item.rb +23 -0
- data/lib/gateway/Trailer.rb +6 -0
- data/lib/gateway/address.rb +25 -0
- data/lib/gateway/header.rb +5 -0
- data/lib/gateway/post_notification.rb +29 -0
- data/lib/gateway/transaction_report_file.rb +45 -0
- data/lib/stone_ecommerce.rb +70 -0
- data/spec/integration/gateway_spec.rb +616 -0
- data/spec/integration/test_helper.rb +69 -0
- data/spec/spec_helper.rb +96 -0
- data/stone_ecommerce.gemspec +19 -0
- metadata +247 -0
@@ -0,0 +1,33 @@
|
|
1
|
+
require_relative 'person'
|
2
|
+
|
3
|
+
class Buyer < Person
|
4
|
+
# Chave do comprador. Utilizada para identificar um comprador no gateway
|
5
|
+
attr_accessor :BuyerKey
|
6
|
+
|
7
|
+
# Refer�ncia do comprador no sistema da loja
|
8
|
+
attr_accessor :BuyerReference
|
9
|
+
|
10
|
+
# Lista de endere�os do comprador
|
11
|
+
attr_accessor :AddressCollection
|
12
|
+
|
13
|
+
# Data de cria��o do comprador no sistema da loja
|
14
|
+
attr_accessor :CreateDateInMerchant
|
15
|
+
|
16
|
+
# Data da �ltima atualiza��o do cadastro do comprador no sistema da loja
|
17
|
+
attr_accessor :LastBuyerUpdateInMerchant
|
18
|
+
|
19
|
+
# Categoria do comprador
|
20
|
+
attr_accessor :BuyerCategory
|
21
|
+
|
22
|
+
def initialize
|
23
|
+
@AddressCollection = Array.new
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
def to_json
|
28
|
+
hash = {}
|
29
|
+
instance_variables.each {|var| hash[var.to_s.delete('@')] = instance_variable_get(var) }
|
30
|
+
hash
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
class Person
|
2
|
+
# Nome da pessoa
|
3
|
+
attr_accessor :Name
|
4
|
+
|
5
|
+
# Define se � pessoa f�sica ou jur�dica
|
6
|
+
attr_accessor :PersonType
|
7
|
+
|
8
|
+
# N�mero do documento
|
9
|
+
attr_accessor :DocumentNumber
|
10
|
+
|
11
|
+
# Tipo de documento
|
12
|
+
attr_accessor :DocumentType
|
13
|
+
|
14
|
+
# Sexo da pessoa
|
15
|
+
attr_accessor :Gender
|
16
|
+
|
17
|
+
# Data de nascimento
|
18
|
+
attr_accessor :Birthdate
|
19
|
+
|
20
|
+
# E-mail
|
21
|
+
attr_accessor :Email
|
22
|
+
|
23
|
+
# Tipo do email. Pessoal ou comercial
|
24
|
+
attr_accessor :EmailType
|
25
|
+
|
26
|
+
# C�digo identificador do cadastro no Facebook
|
27
|
+
attr_accessor :FacebookId
|
28
|
+
|
29
|
+
# C�digo identificador do cadastro no Twitter
|
30
|
+
attr_accessor :TwitterId
|
31
|
+
|
32
|
+
# Telefone celular
|
33
|
+
attr_accessor :MobilePhone
|
34
|
+
|
35
|
+
# Telefone Residencial
|
36
|
+
attr_accessor :HomePhone
|
37
|
+
|
38
|
+
# Telefone comercial
|
39
|
+
attr_accessor :WorkPhone
|
40
|
+
|
41
|
+
def to_json
|
42
|
+
hash = {}
|
43
|
+
instance_variables.each { |var| hash[var.to_s.delete('@')] = instance_variable_get(var) }
|
44
|
+
hash
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
class Recurrency
|
2
|
+
# Frequ�ncia da recorr�ncia
|
3
|
+
attr_accessor :Frequency
|
4
|
+
|
5
|
+
# Intervalo de recorr�ncia
|
6
|
+
attr_accessor :Interval
|
7
|
+
|
8
|
+
# Data da primeira cobran�a
|
9
|
+
attr_accessor :DateToStartBilling
|
10
|
+
|
11
|
+
# Total de recorr�ncias
|
12
|
+
attr_accessor :Recurrences
|
13
|
+
|
14
|
+
# Informa se ser� necess�rio efetuar o procedimento OneDollarAuth antes de registrar a recorr�ncia
|
15
|
+
attr_accessor :OneDollarAuth
|
16
|
+
|
17
|
+
def to_json
|
18
|
+
hash = {}
|
19
|
+
instance_variables.each { |var| hash[var.to_s.delete('@')] = instance_variable_get(var) }
|
20
|
+
hash
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
class CreateSaleRequest
|
2
|
+
|
3
|
+
attr_accessor :CreditCardTransactionCollection
|
4
|
+
|
5
|
+
attr_accessor :BoletoTransactionCollection
|
6
|
+
|
7
|
+
attr_accessor :Order
|
8
|
+
|
9
|
+
attr_accessor :Buyer
|
10
|
+
|
11
|
+
attr_accessor :ShoppingCartCollection
|
12
|
+
|
13
|
+
attr_accessor :Options
|
14
|
+
|
15
|
+
attr_accessor :Merchant
|
16
|
+
|
17
|
+
attr_accessor :RequestData
|
18
|
+
|
19
|
+
def initialize
|
20
|
+
@CreditCardTransactionCollection = Array.new
|
21
|
+
@BoletoTransactionCollection = Array.new
|
22
|
+
@ShoppingCartCollection = Array.new
|
23
|
+
@Buyer = Buyer.new
|
24
|
+
@RequestData = RequestData.new
|
25
|
+
@Options = SalesOption.new
|
26
|
+
@Merchant = Merchant.new
|
27
|
+
@Order = Order.new
|
28
|
+
end
|
29
|
+
|
30
|
+
def to_json
|
31
|
+
hash = {}
|
32
|
+
instance_variables.each {|var| hash[var.to_s.delete('@')] = instance_variable_get(var) }
|
33
|
+
hash
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
class CreateSaleResponse
|
2
|
+
# Lista as transa��es de Cart�o de Cr�dito
|
3
|
+
attr_accessor :CreditCardTransactionResultCollection
|
4
|
+
|
5
|
+
# Lista as transa��es de boleto
|
6
|
+
attr_accessor :BoletoTransactionResultCollection
|
7
|
+
|
8
|
+
# Dados de retorno do pedido
|
9
|
+
attr_accessor :OrderResult
|
10
|
+
|
11
|
+
# Chave do comprador. Utilizada para identificar um comprador no gateway
|
12
|
+
attr_accessor :BuyerKey
|
13
|
+
|
14
|
+
def initialize
|
15
|
+
@CreditCardTransactionResultCollection = Array.new
|
16
|
+
@BoletoTransactionResultCollection = Array.new
|
17
|
+
end
|
18
|
+
|
19
|
+
def to_json
|
20
|
+
hash = {}
|
21
|
+
instance_variables.each {|var| hash[var.to_s.delete('@')] = instance_variable_get(var) }
|
22
|
+
hash
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class ManageSaleRequest
|
2
|
+
|
3
|
+
attr_accessor :CreditCardTransactionCollection
|
4
|
+
|
5
|
+
attr_accessor :OrderKey
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
@CreditCardTransactionCollection = Array.new;
|
9
|
+
end
|
10
|
+
|
11
|
+
def to_json
|
12
|
+
hash = {}
|
13
|
+
instance_variables.each {|var| hash[var.to_s.delete('@')] = instance_variable_get(var) }
|
14
|
+
hash
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class ManageSaleResponse
|
2
|
+
# Cole��o de transa��es de cart�o de cr�dito
|
3
|
+
attr_accessor :CreditCardTransactionResultCollection
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
@CreditCardTransactionResultCollection = Array.new
|
7
|
+
end
|
8
|
+
|
9
|
+
def to_json
|
10
|
+
hash = {}
|
11
|
+
instance_variables.each {|var| hash[var.to_s.delete('@')] = instance_variable_get(var) }
|
12
|
+
hash
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
class QuerySaleRequest
|
2
|
+
attr_accessor :OrderKey
|
3
|
+
|
4
|
+
attr_accessor :OrderReference
|
5
|
+
|
6
|
+
attr_accessor :CreditCardTransactionKey
|
7
|
+
|
8
|
+
attr_accessor :CreditCardTransactionReference
|
9
|
+
|
10
|
+
attr_accessor :BoletoTransactionKey
|
11
|
+
|
12
|
+
attr_accessor :BoletoTransactionReference
|
13
|
+
|
14
|
+
attr_accessor :QuerySaleRequestEnum
|
15
|
+
|
16
|
+
# Enum feito para as chamadas do m�todo query
|
17
|
+
@@QuerySaleRequestEnum = {
|
18
|
+
:OrderKey => 'OrderKey',
|
19
|
+
:OrderReference => 'OrderReference',
|
20
|
+
:CreditCardTransactionKey => 'CreditCardTransactionKey',
|
21
|
+
:CreditCardTransactionReference => 'CreditCardTransactionReference',
|
22
|
+
:BoletoTransactionKey => 'BoletoTransactionKey',
|
23
|
+
:BoletoTransactionReference => 'BoletoTransactionReference'
|
24
|
+
}
|
25
|
+
|
26
|
+
def self.QuerySaleRequestEnum
|
27
|
+
@@QuerySaleRequestEnum
|
28
|
+
end
|
29
|
+
|
30
|
+
def to_json
|
31
|
+
hash = {}
|
32
|
+
instance_variables.each {|var| hash[var.to_s.delete('@')] = instance_variable_get(var) }
|
33
|
+
hash
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class QuerySaleResponse
|
2
|
+
# Lista de vendas
|
3
|
+
attr_accessor :SaleDataCollection
|
4
|
+
|
5
|
+
# Indicador do total de vendas
|
6
|
+
attr_accessor :SaleDataCount
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
@SaleDataCollection = Array.new
|
10
|
+
end
|
11
|
+
|
12
|
+
def to_json
|
13
|
+
hash = {}
|
14
|
+
instance_variables.each {|var| hash[var.to_s.delete('@')] = instance_variable_get(var) }
|
15
|
+
hash
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class RequestData
|
2
|
+
# Identificador da origem de venda na loja
|
3
|
+
attr_accessor :Origin
|
4
|
+
|
5
|
+
# Identificador da sess�o do usu�rio no sistema da loja (utilizado pelo servi�o de antifraude)
|
6
|
+
attr_accessor :SessionId
|
7
|
+
|
8
|
+
# Endere�o IP do cliente da loja
|
9
|
+
attr_accessor :IpAddress
|
10
|
+
|
11
|
+
# Categoria da venda e-commerce. B2B ou B2C
|
12
|
+
attr_accessor :EcommerceCategory
|
13
|
+
|
14
|
+
def to_json
|
15
|
+
hash = {}
|
16
|
+
instance_variables.each { |var| hash[var.to_s.delete('@')] = instance_variable_get(var) }
|
17
|
+
hash
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class RetrySaleOptions
|
2
|
+
# Indica se o limite extendido est� habilitado
|
3
|
+
attr_accessor :ExtendedLimitEnabled
|
4
|
+
|
5
|
+
# C�digo do limite extendido
|
6
|
+
attr_accessor :ExtendedLimitCode
|
7
|
+
|
8
|
+
def to_json
|
9
|
+
hash = {}
|
10
|
+
instance_variables.each {|var| hash[var.to_s.delete('@')] = instance_variable_get(var) }
|
11
|
+
hash
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require_relative 'retry_sale_options'
|
2
|
+
|
3
|
+
class RetrySaleRequest
|
4
|
+
|
5
|
+
attr_accessor :Options
|
6
|
+
|
7
|
+
attr_accessor :OrderKey
|
8
|
+
|
9
|
+
attr_accessor :RetrySaleCreditCardTransactionCollection
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
@RetrySaleCreditCardTransactionCollection = Array.new
|
13
|
+
@Options = RetrySaleOptions.new
|
14
|
+
end
|
15
|
+
|
16
|
+
def to_json
|
17
|
+
hash = {}
|
18
|
+
instance_variables.each {|var| hash[var.to_s.delete('@')] = instance_variable_get(var) }
|
19
|
+
hash
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class RetrySaleResponse
|
2
|
+
attr_accessor :CreditCardTransactionResultCollection
|
3
|
+
|
4
|
+
def initialize
|
5
|
+
@CreditCardTransactionResultCollection = Array.new
|
6
|
+
end
|
7
|
+
|
8
|
+
def to_json
|
9
|
+
hash = {}
|
10
|
+
instance_variables.each {|var| hash[var.to_s.delete('@')] = instance_variable_get(var) }
|
11
|
+
hash
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require_relative 'sale_order_data'
|
2
|
+
require_relative '../../gateway/AntiFraud/query_sale_anti_fraud_analysis_data'
|
3
|
+
|
4
|
+
class SaleData
|
5
|
+
# Lista transa��es de cart�o de cr�dito
|
6
|
+
attr_accessor :CreditCardTransactionDataCollection
|
7
|
+
|
8
|
+
# Lista as transa��es de boleto
|
9
|
+
attr_accessor :BoletoTransactionDataCollection
|
10
|
+
|
11
|
+
# Dados do pedido
|
12
|
+
attr_accessor :OrderData
|
13
|
+
|
14
|
+
# Chave do comprador. Utilzada para identificar um comprador no gateway
|
15
|
+
attr_accessor :BuyerKey
|
16
|
+
|
17
|
+
# Dados de servi�o do antifraude
|
18
|
+
attr_accessor :AntiFraudAnalysisData
|
19
|
+
|
20
|
+
def initialize
|
21
|
+
@CreditCardTransactionDataCollection = Array.new
|
22
|
+
@BoletoTransactionDataCollection = Array.new
|
23
|
+
@OrderData = SaleOrderData.new
|
24
|
+
@AntiFraudAnalysisData = QuerySaleAntiFraudAnalysisData.new
|
25
|
+
end
|
26
|
+
|
27
|
+
def to_json
|
28
|
+
hash = {}
|
29
|
+
instance_variables.each {|var| hash[var.to_s.delete('@')] = instance_variable_get(var) }
|
30
|
+
hash
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class SaleOrderData
|
2
|
+
# N�mero do pedido no sistema da loja
|
3
|
+
attr_accessor :OrderReference
|
4
|
+
|
5
|
+
# Chave do pedido. Utilizado para identificar o pedido no Gateway
|
6
|
+
attr_accessor :OrderKey
|
7
|
+
|
8
|
+
# Data de cria��o do pedido no Gateway
|
9
|
+
attr_accessor :CreateDate
|
10
|
+
|
11
|
+
def to_json
|
12
|
+
hash = {}
|
13
|
+
instance_variables.each {|var| hash[var.to_s.delete('@')] = instance_variable_get(var) }
|
14
|
+
hash
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class SalesOption
|
2
|
+
|
3
|
+
attr_accessor :IsAntiFraudEnabled
|
4
|
+
|
5
|
+
attr_accessor :AntiFraudServiceCode
|
6
|
+
|
7
|
+
attr_accessor :Retries
|
8
|
+
|
9
|
+
attr_accessor :CurrencyIso
|
10
|
+
|
11
|
+
def to_json
|
12
|
+
hash = {}
|
13
|
+
instance_variables.each {|var| hash[var.to_s.delete('@')] = instance_variable_get(var) }
|
14
|
+
hash
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
class ShoppingCartCollection
|
2
|
+
|
3
|
+
attr_accessor :FreighCostInCents
|
4
|
+
|
5
|
+
attr_accessor :EstimatedDeliveryDate
|
6
|
+
|
7
|
+
attr_accessor :DeliveryDeadline
|
8
|
+
|
9
|
+
attr_accessor :ShippingCompany
|
10
|
+
|
11
|
+
attr_accessor :DeliveryAddress
|
12
|
+
|
13
|
+
attr_accessor :ShoppingCartItemCollection
|
14
|
+
|
15
|
+
def initialize
|
16
|
+
@ShoppingCartItemCollection = Array.new
|
17
|
+
@DeliveryAddress = DeliveryAddress.new
|
18
|
+
end
|
19
|
+
|
20
|
+
def to_json
|
21
|
+
hash = {}
|
22
|
+
instance_variables.each {|var| hash[var.to_s.delete('@')] = instance_variable_get(var) }
|
23
|
+
hash
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
class ShoppingCartItemCollection
|
2
|
+
|
3
|
+
attr_accessor :ItemReference
|
4
|
+
|
5
|
+
attr_accessor :Quantity
|
6
|
+
|
7
|
+
attr_accessor :UnitCostInCents
|
8
|
+
|
9
|
+
attr_accessor :TotalCostInCents
|
10
|
+
|
11
|
+
attr_accessor :Name
|
12
|
+
|
13
|
+
attr_accessor :Description
|
14
|
+
|
15
|
+
attr_accessor :DiscountAmountInCents
|
16
|
+
|
17
|
+
def to_json
|
18
|
+
hash = {}
|
19
|
+
instance_variables.each {|var| hash[var.to_s.delete('@')] = instance_variable_get(var) }
|
20
|
+
hash
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
class Address
|
2
|
+
|
3
|
+
attr_accessor :Country
|
4
|
+
|
5
|
+
attr_accessor :State
|
6
|
+
|
7
|
+
attr_accessor :City
|
8
|
+
|
9
|
+
attr_accessor :District
|
10
|
+
|
11
|
+
attr_accessor :Street
|
12
|
+
|
13
|
+
attr_accessor :Number
|
14
|
+
|
15
|
+
attr_accessor :Complement
|
16
|
+
|
17
|
+
attr_accessor :ZipCode
|
18
|
+
|
19
|
+
def to_json
|
20
|
+
hash = {}
|
21
|
+
instance_variables.each {|var| hash[var.to_s.delete('@')] = instance_variable_get(var) }
|
22
|
+
hash
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -0,0 +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
|
29
|
+
end
|
@@ -0,0 +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
|
45
|
+
end
|
@@ -0,0 +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'
|