stone_ecommerce 1.2.3 → 1.2.4
Sign up to get free protection for your applications and to get access to all the features.
- 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,25 +1,25 @@
|
|
1
|
-
module Gateway
|
2
|
-
|
3
|
-
class ShoppingCartItemCollection
|
4
|
-
|
5
|
-
attr_accessor :ItemReference
|
6
|
-
|
7
|
-
attr_accessor :Quantity
|
8
|
-
|
9
|
-
attr_accessor :UnitCostInCents
|
10
|
-
|
11
|
-
attr_accessor :TotalCostInCents
|
12
|
-
|
13
|
-
attr_accessor :Name
|
14
|
-
|
15
|
-
attr_accessor :Description
|
16
|
-
|
17
|
-
attr_accessor :DiscountAmountInCents
|
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
|
-
end
|
1
|
+
module Gateway
|
2
|
+
|
3
|
+
class ShoppingCartItemCollection
|
4
|
+
|
5
|
+
attr_accessor :ItemReference
|
6
|
+
|
7
|
+
attr_accessor :Quantity
|
8
|
+
|
9
|
+
attr_accessor :UnitCostInCents
|
10
|
+
|
11
|
+
attr_accessor :TotalCostInCents
|
12
|
+
|
13
|
+
attr_accessor :Name
|
14
|
+
|
15
|
+
attr_accessor :Description
|
16
|
+
|
17
|
+
attr_accessor :DiscountAmountInCents
|
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
|
+
end
|
25
25
|
end
|
data/lib/gateway/Trailer.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
module Gateway
|
2
|
-
|
3
|
-
class Trailer
|
4
|
-
attr_accessor :OrderDataCount
|
5
|
-
attr_accessor :CreditCardTransactionDataCount
|
6
|
-
attr_accessor :BoletoTransactionDataCount
|
7
|
-
attr_accessor :OnlineDebitTransactionDataCount
|
8
|
-
end
|
1
|
+
module Gateway
|
2
|
+
|
3
|
+
class Trailer
|
4
|
+
attr_accessor :OrderDataCount
|
5
|
+
attr_accessor :CreditCardTransactionDataCount
|
6
|
+
attr_accessor :BoletoTransactionDataCount
|
7
|
+
attr_accessor :OnlineDebitTransactionDataCount
|
8
|
+
end
|
9
9
|
end
|
data/lib/gateway/header.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
module Gateway
|
2
|
-
|
3
|
-
class Header
|
4
|
-
attr_accessor :TransactionProcessedDate
|
5
|
-
attr_accessor :ReportFileCreateDate
|
6
|
-
attr_accessor :Version
|
7
|
-
end
|
1
|
+
module Gateway
|
2
|
+
|
3
|
+
class Header
|
4
|
+
attr_accessor :TransactionProcessedDate
|
5
|
+
attr_accessor :ReportFileCreateDate
|
6
|
+
attr_accessor :Version
|
7
|
+
end
|
8
8
|
end
|
@@ -1,32 +1,32 @@
|
|
1
|
-
require 'nori'
|
2
|
-
|
3
|
-
module Gateway
|
4
|
-
|
5
|
-
# Class who handles Gateway post notification XML
|
6
|
-
class PostNotification
|
7
|
-
|
8
|
-
# This method parse the Xml sent by Gateway when notify a change in a transaction.
|
9
|
-
#
|
10
|
-
# @param request [String] XML received in the Gateway POST request.
|
11
|
-
# @return [Hash<Symbol, String>] A hash collection containing the XML data parsed.
|
12
|
-
def self.ParseNotification(xml)
|
13
|
-
|
14
|
-
nori = Nori.new(:convert_tags_to => lambda { |tag| PostNotification.to_underscore(tag).to_sym })
|
15
|
-
xml_hash = nori.parse(CGI::unescapeHTML(xml))
|
16
|
-
|
17
|
-
return xml_hash
|
18
|
-
end
|
19
|
-
|
20
|
-
# Converts a string in Camel Case format to lower case with underscore.
|
21
|
-
#
|
22
|
-
# @param Example: 'StatusNotification' outputs 'status_notification'
|
23
|
-
# @returns [String] lower case string separated with underscore
|
24
|
-
def self.to_underscore(camel_case_string)
|
25
|
-
return camel_case_string.gsub(/::/, '/').
|
26
|
-
gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2').
|
27
|
-
gsub(/([a-z\d])([A-Z])/, '\1_\2').
|
28
|
-
tr("-", "_").
|
29
|
-
downcase
|
30
|
-
end
|
31
|
-
end
|
1
|
+
require 'nori'
|
2
|
+
|
3
|
+
module Gateway
|
4
|
+
|
5
|
+
# Class who handles Gateway post notification XML
|
6
|
+
class PostNotification
|
7
|
+
|
8
|
+
# This method parse the Xml sent by Gateway when notify a change in a transaction.
|
9
|
+
#
|
10
|
+
# @param request [String] XML received in the Gateway POST request.
|
11
|
+
# @return [Hash<Symbol, String>] A hash collection containing the XML data parsed.
|
12
|
+
def self.ParseNotification(xml)
|
13
|
+
|
14
|
+
nori = Nori.new(:convert_tags_to => lambda { |tag| PostNotification.to_underscore(tag).to_sym })
|
15
|
+
xml_hash = nori.parse(CGI::unescapeHTML(xml))
|
16
|
+
|
17
|
+
return xml_hash
|
18
|
+
end
|
19
|
+
|
20
|
+
# Converts a string in Camel Case format to lower case with underscore.
|
21
|
+
#
|
22
|
+
# @param Example: 'StatusNotification' outputs 'status_notification'
|
23
|
+
# @returns [String] lower case string separated with underscore
|
24
|
+
def self.to_underscore(camel_case_string)
|
25
|
+
return camel_case_string.gsub(/::/, '/').
|
26
|
+
gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2').
|
27
|
+
gsub(/([a-z\d])([A-Z])/, '\1_\2').
|
28
|
+
tr("-", "_").
|
29
|
+
downcase
|
30
|
+
end
|
31
|
+
end
|
32
32
|
end
|
@@ -1,48 +1,48 @@
|
|
1
|
-
module Gateway
|
2
|
-
|
3
|
-
class TransactionReportFile
|
4
|
-
def TransactionReportFileParser(file_to_parse)
|
5
|
-
response = {}
|
6
|
-
response['CreditCardTransaction'] = []
|
7
|
-
response['OnlineDebitTransaction'] = []
|
8
|
-
response['BoletoTransaction'] = []
|
9
|
-
|
10
|
-
header_parser = HeaderParser.new
|
11
|
-
credit_card_parser = CreditCardTransactionParser.new
|
12
|
-
boleto_parser = BoletoTransactionParser.new
|
13
|
-
online_debit_parser = OnlineDebitTransactionParser.new
|
14
|
-
trailer_parser = TrailerParser.new
|
15
|
-
|
16
|
-
begin
|
17
|
-
response_splited = file_to_parse.split("\n")
|
18
|
-
|
19
|
-
response_splited.each do |item|
|
20
|
-
|
21
|
-
to_parse_item = item.split(',')
|
22
|
-
if to_parse_item[0] == '01'
|
23
|
-
response['Header'] = header_parser.Parse(to_parse_item)
|
24
|
-
end
|
25
|
-
|
26
|
-
if to_parse_item[0] == '20'
|
27
|
-
response['CreditCardTransaction'] << credit_card_parser.Parse(to_parse_item)
|
28
|
-
end
|
29
|
-
|
30
|
-
if to_parse_item[0] == '40'
|
31
|
-
response['OnlineDebitTransaction'] << online_debit_parser.Parse(to_parse_item)
|
32
|
-
end
|
33
|
-
|
34
|
-
if to_parse_item[0] == '30'
|
35
|
-
response['BoletoTransaction'] << boleto_parser.Parse(to_parse_item)
|
36
|
-
end
|
37
|
-
|
38
|
-
if to_parse_item[0] == '99'
|
39
|
-
response['Trailer'] = trailer_parser.Parse(to_parse_item)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
rescue Exception => err
|
43
|
-
return err
|
44
|
-
end
|
45
|
-
return response
|
46
|
-
end
|
47
|
-
end
|
1
|
+
module Gateway
|
2
|
+
|
3
|
+
class TransactionReportFile
|
4
|
+
def TransactionReportFileParser(file_to_parse)
|
5
|
+
response = {}
|
6
|
+
response['CreditCardTransaction'] = []
|
7
|
+
response['OnlineDebitTransaction'] = []
|
8
|
+
response['BoletoTransaction'] = []
|
9
|
+
|
10
|
+
header_parser = HeaderParser.new
|
11
|
+
credit_card_parser = CreditCardTransactionParser.new
|
12
|
+
boleto_parser = BoletoTransactionParser.new
|
13
|
+
online_debit_parser = OnlineDebitTransactionParser.new
|
14
|
+
trailer_parser = TrailerParser.new
|
15
|
+
|
16
|
+
begin
|
17
|
+
response_splited = file_to_parse.split("\n")
|
18
|
+
|
19
|
+
response_splited.each do |item|
|
20
|
+
|
21
|
+
to_parse_item = item.split(',')
|
22
|
+
if to_parse_item[0] == '01'
|
23
|
+
response['Header'] = header_parser.Parse(to_parse_item)
|
24
|
+
end
|
25
|
+
|
26
|
+
if to_parse_item[0] == '20'
|
27
|
+
response['CreditCardTransaction'] << credit_card_parser.Parse(to_parse_item)
|
28
|
+
end
|
29
|
+
|
30
|
+
if to_parse_item[0] == '40'
|
31
|
+
response['OnlineDebitTransaction'] << online_debit_parser.Parse(to_parse_item)
|
32
|
+
end
|
33
|
+
|
34
|
+
if to_parse_item[0] == '30'
|
35
|
+
response['BoletoTransaction'] << boleto_parser.Parse(to_parse_item)
|
36
|
+
end
|
37
|
+
|
38
|
+
if to_parse_item[0] == '99'
|
39
|
+
response['Trailer'] = trailer_parser.Parse(to_parse_item)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
rescue Exception => err
|
43
|
+
return err
|
44
|
+
end
|
45
|
+
return response
|
46
|
+
end
|
47
|
+
end
|
48
48
|
end
|
data/lib/stone_ecommerce.rb
CHANGED
@@ -1,62 +1,61 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'bundler/setup'
|
3
|
-
|
4
|
-
require 'json'
|
5
|
-
require 'rest-client'
|
6
|
-
require 'nori'
|
7
|
-
require '
|
8
|
-
|
9
|
-
|
10
|
-
require_relative 'gateway/BoletoTransaction/
|
11
|
-
require_relative 'gateway/BoletoTransaction/
|
12
|
-
|
13
|
-
|
14
|
-
require_relative 'gateway/CreditCardTransaction/
|
15
|
-
require_relative 'gateway/CreditCardTransaction/
|
16
|
-
require_relative 'gateway/CreditCardTransaction/
|
17
|
-
require_relative 'gateway/CreditCardTransaction/
|
18
|
-
require_relative 'gateway/CreditCardTransaction/
|
19
|
-
|
20
|
-
|
21
|
-
require_relative 'gateway/Address/
|
22
|
-
require_relative 'gateway/Address/
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
require_relative 'gateway/Order/
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
require_relative 'gateway/Parsers/
|
33
|
-
require_relative 'gateway/Parsers/
|
34
|
-
require_relative 'gateway/Parsers/
|
35
|
-
require_relative 'gateway/Parsers/
|
36
|
-
|
37
|
-
|
38
|
-
require_relative 'gateway/Person/
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
require_relative 'gateway/Sale/
|
44
|
-
require_relative 'gateway/Sale/
|
45
|
-
require_relative 'gateway/Sale/
|
46
|
-
require_relative 'gateway/Sale/
|
47
|
-
require_relative 'gateway/Sale/
|
48
|
-
require_relative 'gateway/Sale/
|
49
|
-
|
50
|
-
|
51
|
-
require_relative 'gateway/ShoppingCart/
|
52
|
-
|
53
|
-
|
54
|
-
require_relative 'gateway/
|
55
|
-
require_relative 'gateway/
|
56
|
-
require_relative 'gateway/
|
57
|
-
require_relative 'gateway/
|
58
|
-
require_relative 'gateway/
|
59
|
-
require_relative 'gateway/
|
60
|
-
require_relative 'gateway/InstantBuyData/
|
61
|
-
require_relative 'gateway/
|
62
|
-
require_relative 'gateway/Person/create_buyer_request'
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler/setup'
|
3
|
+
|
4
|
+
require 'json'
|
5
|
+
require 'rest-client'
|
6
|
+
require 'nori'
|
7
|
+
require 'rexml/document'
|
8
|
+
|
9
|
+
require_relative 'gateway/BoletoTransaction/boleto_transaction'
|
10
|
+
require_relative 'gateway/BoletoTransaction/boleto_transaction_options'
|
11
|
+
require_relative 'gateway/BoletoTransaction/boleto_transaction_report_file'
|
12
|
+
|
13
|
+
require_relative 'gateway/CreditCardTransaction/credit_card'
|
14
|
+
require_relative 'gateway/CreditCardTransaction/credit_card_transaction'
|
15
|
+
require_relative 'gateway/CreditCardTransaction/credit_card_transaction_options'
|
16
|
+
require_relative 'gateway/CreditCardTransaction/manage_credit_card_transaction'
|
17
|
+
require_relative 'gateway/CreditCardTransaction/retry_sale_credit_card_transaction'
|
18
|
+
require_relative 'gateway/CreditCardTransaction/credit_card_transaction_report_file'
|
19
|
+
|
20
|
+
require_relative 'gateway/Address/billing_address'
|
21
|
+
require_relative 'gateway/Address/buyer_address'
|
22
|
+
require_relative 'gateway/Address/delivery_address'
|
23
|
+
|
24
|
+
require_relative 'gateway/Merchant/merchant'
|
25
|
+
|
26
|
+
require_relative 'gateway/Order/order'
|
27
|
+
require_relative 'gateway/Order/order_transaction_report_file'
|
28
|
+
|
29
|
+
require_relative 'gateway/OnlineDebit/online_debit_transaction_report_file'
|
30
|
+
|
31
|
+
require_relative 'gateway/Parsers/boleto_transaction_parser'
|
32
|
+
require_relative 'gateway/Parsers/credit_card_transaction_parser'
|
33
|
+
require_relative 'gateway/Parsers/online_debit_transaction_parser'
|
34
|
+
require_relative 'gateway/Parsers/header_parser'
|
35
|
+
require_relative 'gateway/Parsers/trailer_parser'
|
36
|
+
|
37
|
+
require_relative 'gateway/Person/buyer'
|
38
|
+
require_relative 'gateway/Person/person'
|
39
|
+
|
40
|
+
require_relative 'gateway/Recurrency/recurrency'
|
41
|
+
|
42
|
+
require_relative 'gateway/Sale/create_sale_request'
|
43
|
+
require_relative 'gateway/Sale/manage_sale_request'
|
44
|
+
require_relative 'gateway/Sale/query_sale_request'
|
45
|
+
require_relative 'gateway/Sale/request_data'
|
46
|
+
require_relative 'gateway/Sale/retry_sale_options'
|
47
|
+
require_relative 'gateway/Sale/retry_sale_request'
|
48
|
+
require_relative 'gateway/Sale/sale_data'
|
49
|
+
|
50
|
+
require_relative 'gateway/ShoppingCart/shopping_cart'
|
51
|
+
require_relative 'gateway/ShoppingCart/shopping_cart_item'
|
52
|
+
|
53
|
+
require_relative 'gateway/SalesOption'
|
54
|
+
require_relative 'gateway/post_notification'
|
55
|
+
require_relative 'gateway/Gateway'
|
56
|
+
require_relative 'gateway/header'
|
57
|
+
require_relative 'gateway/Trailer'
|
58
|
+
require_relative 'gateway/transaction_report_file'
|
59
|
+
require_relative 'gateway/InstantBuyData/create_instant_buy_data_request'
|
60
|
+
require_relative 'gateway/InstantBuyData/update_instant_buy_data_request'
|
61
|
+
require_relative 'gateway/Person/create_buyer_request'
|