stone_ecommerce 1.2.3 → 1.2.4
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 +4 -4
- data/LICENSE +202 -202
- data/README.md +58 -58
- data/lib/gateway/Address/billing_address.rb +33 -33
- data/lib/gateway/Address/buyer_address.rb +38 -38
- data/lib/gateway/Address/delivery_address.rb +34 -34
- data/lib/gateway/BoletoTransaction/boleto_transaction.rb +40 -40
- data/lib/gateway/BoletoTransaction/boleto_transaction_options.rb +16 -16
- data/lib/gateway/BoletoTransaction/boleto_transaction_report_file.rb +22 -22
- data/lib/gateway/CreditCardTransaction/credit_card.rb +30 -30
- data/lib/gateway/CreditCardTransaction/credit_card_transaction.rb +33 -33
- data/lib/gateway/CreditCardTransaction/credit_card_transaction_options.rb +28 -28
- data/lib/gateway/CreditCardTransaction/credit_card_transaction_report_file.rb +31 -31
- data/lib/gateway/CreditCardTransaction/manage_credit_card_transaction.rb +14 -14
- data/lib/gateway/CreditCardTransaction/retry_sale_credit_card_transaction.rb +14 -14
- data/lib/gateway/Gateway.rb +621 -621
- data/lib/gateway/InstantBuyData/create_instant_buy_data_request.rb +30 -30
- data/lib/gateway/InstantBuyData/update_instant_buy_data_request.rb +10 -10
- data/lib/gateway/Merchant/merchant.rb +12 -12
- data/lib/gateway/OnlineDebit/online_debit_transaction_report_file.rb +21 -21
- data/lib/gateway/Order/order.rb +13 -13
- data/lib/gateway/Order/order_transaction_report_file.rb +8 -8
- data/lib/gateway/Parsers/boleto_transaction_parser.rb +33 -33
- data/lib/gateway/Parsers/credit_card_transaction_parser.rb +42 -42
- data/lib/gateway/Parsers/header_parser.rb +16 -16
- data/lib/gateway/Parsers/online_debit_transaction_parser.rb +32 -32
- data/lib/gateway/Parsers/trailer_parser.rb +16 -16
- data/lib/gateway/Person/buyer.rb +32 -32
- data/lib/gateway/Person/create_buyer_request.rb +22 -22
- data/lib/gateway/Person/person.rb +48 -48
- data/lib/gateway/Recurrency/recurrency.rb +24 -24
- data/lib/gateway/Sale/create_sale_request.rb +37 -37
- data/lib/gateway/Sale/manage_sale_request.rb +18 -18
- data/lib/gateway/Sale/query_sale_request.rb +37 -37
- data/lib/gateway/Sale/request_data.rb +21 -21
- data/lib/gateway/Sale/retry_sale_options.rb +15 -15
- data/lib/gateway/Sale/retry_sale_request.rb +23 -23
- data/lib/gateway/Sale/sale_data.rb +30 -30
- data/lib/gateway/Sale/sale_order_data.rb +18 -18
- data/lib/gateway/SalesOption.rb +18 -18
- data/lib/gateway/ShoppingCart/shopping_cart.rb +27 -27
- data/lib/gateway/ShoppingCart/shopping_cart_item.rb +24 -24
- data/lib/gateway/Trailer.rb +8 -8
- data/lib/gateway/header.rb +7 -7
- data/lib/gateway/post_notification.rb +31 -31
- data/lib/gateway/transaction_report_file.rb +47 -47
- data/lib/stone_ecommerce.rb +61 -62
- data/spec/integration/gateway_spec.rb +1024 -1024
- data/spec/integration/test_helper.rb +68 -68
- data/stone_ecommerce.gemspec +20 -19
- metadata +27 -24
@@ -1,31 +1,31 @@
|
|
1
|
-
module Gateway
|
2
|
-
class CreateInstantBuyDataRequest
|
3
|
-
attr_accessor :IsOneDollarAuthEnabled
|
4
|
-
|
5
|
-
attr_accessor :CreditCardNumber
|
6
|
-
|
7
|
-
attr_accessor :HolderName
|
8
|
-
|
9
|
-
attr_accessor :SecurityCode
|
10
|
-
|
11
|
-
attr_accessor :ExpMonth
|
12
|
-
|
13
|
-
attr_accessor :ExpYear
|
14
|
-
|
15
|
-
attr_accessor :CreditCardBrand
|
16
|
-
|
17
|
-
attr_accessor :BillingAddress
|
18
|
-
|
19
|
-
attr_accessor :BuyerKey
|
20
|
-
|
21
|
-
def initialize
|
22
|
-
@BillingAddress = BillingAddress.new
|
23
|
-
end
|
24
|
-
|
25
|
-
def to_json
|
26
|
-
hash = {}
|
27
|
-
instance_variables.each { |var| hash[var.to_s.delete('@')] = instance_variable_get(var) }
|
28
|
-
hash
|
29
|
-
end
|
30
|
-
end
|
1
|
+
module Gateway
|
2
|
+
class CreateInstantBuyDataRequest
|
3
|
+
attr_accessor :IsOneDollarAuthEnabled
|
4
|
+
|
5
|
+
attr_accessor :CreditCardNumber
|
6
|
+
|
7
|
+
attr_accessor :HolderName
|
8
|
+
|
9
|
+
attr_accessor :SecurityCode
|
10
|
+
|
11
|
+
attr_accessor :ExpMonth
|
12
|
+
|
13
|
+
attr_accessor :ExpYear
|
14
|
+
|
15
|
+
attr_accessor :CreditCardBrand
|
16
|
+
|
17
|
+
attr_accessor :BillingAddress
|
18
|
+
|
19
|
+
attr_accessor :BuyerKey
|
20
|
+
|
21
|
+
def initialize
|
22
|
+
@BillingAddress = BillingAddress.new
|
23
|
+
end
|
24
|
+
|
25
|
+
def to_json
|
26
|
+
hash = {}
|
27
|
+
instance_variables.each { |var| hash[var.to_s.delete('@')] = instance_variable_get(var) }
|
28
|
+
hash
|
29
|
+
end
|
30
|
+
end
|
31
31
|
end
|
@@ -1,11 +1,11 @@
|
|
1
|
-
module Gateway
|
2
|
-
class UpdateInstantBuyDataRequest
|
3
|
-
attr_accessor :BuyerKey
|
4
|
-
|
5
|
-
def to_json
|
6
|
-
hash = {}
|
7
|
-
instance_variables.each { |var| hash[var.to_s.delete('@')] = instance_variable_get(var) }
|
8
|
-
hash
|
9
|
-
end
|
10
|
-
end
|
1
|
+
module Gateway
|
2
|
+
class UpdateInstantBuyDataRequest
|
3
|
+
attr_accessor :BuyerKey
|
4
|
+
|
5
|
+
def to_json
|
6
|
+
hash = {}
|
7
|
+
instance_variables.each { |var| hash[var.to_s.delete('@')] = instance_variable_get(var) }
|
8
|
+
hash
|
9
|
+
end
|
10
|
+
end
|
11
11
|
end
|
@@ -1,13 +1,13 @@
|
|
1
|
-
module Gateway
|
2
|
-
|
3
|
-
class Merchant
|
4
|
-
# Identificador da loja na plataforma
|
5
|
-
attr_accessor :MerchantReference
|
6
|
-
|
7
|
-
def to_json
|
8
|
-
hash = {}
|
9
|
-
instance_variables.each { |var| hash[var.to_s.delete('@')] = instance_variable_get(var) }
|
10
|
-
hash
|
11
|
-
end
|
12
|
-
end
|
1
|
+
module Gateway
|
2
|
+
|
3
|
+
class Merchant
|
4
|
+
# Identificador da loja na plataforma
|
5
|
+
attr_accessor :MerchantReference
|
6
|
+
|
7
|
+
def to_json
|
8
|
+
hash = {}
|
9
|
+
instance_variables.each { |var| hash[var.to_s.delete('@')] = instance_variable_get(var) }
|
10
|
+
hash
|
11
|
+
end
|
12
|
+
end
|
13
13
|
end
|
@@ -1,21 +1,21 @@
|
|
1
|
-
module Gateway
|
2
|
-
|
3
|
-
class OnlineDebitTransactionReportFile
|
4
|
-
attr_accessor :Order
|
5
|
-
attr_accessor :TransactionKey
|
6
|
-
attr_accessor :TransactionReference
|
7
|
-
attr_accessor :Bank
|
8
|
-
attr_accessor :Status
|
9
|
-
attr_accessor :AmountInCents
|
10
|
-
attr_accessor :AmountPaidInCents
|
11
|
-
attr_accessor :PaymentDate
|
12
|
-
attr_accessor :BankReturnCode
|
13
|
-
attr_accessor :BankPaymentDate
|
14
|
-
attr_accessor :Signature
|
15
|
-
attr_accessor :TransactionKeyToBank
|
16
|
-
|
17
|
-
def initialize
|
18
|
-
@Order = OrderTransactionReportFile.new
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
1
|
+
module Gateway
|
2
|
+
|
3
|
+
class OnlineDebitTransactionReportFile
|
4
|
+
attr_accessor :Order
|
5
|
+
attr_accessor :TransactionKey
|
6
|
+
attr_accessor :TransactionReference
|
7
|
+
attr_accessor :Bank
|
8
|
+
attr_accessor :Status
|
9
|
+
attr_accessor :AmountInCents
|
10
|
+
attr_accessor :AmountPaidInCents
|
11
|
+
attr_accessor :PaymentDate
|
12
|
+
attr_accessor :BankReturnCode
|
13
|
+
attr_accessor :BankPaymentDate
|
14
|
+
attr_accessor :Signature
|
15
|
+
attr_accessor :TransactionKeyToBank
|
16
|
+
|
17
|
+
def initialize
|
18
|
+
@Order = OrderTransactionReportFile.new
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/gateway/Order/order.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
|
-
module Gateway
|
2
|
-
|
3
|
-
class Order
|
4
|
-
# Identificador do pedido no sistema da loja
|
5
|
-
attr_accessor :OrderReference
|
6
|
-
|
7
|
-
def to_json
|
8
|
-
hash = {}
|
9
|
-
instance_variables.each { |var| hash[var.to_s.delete('@')] = instance_variable_get(var) }
|
10
|
-
hash
|
11
|
-
end
|
12
|
-
|
13
|
-
end
|
1
|
+
module Gateway
|
2
|
+
|
3
|
+
class Order
|
4
|
+
# Identificador do pedido no sistema da loja
|
5
|
+
attr_accessor :OrderReference
|
6
|
+
|
7
|
+
def to_json
|
8
|
+
hash = {}
|
9
|
+
instance_variables.each { |var| hash[var.to_s.delete('@')] = instance_variable_get(var) }
|
10
|
+
hash
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
14
|
end
|
@@ -1,9 +1,9 @@
|
|
1
|
-
module Gateway
|
2
|
-
|
3
|
-
class OrderTransactionReportFile
|
4
|
-
attr_accessor :OrderKey
|
5
|
-
attr_accessor :OrderReference
|
6
|
-
attr_accessor :MerchantKey
|
7
|
-
attr_accessor :MerchantName
|
8
|
-
end
|
1
|
+
module Gateway
|
2
|
+
|
3
|
+
class OrderTransactionReportFile
|
4
|
+
attr_accessor :OrderKey
|
5
|
+
attr_accessor :OrderReference
|
6
|
+
attr_accessor :MerchantKey
|
7
|
+
attr_accessor :MerchantName
|
8
|
+
end
|
9
9
|
end
|
@@ -1,34 +1,34 @@
|
|
1
|
-
module Gateway
|
2
|
-
|
3
|
-
class BoletoTransactionParser
|
4
|
-
def Parse(elements)
|
5
|
-
@@DATETIME_FORMAT = '%Y-%m-%d %H:%M:%S'
|
6
|
-
|
7
|
-
if elements.length < 18
|
8
|
-
throw('The expected parameter count is 18')
|
9
|
-
end
|
10
|
-
|
11
|
-
boleto_transaction = BoletoTransactionReportFile.new
|
12
|
-
boleto_transaction.Order.OrderKey = elements[1]
|
13
|
-
boleto_transaction.Order.OrderReference = elements[2]
|
14
|
-
boleto_transaction.Order.MerchantKey = elements[3]
|
15
|
-
boleto_transaction.Order.MerchantName = elements[4]
|
16
|
-
|
17
|
-
boleto_transaction.TransactionKey = elements[5]
|
18
|
-
boleto_transaction.TransactionReference = elements[6]
|
19
|
-
boleto_transaction.Status = elements[7]
|
20
|
-
boleto_transaction.NossoNumero = elements[8]
|
21
|
-
boleto_transaction.BankNumber = elements[9]
|
22
|
-
boleto_transaction.Agency = elements[10]
|
23
|
-
boleto_transaction.Account = elements[11]
|
24
|
-
boleto_transaction.BarCode = elements[12]
|
25
|
-
boleto_transaction.ExpirationDate = DateTime.strptime(elements[13], '%m/%d/%Y %H:%M:%S').strftime(@@DATETIME_FORMAT)
|
26
|
-
boleto_transaction.AmountInCents = elements[14].to_i
|
27
|
-
boleto_transaction.AmountPaidInCents = (elements[15].to_s == '') == false ? elements[15].to_i : 0
|
28
|
-
boleto_transaction.PaymentDate = (elements[16].to_s == '') == false ? DateTime.strptime(elements[16], '%m/%d/%Y %H:%M:%S').strftime(@@DATETIME_FORMAT) : nil
|
29
|
-
boleto_transaction.CreditDate = (elements[17].chomp.to_s == '') == false ? DateTime.strptime(elements[17], '%m/%d/%Y %H:%M:%S').strftime(@@DATETIME_FORMAT) : nil
|
30
|
-
|
31
|
-
return boleto_transaction
|
32
|
-
end
|
33
|
-
end
|
1
|
+
module Gateway
|
2
|
+
|
3
|
+
class BoletoTransactionParser
|
4
|
+
def Parse(elements)
|
5
|
+
@@DATETIME_FORMAT = '%Y-%m-%d %H:%M:%S'
|
6
|
+
|
7
|
+
if elements.length < 18
|
8
|
+
throw('The expected parameter count is 18')
|
9
|
+
end
|
10
|
+
|
11
|
+
boleto_transaction = BoletoTransactionReportFile.new
|
12
|
+
boleto_transaction.Order.OrderKey = elements[1]
|
13
|
+
boleto_transaction.Order.OrderReference = elements[2]
|
14
|
+
boleto_transaction.Order.MerchantKey = elements[3]
|
15
|
+
boleto_transaction.Order.MerchantName = elements[4]
|
16
|
+
|
17
|
+
boleto_transaction.TransactionKey = elements[5]
|
18
|
+
boleto_transaction.TransactionReference = elements[6]
|
19
|
+
boleto_transaction.Status = elements[7]
|
20
|
+
boleto_transaction.NossoNumero = elements[8]
|
21
|
+
boleto_transaction.BankNumber = elements[9]
|
22
|
+
boleto_transaction.Agency = elements[10]
|
23
|
+
boleto_transaction.Account = elements[11]
|
24
|
+
boleto_transaction.BarCode = elements[12]
|
25
|
+
boleto_transaction.ExpirationDate = DateTime.strptime(elements[13], '%m/%d/%Y %H:%M:%S').strftime(@@DATETIME_FORMAT)
|
26
|
+
boleto_transaction.AmountInCents = elements[14].to_i
|
27
|
+
boleto_transaction.AmountPaidInCents = (elements[15].to_s == '') == false ? elements[15].to_i : 0
|
28
|
+
boleto_transaction.PaymentDate = (elements[16].to_s == '') == false ? DateTime.strptime(elements[16], '%m/%d/%Y %H:%M:%S').strftime(@@DATETIME_FORMAT) : nil
|
29
|
+
boleto_transaction.CreditDate = (elements[17].chomp.to_s == '') == false ? DateTime.strptime(elements[17], '%m/%d/%Y %H:%M:%S').strftime(@@DATETIME_FORMAT) : nil
|
30
|
+
|
31
|
+
return boleto_transaction
|
32
|
+
end
|
33
|
+
end
|
34
34
|
end
|
@@ -1,43 +1,43 @@
|
|
1
|
-
module Gateway
|
2
|
-
|
3
|
-
class CreditCardTransactionParser
|
4
|
-
def Parse(elements)
|
5
|
-
@@DATETIME_FORMAT = '%Y-%m-%d %H:%M:%S'
|
6
|
-
|
7
|
-
if elements.length < 27
|
8
|
-
throw('The expected parameter count is 27')
|
9
|
-
end
|
10
|
-
|
11
|
-
credit_card_transaction = CreditCardTransactionReportFile.new
|
12
|
-
credit_card_transaction.Order.OrderKey = elements[1]
|
13
|
-
credit_card_transaction.Order.OrderReference = elements[2]
|
14
|
-
credit_card_transaction.Order.MerchantKey = elements[3]
|
15
|
-
credit_card_transaction.Order.MerchantName = elements[4]
|
16
|
-
|
17
|
-
credit_card_transaction.TransactionKey = elements[5]
|
18
|
-
credit_card_transaction.TransactionKeyToAcquirer = elements[6]
|
19
|
-
credit_card_transaction.CreditCardTransactionReference = elements[7]
|
20
|
-
credit_card_transaction.CreditCardBrand = elements[8]
|
21
|
-
credit_card_transaction.CreditCardNumber = elements[9]
|
22
|
-
credit_card_transaction.InstallmentCount = (elements[10].to_s == '') == false ? elements[10].to_i : 0
|
23
|
-
credit_card_transaction.AcquirerName = elements[11]
|
24
|
-
credit_card_transaction.Status = elements[12]
|
25
|
-
credit_card_transaction.AmountInCents = (elements[13].to_s == '') == false ? elements[13].to_i : 0
|
26
|
-
credit_card_transaction.IataAmountInCents = (elements[14].to_s == '') == false ? elements[14].to_i : 0
|
27
|
-
credit_card_transaction.AuthorizationCode = elements[15]
|
28
|
-
credit_card_transaction.TransactionIdentifier = elements[16]
|
29
|
-
credit_card_transaction.UniqueSequentialNumber = elements[17]
|
30
|
-
credit_card_transaction.AuthorizedAmountInCents = (elements[18].to_s == '') == false ? elements[18].to_i : 0
|
31
|
-
credit_card_transaction.CapturedAmountInCents = (elements[19].to_s == '') == false ? elements[19].to_i : 0
|
32
|
-
credit_card_transaction.VoidedAmountInCents = (elements[20].to_s == '') == false ? elements[20].to_i : 0
|
33
|
-
credit_card_transaction.RefundedAmountInCents = (elements[21].to_s == '') == false ? elements[21].to_i : 0
|
34
|
-
credit_card_transaction.AcquirerAuthorizationReturnCode = elements[22]
|
35
|
-
credit_card_transaction.AuthorizedDate = (elements[23].to_s == '') == false ? DateTime.strptime(elements[23], '%Y-%m-%dT%H:%M:%S').strftime(@@DATETIME_FORMAT) : nil
|
36
|
-
credit_card_transaction.CapturedDate = (elements[24].to_s == '') == false ? DateTime.strptime(elements[24], '%Y-%m-%dT%H:%M:%S').strftime(@@DATETIME_FORMAT) : nil
|
37
|
-
credit_card_transaction.VoidedDate = (elements[25].to_s == '') == false ? DateTime.strptime(elements[25], '%Y-%m-%dT%H:%M:%S').strftime(@@DATETIME_FORMAT) : nil
|
38
|
-
credit_card_transaction.LastProbeDate = (elements[26].chomp.to_s == '') == false ? DateTime.strptime(elements[26], '%Y-%m-%dT%H:%M:%S').strftime(@@DATETIME_FORMAT) : nil
|
39
|
-
|
40
|
-
return credit_card_transaction
|
41
|
-
end
|
42
|
-
end
|
1
|
+
module Gateway
|
2
|
+
|
3
|
+
class CreditCardTransactionParser
|
4
|
+
def Parse(elements)
|
5
|
+
@@DATETIME_FORMAT = '%Y-%m-%d %H:%M:%S'
|
6
|
+
|
7
|
+
if elements.length < 27
|
8
|
+
throw('The expected parameter count is 27')
|
9
|
+
end
|
10
|
+
|
11
|
+
credit_card_transaction = CreditCardTransactionReportFile.new
|
12
|
+
credit_card_transaction.Order.OrderKey = elements[1]
|
13
|
+
credit_card_transaction.Order.OrderReference = elements[2]
|
14
|
+
credit_card_transaction.Order.MerchantKey = elements[3]
|
15
|
+
credit_card_transaction.Order.MerchantName = elements[4]
|
16
|
+
|
17
|
+
credit_card_transaction.TransactionKey = elements[5]
|
18
|
+
credit_card_transaction.TransactionKeyToAcquirer = elements[6]
|
19
|
+
credit_card_transaction.CreditCardTransactionReference = elements[7]
|
20
|
+
credit_card_transaction.CreditCardBrand = elements[8]
|
21
|
+
credit_card_transaction.CreditCardNumber = elements[9]
|
22
|
+
credit_card_transaction.InstallmentCount = (elements[10].to_s == '') == false ? elements[10].to_i : 0
|
23
|
+
credit_card_transaction.AcquirerName = elements[11]
|
24
|
+
credit_card_transaction.Status = elements[12]
|
25
|
+
credit_card_transaction.AmountInCents = (elements[13].to_s == '') == false ? elements[13].to_i : 0
|
26
|
+
credit_card_transaction.IataAmountInCents = (elements[14].to_s == '') == false ? elements[14].to_i : 0
|
27
|
+
credit_card_transaction.AuthorizationCode = elements[15]
|
28
|
+
credit_card_transaction.TransactionIdentifier = elements[16]
|
29
|
+
credit_card_transaction.UniqueSequentialNumber = elements[17]
|
30
|
+
credit_card_transaction.AuthorizedAmountInCents = (elements[18].to_s == '') == false ? elements[18].to_i : 0
|
31
|
+
credit_card_transaction.CapturedAmountInCents = (elements[19].to_s == '') == false ? elements[19].to_i : 0
|
32
|
+
credit_card_transaction.VoidedAmountInCents = (elements[20].to_s == '') == false ? elements[20].to_i : 0
|
33
|
+
credit_card_transaction.RefundedAmountInCents = (elements[21].to_s == '') == false ? elements[21].to_i : 0
|
34
|
+
credit_card_transaction.AcquirerAuthorizationReturnCode = elements[22]
|
35
|
+
credit_card_transaction.AuthorizedDate = (elements[23].to_s == '') == false ? DateTime.strptime(elements[23], '%Y-%m-%dT%H:%M:%S').strftime(@@DATETIME_FORMAT) : nil
|
36
|
+
credit_card_transaction.CapturedDate = (elements[24].to_s == '') == false ? DateTime.strptime(elements[24], '%Y-%m-%dT%H:%M:%S').strftime(@@DATETIME_FORMAT) : nil
|
37
|
+
credit_card_transaction.VoidedDate = (elements[25].to_s == '') == false ? DateTime.strptime(elements[25], '%Y-%m-%dT%H:%M:%S').strftime(@@DATETIME_FORMAT) : nil
|
38
|
+
credit_card_transaction.LastProbeDate = (elements[26].chomp.to_s == '') == false ? DateTime.strptime(elements[26], '%Y-%m-%dT%H:%M:%S').strftime(@@DATETIME_FORMAT) : nil
|
39
|
+
|
40
|
+
return credit_card_transaction
|
41
|
+
end
|
42
|
+
end
|
43
43
|
end
|
@@ -1,17 +1,17 @@
|
|
1
|
-
module Gateway
|
2
|
-
|
3
|
-
class HeaderParser
|
4
|
-
def Parse(elements)
|
5
|
-
if elements.length < 4
|
6
|
-
throw('The expected parameter count is 4')
|
7
|
-
end
|
8
|
-
|
9
|
-
header = Header.new
|
10
|
-
header.TransactionProcessedDate = Date.parse(elements[1]).strftime('%Y%m%d')
|
11
|
-
header.ReportFileCreateDate = Date.parse(elements[2]).strftime('%Y%m%d %H:%M:%S')
|
12
|
-
header.Version = elements[3].chomp
|
13
|
-
|
14
|
-
return header
|
15
|
-
end
|
16
|
-
end
|
1
|
+
module Gateway
|
2
|
+
|
3
|
+
class HeaderParser
|
4
|
+
def Parse(elements)
|
5
|
+
if elements.length < 4
|
6
|
+
throw('The expected parameter count is 4')
|
7
|
+
end
|
8
|
+
|
9
|
+
header = Header.new
|
10
|
+
header.TransactionProcessedDate = Date.parse(elements[1]).strftime('%Y%m%d')
|
11
|
+
header.ReportFileCreateDate = Date.parse(elements[2]).strftime('%Y%m%d %H:%M:%S')
|
12
|
+
header.Version = elements[3].chomp
|
13
|
+
|
14
|
+
return header
|
15
|
+
end
|
16
|
+
end
|
17
17
|
end
|
@@ -1,33 +1,33 @@
|
|
1
|
-
module Gateway
|
2
|
-
|
3
|
-
class OnlineDebitTransactionParser
|
4
|
-
def Parse(elements)
|
5
|
-
@@DATETIME_FORMAT = '%Y-%m-%d %H:%M:%S'
|
6
|
-
|
7
|
-
if elements.length < 16
|
8
|
-
throw('The expected parameter count is 16')
|
9
|
-
end
|
10
|
-
|
11
|
-
online_debit_transaction = OnlineDebitTransactionReportFile.new
|
12
|
-
|
13
|
-
online_debit_transaction.Order.OrderKey = elements[1]
|
14
|
-
online_debit_transaction.Order.OrderReference = elements[2]
|
15
|
-
online_debit_transaction.Order.MerchantKey = elements[3]
|
16
|
-
online_debit_transaction.Order.MerchantName = elements[4]
|
17
|
-
|
18
|
-
online_debit_transaction.TransactionKey = elements[5]
|
19
|
-
online_debit_transaction.TransactionReference = elements[6]
|
20
|
-
online_debit_transaction.Bank = elements[7]
|
21
|
-
online_debit_transaction.Status = elements[8]
|
22
|
-
online_debit_transaction.AmountInCents = elements[9].to_i
|
23
|
-
online_debit_transaction.AmountPaidInCents = (elements[10].to_s == '') == false ? elements[10].to_i : 0
|
24
|
-
online_debit_transaction.PaymentDate = (elements[11].to_s == '') == false ? DateTime.strptime(elements[11], '%m/%d/%Y %H:%M:%S').strftime(@@DATETIME_FORMAT) : nil
|
25
|
-
online_debit_transaction.BankReturnCode = elements[12]
|
26
|
-
online_debit_transaction.BankPaymentDate = elements[13]
|
27
|
-
online_debit_transaction.Signature = elements[14]
|
28
|
-
online_debit_transaction.TransactionKeyToBank = elements[15].chomp
|
29
|
-
|
30
|
-
return online_debit_transaction
|
31
|
-
end
|
32
|
-
end
|
1
|
+
module Gateway
|
2
|
+
|
3
|
+
class OnlineDebitTransactionParser
|
4
|
+
def Parse(elements)
|
5
|
+
@@DATETIME_FORMAT = '%Y-%m-%d %H:%M:%S'
|
6
|
+
|
7
|
+
if elements.length < 16
|
8
|
+
throw('The expected parameter count is 16')
|
9
|
+
end
|
10
|
+
|
11
|
+
online_debit_transaction = OnlineDebitTransactionReportFile.new
|
12
|
+
|
13
|
+
online_debit_transaction.Order.OrderKey = elements[1]
|
14
|
+
online_debit_transaction.Order.OrderReference = elements[2]
|
15
|
+
online_debit_transaction.Order.MerchantKey = elements[3]
|
16
|
+
online_debit_transaction.Order.MerchantName = elements[4]
|
17
|
+
|
18
|
+
online_debit_transaction.TransactionKey = elements[5]
|
19
|
+
online_debit_transaction.TransactionReference = elements[6]
|
20
|
+
online_debit_transaction.Bank = elements[7]
|
21
|
+
online_debit_transaction.Status = elements[8]
|
22
|
+
online_debit_transaction.AmountInCents = elements[9].to_i
|
23
|
+
online_debit_transaction.AmountPaidInCents = (elements[10].to_s == '') == false ? elements[10].to_i : 0
|
24
|
+
online_debit_transaction.PaymentDate = (elements[11].to_s == '') == false ? DateTime.strptime(elements[11], '%m/%d/%Y %H:%M:%S').strftime(@@DATETIME_FORMAT) : nil
|
25
|
+
online_debit_transaction.BankReturnCode = elements[12]
|
26
|
+
online_debit_transaction.BankPaymentDate = elements[13]
|
27
|
+
online_debit_transaction.Signature = elements[14]
|
28
|
+
online_debit_transaction.TransactionKeyToBank = elements[15].chomp
|
29
|
+
|
30
|
+
return online_debit_transaction
|
31
|
+
end
|
32
|
+
end
|
33
33
|
end
|
@@ -1,17 +1,17 @@
|
|
1
|
-
module Gateway
|
2
|
-
class TrailerParser
|
3
|
-
def Parse(elements)
|
4
|
-
if elements.length < 5
|
5
|
-
throw('The expected parameter count is 5')
|
6
|
-
end
|
7
|
-
|
8
|
-
trailer = Trailer.new
|
9
|
-
trailer.OrderDataCount = elements[1]
|
10
|
-
trailer.CreditCardTransactionDataCount = elements[2]
|
11
|
-
trailer.BoletoTransactionDataCount = elements[3]
|
12
|
-
trailer.OnlineDebitTransactionDataCount = elements[4].chomp
|
13
|
-
|
14
|
-
return trailer
|
15
|
-
end
|
16
|
-
end
|
1
|
+
module Gateway
|
2
|
+
class TrailerParser
|
3
|
+
def Parse(elements)
|
4
|
+
if elements.length < 5
|
5
|
+
throw('The expected parameter count is 5')
|
6
|
+
end
|
7
|
+
|
8
|
+
trailer = Trailer.new
|
9
|
+
trailer.OrderDataCount = elements[1]
|
10
|
+
trailer.CreditCardTransactionDataCount = elements[2]
|
11
|
+
trailer.BoletoTransactionDataCount = elements[3]
|
12
|
+
trailer.OnlineDebitTransactionDataCount = elements[4].chomp
|
13
|
+
|
14
|
+
return trailer
|
15
|
+
end
|
16
|
+
end
|
17
17
|
end
|
data/lib/gateway/Person/buyer.rb
CHANGED
@@ -1,33 +1,33 @@
|
|
1
|
-
require_relative 'person'
|
2
|
-
module Gateway
|
3
|
-
|
4
|
-
class Buyer < Person
|
5
|
-
# Chave do comprador. Utilizada para identificar um comprador no gateway
|
6
|
-
attr_accessor :BuyerKey
|
7
|
-
|
8
|
-
# Refer�ncia do comprador no sistema da loja
|
9
|
-
attr_accessor :BuyerReference
|
10
|
-
|
11
|
-
# Lista de endere�os do comprador
|
12
|
-
attr_accessor :AddressCollection
|
13
|
-
|
14
|
-
# Data de cria��o do comprador no sistema da loja
|
15
|
-
attr_accessor :CreateDateInMerchant
|
16
|
-
|
17
|
-
# Data da �ltima atualiza��o do cadastro do comprador no sistema da loja
|
18
|
-
attr_accessor :LastBuyerUpdateInMerchant
|
19
|
-
|
20
|
-
# Categoria do comprador
|
21
|
-
attr_accessor :BuyerCategory
|
22
|
-
|
23
|
-
def initialize
|
24
|
-
@AddressCollection = Array.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
|
-
end
|
1
|
+
require_relative 'person'
|
2
|
+
module Gateway
|
3
|
+
|
4
|
+
class Buyer < Person
|
5
|
+
# Chave do comprador. Utilizada para identificar um comprador no gateway
|
6
|
+
attr_accessor :BuyerKey
|
7
|
+
|
8
|
+
# Refer�ncia do comprador no sistema da loja
|
9
|
+
attr_accessor :BuyerReference
|
10
|
+
|
11
|
+
# Lista de endere�os do comprador
|
12
|
+
attr_accessor :AddressCollection
|
13
|
+
|
14
|
+
# Data de cria��o do comprador no sistema da loja
|
15
|
+
attr_accessor :CreateDateInMerchant
|
16
|
+
|
17
|
+
# Data da �ltima atualiza��o do cadastro do comprador no sistema da loja
|
18
|
+
attr_accessor :LastBuyerUpdateInMerchant
|
19
|
+
|
20
|
+
# Categoria do comprador
|
21
|
+
attr_accessor :BuyerCategory
|
22
|
+
|
23
|
+
def initialize
|
24
|
+
@AddressCollection = Array.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
|
+
end
|
33
33
|
end
|
@@ -1,23 +1,23 @@
|
|
1
|
-
module Gateway
|
2
|
-
class CreateBuyerRequest < Person
|
3
|
-
attr_accessor :AddressCollection
|
4
|
-
|
5
|
-
attr_accessor :BuyerCategory
|
6
|
-
|
7
|
-
attr_accessor :BuyerReference
|
8
|
-
|
9
|
-
attr_accessor :CreateDateInMerchant
|
10
|
-
|
11
|
-
attr_accessor :LastBuyerUpdateInMerchant
|
12
|
-
|
13
|
-
def initialize
|
14
|
-
@AddressCollection = Array.new
|
15
|
-
end
|
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
|
-
end
|
1
|
+
module Gateway
|
2
|
+
class CreateBuyerRequest < Person
|
3
|
+
attr_accessor :AddressCollection
|
4
|
+
|
5
|
+
attr_accessor :BuyerCategory
|
6
|
+
|
7
|
+
attr_accessor :BuyerReference
|
8
|
+
|
9
|
+
attr_accessor :CreateDateInMerchant
|
10
|
+
|
11
|
+
attr_accessor :LastBuyerUpdateInMerchant
|
12
|
+
|
13
|
+
def initialize
|
14
|
+
@AddressCollection = Array.new
|
15
|
+
end
|
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
|
+
end
|
23
23
|
end
|