genesis_ruby 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (132) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +11 -0
  3. data/Gemfile +6 -0
  4. data/Gemfile.lock +158 -0
  5. data/LICENSE +21 -0
  6. data/README.md +343 -0
  7. data/Rakefile +12 -0
  8. data/VERSION +1 -0
  9. data/genesis_ruby.gemspec +43 -0
  10. data/lib/genesis_ruby/api/constants/currencies/iso4217.rb +1106 -0
  11. data/lib/genesis_ruby/api/constants/date_time_formats.rb +45 -0
  12. data/lib/genesis_ruby/api/constants/endpoints.rb +18 -0
  13. data/lib/genesis_ruby/api/constants/environments.rb +17 -0
  14. data/lib/genesis_ruby/api/constants/states/state.rb +43 -0
  15. data/lib/genesis_ruby/api/constants/states.rb +86 -0
  16. data/lib/genesis_ruby/api/constants/transactions/parameters/business/payment_types.rb +24 -0
  17. data/lib/genesis_ruby/api/constants/transactions/parameters/recurring/categories.rb +24 -0
  18. data/lib/genesis_ruby/api/constants/transactions/parameters/recurring/types.rb +28 -0
  19. data/lib/genesis_ruby/api/constants/transactions/parameters/sca_exemptions.rb +34 -0
  20. data/lib/genesis_ruby/api/constants/transactions/parameters/threeds/version2/browser/color_depths.rb +46 -0
  21. data/lib/genesis_ruby/api/constants/transactions/parameters/threeds/version2/card_holder_account/password_change_indicators.rb +37 -0
  22. data/lib/genesis_ruby/api/constants/transactions/parameters/threeds/version2/card_holder_account/registration_indicators.rb +37 -0
  23. data/lib/genesis_ruby/api/constants/transactions/parameters/threeds/version2/card_holder_account/shipping_address_usage_indicators.rb +34 -0
  24. data/lib/genesis_ruby/api/constants/transactions/parameters/threeds/version2/card_holder_account/suspicious_activity_indicators.rb +28 -0
  25. data/lib/genesis_ruby/api/constants/transactions/parameters/threeds/version2/card_holder_account/update_indicators.rb +34 -0
  26. data/lib/genesis_ruby/api/constants/transactions/parameters/threeds/version2/control/challenge_indicators.rb +34 -0
  27. data/lib/genesis_ruby/api/constants/transactions/parameters/threeds/version2/control/challenge_window_sizes.rb +37 -0
  28. data/lib/genesis_ruby/api/constants/transactions/parameters/threeds/version2/control/device_types.rb +28 -0
  29. data/lib/genesis_ruby/api/constants/transactions/parameters/threeds/version2/merchant_risk/delivery_timeframes.rb +34 -0
  30. data/lib/genesis_ruby/api/constants/transactions/parameters/threeds/version2/merchant_risk/pre_order_purchase_indicators.rb +28 -0
  31. data/lib/genesis_ruby/api/constants/transactions/parameters/threeds/version2/merchant_risk/reorder_item_indicators.rb +28 -0
  32. data/lib/genesis_ruby/api/constants/transactions/parameters/threeds/version2/merchant_risk/shipping_indicators.rb +46 -0
  33. data/lib/genesis_ruby/api/constants/transactions/parameters/threeds/version2/purchase/categories.rb +43 -0
  34. data/lib/genesis_ruby/api/constants/transactions/parameters/threeds/version2/sdk/interfaces.rb +31 -0
  35. data/lib/genesis_ruby/api/constants/transactions/parameters/threeds/version2/sdk/ui_types.rb +37 -0
  36. data/lib/genesis_ruby/api/constants/transactions.rb +371 -0
  37. data/lib/genesis_ruby/api/mixins/constants/common.rb +27 -0
  38. data/lib/genesis_ruby/api/mixins/requests/address_info_attributes.rb +20 -0
  39. data/lib/genesis_ruby/api/mixins/requests/customer_address/billing_info_attributes.rb +33 -0
  40. data/lib/genesis_ruby/api/mixins/requests/customer_address/customer_info_attributes.rb +26 -0
  41. data/lib/genesis_ruby/api/mixins/requests/customer_address/shipping_info_attributes.rb +33 -0
  42. data/lib/genesis_ruby/api/mixins/requests/document_attributes.rb +14 -0
  43. data/lib/genesis_ruby/api/mixins/requests/financial/async_attributes.rb +34 -0
  44. data/lib/genesis_ruby/api/mixins/requests/financial/base_attributes.rb +16 -0
  45. data/lib/genesis_ruby/api/mixins/requests/financial/business/airlines_air_carriers_attributes.rb +60 -0
  46. data/lib/genesis_ruby/api/mixins/requests/financial/business/business_attributes.rb +56 -0
  47. data/lib/genesis_ruby/api/mixins/requests/financial/business/car_plane_and_boat_rentals_attributes.rb +53 -0
  48. data/lib/genesis_ruby/api/mixins/requests/financial/business/cruise_lines_attributes.rb +50 -0
  49. data/lib/genesis_ruby/api/mixins/requests/financial/business/event_management_attributes.rb +54 -0
  50. data/lib/genesis_ruby/api/mixins/requests/financial/business/furniture_attributes.rb +53 -0
  51. data/lib/genesis_ruby/api/mixins/requests/financial/business/hotels_and_real_estate_rentals_attributes.rb +53 -0
  52. data/lib/genesis_ruby/api/mixins/requests/financial/business/travel_agencies_attributes.rb +88 -0
  53. data/lib/genesis_ruby/api/mixins/requests/financial/cards/credit_card_attributes.rb +31 -0
  54. data/lib/genesis_ruby/api/mixins/requests/financial/cards/fx_rate_attributes.rb +18 -0
  55. data/lib/genesis_ruby/api/mixins/requests/financial/cards/recurring/recurring_category_attributes.rb +31 -0
  56. data/lib/genesis_ruby/api/mixins/requests/financial/cards/recurring/recurring_type_attributes.rb +31 -0
  57. data/lib/genesis_ruby/api/mixins/requests/financial/cards/tokenization_attributes.rb +39 -0
  58. data/lib/genesis_ruby/api/mixins/requests/financial/crypto_attributes.rb +25 -0
  59. data/lib/genesis_ruby/api/mixins/requests/financial/dynamic_descriptor_attributes.rb +114 -0
  60. data/lib/genesis_ruby/api/mixins/requests/financial/gaming_attributes.rb +25 -0
  61. data/lib/genesis_ruby/api/mixins/requests/financial/moto_attributes.rb +25 -0
  62. data/lib/genesis_ruby/api/mixins/requests/financial/notification_attributes.rb +25 -0
  63. data/lib/genesis_ruby/api/mixins/requests/financial/payment_attributes.rb +32 -0
  64. data/lib/genesis_ruby/api/mixins/requests/financial/pending_payment_attributes.rb +25 -0
  65. data/lib/genesis_ruby/api/mixins/requests/financial/reference_attributes.rb +16 -0
  66. data/lib/genesis_ruby/api/mixins/requests/financial/risk_attributes.rb +47 -0
  67. data/lib/genesis_ruby/api/mixins/requests/financial/sca_attributes.rb +37 -0
  68. data/lib/genesis_ruby/api/mixins/requests/financial/threeds/version2/browser.rb +92 -0
  69. data/lib/genesis_ruby/api/mixins/requests/financial/threeds/version2/card_holder_account.rb +183 -0
  70. data/lib/genesis_ruby/api/mixins/requests/financial/threeds/version2/common_attributes.rb +52 -0
  71. data/lib/genesis_ruby/api/mixins/requests/financial/threeds/version2/control.rb +61 -0
  72. data/lib/genesis_ruby/api/mixins/requests/financial/threeds/version2/merchant_risk.rb +114 -0
  73. data/lib/genesis_ruby/api/mixins/requests/financial/threeds/version2/method.rb +44 -0
  74. data/lib/genesis_ruby/api/mixins/requests/financial/threeds/version2/purchase.rb +42 -0
  75. data/lib/genesis_ruby/api/mixins/requests/financial/threeds/version2/recurring.rb +49 -0
  76. data/lib/genesis_ruby/api/mixins/requests/financial/threeds/version2/sdk.rb +107 -0
  77. data/lib/genesis_ruby/api/mixins/requests/financial/threeds/version2/wpf_attributes.rb +61 -0
  78. data/lib/genesis_ruby/api/mixins/requests/restricted_setter.rb +75 -0
  79. data/lib/genesis_ruby/api/request.rb +171 -0
  80. data/lib/genesis_ruby/api/requests/base/financial.rb +44 -0
  81. data/lib/genesis_ruby/api/requests/base/financials/credit_card.rb +27 -0
  82. data/lib/genesis_ruby/api/requests/financial/cards/authorize.rb +60 -0
  83. data/lib/genesis_ruby/api/requests/financial/cards/authorize3d.rb +76 -0
  84. data/lib/genesis_ruby/api/requests/financial/cards/sale.rb +59 -0
  85. data/lib/genesis_ruby/api/requests/financial/cards/sale3d.rb +75 -0
  86. data/lib/genesis_ruby/api/requests/wpf/create.rb +142 -0
  87. data/lib/genesis_ruby/api/response.rb +91 -0
  88. data/lib/genesis_ruby/builder.rb +42 -0
  89. data/lib/genesis_ruby/builders/base.rb +18 -0
  90. data/lib/genesis_ruby/builders/xml.rb +95 -0
  91. data/lib/genesis_ruby/configuration.rb +177 -0
  92. data/lib/genesis_ruby/connection.rb +20 -0
  93. data/lib/genesis_ruby/dependencies.rb +19 -0
  94. data/lib/genesis_ruby/errors/builder_error.rb +14 -0
  95. data/lib/genesis_ruby/errors/endpoint_not_set_error.rb +14 -0
  96. data/lib/genesis_ruby/errors/error.rb +18 -0
  97. data/lib/genesis_ruby/errors/invalid_argument_error.rb +14 -0
  98. data/lib/genesis_ruby/errors/network_error.rb +14 -0
  99. data/lib/genesis_ruby/errors/object_formatter_error.rb +14 -0
  100. data/lib/genesis_ruby/errors/parameter_error.rb +12 -0
  101. data/lib/genesis_ruby/errors/parser_error.rb +14 -0
  102. data/lib/genesis_ruby/errors/response_error.rb +14 -0
  103. data/lib/genesis_ruby/network/adapter/base_adapter.rb +31 -0
  104. data/lib/genesis_ruby/network/adapter/net_http_adapter.rb +92 -0
  105. data/lib/genesis_ruby/network/base_network.rb +83 -0
  106. data/lib/genesis_ruby/network/net_http.rb +28 -0
  107. data/lib/genesis_ruby/parser.rb +44 -0
  108. data/lib/genesis_ruby/parsers/base.rb +25 -0
  109. data/lib/genesis_ruby/parsers/xml.rb +120 -0
  110. data/lib/genesis_ruby/utils/common.rb +108 -0
  111. data/lib/genesis_ruby/utils/formatters/base.rb +40 -0
  112. data/lib/genesis_ruby/utils/formatters/response/definitions.rb +21 -0
  113. data/lib/genesis_ruby/utils/formatters/response/formats/amount.rb +34 -0
  114. data/lib/genesis_ruby/utils/formatters/response/formats/timestamp.rb +29 -0
  115. data/lib/genesis_ruby/utils/formatters/response/loader.rb +42 -0
  116. data/lib/genesis_ruby/utils/money/base/strategy.rb +38 -0
  117. data/lib/genesis_ruby/utils/money/conversions/amount_to_exponent.rb +22 -0
  118. data/lib/genesis_ruby/utils/money/conversions/exponent_to_amount.rb +22 -0
  119. data/lib/genesis_ruby/utils/money/format.rb +34 -0
  120. data/lib/genesis_ruby/utils/money_format.rb +39 -0
  121. data/lib/genesis_ruby/utils/object_formatter.rb +67 -0
  122. data/lib/genesis_ruby/utils/options/api_config.rb +36 -0
  123. data/lib/genesis_ruby/utils/options/base.rb +35 -0
  124. data/lib/genesis_ruby/utils/options/network_adapter_config.rb +41 -0
  125. data/lib/genesis_ruby/utils/transactions/financial_types.rb +50 -0
  126. data/lib/genesis_ruby/utils/transactions/references/capturable_types.rb +52 -0
  127. data/lib/genesis_ruby/utils/transactions/references/refundable_types.rb +70 -0
  128. data/lib/genesis_ruby/utils/transactions/references/voidable_types.rb +49 -0
  129. data/lib/genesis_ruby/utils/transactions/wpf_types.rb +43 -0
  130. data/lib/genesis_ruby/version.rb +5 -0
  131. data/lib/genesis_ruby.rb +57 -0
  132. metadata +372 -0
@@ -0,0 +1,61 @@
1
+ require 'genesis_ruby/api/mixins/requests/financial/threeds/version2/recurring'
2
+ require 'genesis_ruby/api/mixins/requests/financial/threeds/version2/purchase'
3
+ require 'genesis_ruby/api/mixins/requests/financial/threeds/version2/merchant_risk'
4
+ require 'genesis_ruby/api/mixins/requests/financial/threeds/version2/control'
5
+ require 'genesis_ruby/api/mixins/requests/financial/threeds/version2/card_holder_account'
6
+
7
+ module GenesisRuby
8
+ module Api
9
+ module Mixins
10
+ module Requests
11
+ module Financial
12
+ module Threeds
13
+ module Version2
14
+ # Threeds Version 2 WPF Attributes
15
+ module WpfAttributes
16
+
17
+ include Control
18
+ include Purchase
19
+ include Recurring
20
+ include MerchantRisk
21
+ include CardHolderAccount
22
+
23
+ # WPF doesn't support Threeds V2 Device Type parameter
24
+ def threeds_v2_control_device_type
25
+ raise NoMethodError, "#{__method__} isn't available for the Web Payment Form"
26
+ end
27
+
28
+ # WPF doesn't support Threeds V2 Device Type parameter
29
+ def threeds_v2_control_device_type=(_value)
30
+ raise NoMethodError, "#{__method__} isn't available for the Web Payment Form"
31
+ end
32
+
33
+ protected
34
+
35
+ # Request Control Attributes structure available for the Web Payment Form
36
+ def control_attributes
37
+ {
38
+ challenge_window_size: threeds_v2_control_challenge_window_size,
39
+ challenge_indicator: threeds_v2_control_challenge_indicator
40
+ }
41
+ end
42
+
43
+ # Threeds V2 Web Payment Form Attributes
44
+ def threeds_v2_wpf_attributes_structure
45
+ {
46
+ control: control_attributes,
47
+ purchase: purchase_attributes,
48
+ merchant_risk: merchant_risk_attributes,
49
+ card_holder_account: card_holder_account_attributes,
50
+ recurring: recurring_attributes
51
+ }
52
+ end
53
+
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,75 @@
1
+ require 'genesis_ruby/api/constants/date_time_formats'
2
+ require 'genesis_ruby/utils/common'
3
+
4
+ module GenesisRuby
5
+ module Api
6
+ module Mixins
7
+ module Requests
8
+ # Helper methods for restricting the available accessor's values
9
+ module RestrictedSetter
10
+
11
+ protected
12
+
13
+ # Validation of the value's allowed values
14
+ def allowed_options(attribute:, allowed:, value:, allow_empty: false, error_message: nil)
15
+ return assign_instance_variable attribute, nil if allow_empty && value.to_s.empty?
16
+
17
+ error_message = format(
18
+ '%{error_message}%{method} accepts one of the following: %{allowed}',
19
+ error_message: error_message ? "#{error_message} " : '',
20
+ method: attribute,
21
+ allowed: allowed.join(', ')
22
+ )
23
+
24
+ raise InvalidArgumentError, error_message unless allowed.include? value
25
+
26
+ assign_instance_variable attribute, value
27
+ end
28
+
29
+ # Validation of the value's length
30
+ def limited_string(attribute:, value:, min: nil, max: nil)
31
+ len = value.to_s.length
32
+
33
+ raise InvalidArgumentError, "#{attribute} value must be min #{min} chars long." if !min.nil? && len < min
34
+
35
+ raise InvalidArgumentError, "#{attribute} value must be max #{max} chars long." if !max.nil? && len > max
36
+
37
+ assign_instance_variable attribute, value
38
+ end
39
+
40
+ # Parses given date and assign it to the given attribute when it is valid
41
+ def parse_date(attribute:, value:, formats: [], error_message: nil, allow_empty: false)
42
+ return assign_instance_variable attribute, nil if allow_empty && value.to_s.empty?
43
+
44
+ formats = GenesisRuby::Api::Constants::DateTimeFormats.all if formats.empty?
45
+ parsed_date = GenesisRuby::Utils::Common.parse_date(value, formats)
46
+ error_message ||= format(
47
+ '%{method} accepts only valid date values in one of the following formats: %{formats}',
48
+ method: attribute,
49
+ formats: formats.join(', ')
50
+ )
51
+
52
+ raise InvalidArgumentError, error_message unless parsed_date
53
+
54
+ assign_instance_variable attribute.to_s.chomp, parsed_date
55
+ end
56
+
57
+ # Parses given value to_i and assign it to the given attribute
58
+ def parse_int(attribute:, value:, allow_empty: false)
59
+ return assign_instance_variable attribute, nil if allow_empty && value.to_s.empty?
60
+
61
+ assign_instance_variable attribute, value.to_i
62
+ end
63
+
64
+ private
65
+
66
+ # Helper for assigning a attribute to the class instance
67
+ def assign_instance_variable(attribute, value)
68
+ instance_variable_set "@#{attribute.to_s.chomp "="}", value
69
+ end
70
+
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,171 @@
1
+ require 'genesis_ruby/utils/options/api_config'
2
+ require 'genesis_ruby/errors/endpoint_not_set_error'
3
+ require 'genesis_ruby/builder'
4
+ require 'genesis_ruby/utils/common'
5
+ require 'genesis_ruby/utils/money_format'
6
+
7
+ module GenesisRuby
8
+ module Api
9
+ # Base Request Class
10
+ class Request
11
+
12
+ PROTOCOL_HTTPS = 'https'.freeze
13
+ PORT_HTTPS = 443
14
+
15
+ METHOD_POST = 'POST'.freeze
16
+ METHOD_GET = 'GET'.freeze
17
+ METHOD_PUT = 'PUT'.freeze
18
+
19
+ attr_reader :api_config
20
+
21
+ def initialize(configuration, builder_interface = 'xml')
22
+ @configuration = configuration
23
+ @builder_interface = builder_interface
24
+ @api_config = GenesisRuby::Utils::Options::ApiConfig.new
25
+
26
+ init_configuration
27
+ init_required_fields
28
+ end
29
+
30
+ # Generate the Request Document based on the builder_interface
31
+ def build_document
32
+ process_request_parameters
33
+
34
+ if tree_structure.instance_of?(Hash)
35
+ @builder_context = GenesisRuby::Builder.new(builder_interface)
36
+ builder_context.parse_structure(tree_structure.clone)
37
+
38
+ return builder_context.document
39
+ end
40
+
41
+ nil
42
+ end
43
+
44
+ protected
45
+
46
+ attr_reader :configuration, :builder_interface, :builder_context
47
+ attr_accessor :tree_structure
48
+
49
+ # Request Configuration
50
+ def init_configuration; end
51
+
52
+ # Required fields for the request
53
+ def init_required_fields; end
54
+
55
+ # Pre-defined XML Request Configuration
56
+ def init_xml_configuration
57
+ @api_config.load_xml_config
58
+ end
59
+
60
+ # Pre-defined JSON Request Configuration
61
+ def init_json_configuration
62
+ @api_config.load_json_config
63
+ end
64
+
65
+ # Pre-defined FORM Request Configuration
66
+ def init_form_configuration
67
+ @api_config.load_form_config
68
+ end
69
+
70
+ # Initializes Api EndPoint Url with request path & terminal token
71
+ def init_api_gateway_configuration(options = { request_path: 'process', include_token: true })
72
+ request_path = options.fetch :request_path, 'process'
73
+ include_token = options.fetch :include_token, true
74
+
75
+ api_config.url = build_request_url(
76
+ {
77
+ subdomain: 'gateway',
78
+ path: request_path,
79
+ token: include_token ? @configuration.token : ''
80
+ }
81
+ )
82
+ end
83
+
84
+ # Initializes WPF EndPoint Url with internationalization
85
+ def init_api_wpf_configuration(options = { language: '' })
86
+ language = (options.fetch :language, '').to_s
87
+
88
+ api_config.url = build_request_url(
89
+ {
90
+ subdomain: 'wpf',
91
+ path: language.empty? ? 'wpf' : format('%{language}/wpf', { language: language })
92
+ }
93
+ )
94
+ end
95
+
96
+ # Process Everything the variables set previously
97
+ #
98
+ # Step 1: Execute per-field actions
99
+ # Step 2: Update the Tree structure
100
+ # Step 3: Clean the empty leafs
101
+ # Step 4: Check for Required Fields
102
+ def process_request_parameters
103
+ populate_structure
104
+
105
+ sanitize_structure
106
+
107
+ check_requirements
108
+ end
109
+
110
+ # Create the Tree structure and populate
111
+ # the fields with the set parameters.
112
+ # Every request defines the :tree_structure
113
+ def populate_structure
114
+ @tree_structure = {}
115
+ end
116
+
117
+ # Remove empty key values from the structure
118
+ def sanitize_structure
119
+ GenesisRuby::Utils::Common.deep_compact!(tree_structure) if tree_structure.instance_of?(Hash)
120
+ end
121
+
122
+ # Perform validation over the defined parameters
123
+ def check_requirements
124
+ # TODO: perform validation over the defined parameters
125
+ end
126
+
127
+ # Build the Genesis API endpoint
128
+ # Options:
129
+ # subdomain - the service /gateway, wpf, etc/
130
+ # path - the requested service /blacklists, threeds/threeds_method/<unique_id>, wpf/reconcile, etc/
131
+ # token - the MID configuration, appended to the end of the URL
132
+ def build_request_url(options = { subdomain: 'gateway', path: '', token: '' })
133
+ options = parse_request_parameters(options)
134
+
135
+ format('%{protocol}://%{sub}%{domain}:%{port}/%{path}', {
136
+ protocol: api_config.protocol || PROTOCOL_HTTPS,
137
+ sub: @configuration.sub_domain(options[:subdomain]),
138
+ domain: @configuration.endpoint,
139
+ port: api_config.port || PORT_HTTPS,
140
+ path: fetch_request_path(options)
141
+ })
142
+ end
143
+
144
+ # Transform amount to minor currency format
145
+ def transform_amount(amount, currency)
146
+ GenesisRuby::Utils::MoneyFormat.amount_to_exponent amount, currency
147
+ end
148
+
149
+ private
150
+
151
+ # Parse the Request URL options
152
+ def parse_request_parameters(options = { subdomain: 'gateway', token: '', path: '' })
153
+ raise EndpointNotSetError if @configuration.endpoint.empty?
154
+
155
+ {
156
+ subdomain: options.fetch(:subdomain, 'gateway'),
157
+ token: options.fetch(:token, ''),
158
+ path: options.fetch(:path, '')
159
+ }
160
+ end
161
+
162
+ # Fetch the request path by the given options
163
+ def fetch_request_path(options = { path: '', token: '' })
164
+ return options[:path] if options[:token].empty?
165
+
166
+ format('%{path}/%{token}/', { path: options[:path], token: options[:token] })
167
+ end
168
+
169
+ end
170
+ end
171
+ end
@@ -0,0 +1,44 @@
1
+ module GenesisRuby
2
+ module Api
3
+ module Requests
4
+ module Base
5
+ # Base class used by all Financial transaction requests
6
+ class Financial < Request
7
+
8
+ include Mixins::Requests::Financial::BaseAttributes
9
+
10
+ protected
11
+
12
+ # Returns the Request transaction type
13
+ def transaction_type
14
+ raise NotImplementedError, 'Transaction Type method must be implemented'
15
+ end
16
+
17
+ # Return additional request attributes
18
+ def payment_transaction_structure
19
+ raise NotImplementedError, 'Payment Transaction Structure method must be implemented'
20
+ end
21
+
22
+ # Request Configuration
23
+ def init_configuration
24
+ super
25
+ init_xml_configuration
26
+ init_api_gateway_configuration
27
+ end
28
+
29
+ def populate_structure
30
+ self.tree_structure = {
31
+ payment_transaction: {
32
+ transaction_type: transaction_type,
33
+ transaction_id: transaction_id,
34
+ usage: usage,
35
+ remote_ip: remote_ip
36
+ }.merge(payment_transaction_structure)
37
+ }
38
+ end
39
+
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,27 @@
1
+ require 'genesis_ruby/api/requests/base/financial'
2
+
3
+ module GenesisRuby
4
+ module Api
5
+ module Requests
6
+ module Base
7
+ module Financials
8
+ # Base Class used for all transaction request containing Credit Card data
9
+ class CreditCard < GenesisRuby::Api::Requests::Base::Financial
10
+
11
+ include Mixins::Requests::Financial::PaymentAttributes
12
+ include Mixins::Requests::Financial::Cards::CreditCardAttributes
13
+ include Mixins::Requests::Financial::Cards::TokenizationAttributes
14
+
15
+ protected
16
+
17
+ # Credit Card attributes
18
+ def payment_transaction_structure
19
+ payment_attributes_structure.merge credit_card_attributes_structure, tokenization_attributes_structure
20
+ end
21
+
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,60 @@
1
+ require 'genesis_ruby/api/requests/base/financials/credit_card'
2
+
3
+ module GenesisRuby
4
+ module Api
5
+ module Requests
6
+ module Financial
7
+ module Cards
8
+ # With authorize transactions, you can confirm that a credit card is valid and
9
+ # reserve the desired amount on the card
10
+ class Authorize < Requests::Base::Financials::CreditCard
11
+
12
+ include Mixins::Requests::AddressInfoAttributes
13
+ include Mixins::Requests::DocumentAttributes
14
+ include Mixins::Requests::Financial::Business::BusinessAttributes
15
+ include Mixins::Requests::Financial::Cards::FxRateAttributes
16
+ include Mixins::Requests::Financial::Cards::Recurring::RecurringCategoryAttributes
17
+ include Mixins::Requests::Financial::Cards::Recurring::RecurringTypeAttributes
18
+ include Mixins::Requests::Financial::CryptoAttributes
19
+ include Mixins::Requests::Financial::DynamicDescriptorAttributes
20
+ include Mixins::Requests::Financial::GamingAttributes
21
+ include Mixins::Requests::Financial::MotoAttributes
22
+ include Mixins::Requests::Financial::ReferenceAttributes
23
+ include Mixins::Requests::Financial::RiskAttributes
24
+ include Mixins::Requests::Financial::ScaAttributes
25
+ include Mixins::Requests::RestrictedSetter
26
+
27
+ protected
28
+
29
+ # Authorize Transaction Type
30
+ def transaction_type
31
+ GenesisRuby::Api::Constants::Transactions::AUTHORIZE
32
+ end
33
+
34
+ def payment_transaction_structure # rubocop:disable Metrics/MethodLength
35
+ super.merge(
36
+ gaming: gaming,
37
+ moto: moto,
38
+ crypto: crypto,
39
+ customer_email: customer_email,
40
+ customer_phone: customer_phone,
41
+ reference_id: reference_id,
42
+ document_id: document_id,
43
+ fx_rate_id: fx_rate_id,
44
+ billing_address: billing_address_parameters_structure,
45
+ shipping_address: shipping_address_parameters_structure,
46
+ risk_params: risk_parameters_structure,
47
+ dynamic_descriptor_params: dynamic_descriptor_structure,
48
+ business_attributes: business_attributes_structure,
49
+ recurring_type: recurring_type,
50
+ recurring_category: recurring_category,
51
+ sca_params: sca_attributes_structure
52
+ )
53
+ end
54
+
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,76 @@
1
+ require 'genesis_ruby/api/requests/base/financials/credit_card'
2
+
3
+ module GenesisRuby
4
+ module Api
5
+ module Requests
6
+ module Financial
7
+ module Cards
8
+ # Authorize 3D transactions, credit card based, can be synchronous or asynchronous based on the workflow and
9
+ # the additional parameters for card holder authentication
10
+ class Authorize3d < Requests::Base::Financials::CreditCard
11
+
12
+ include Mixins::Requests::AddressInfoAttributes
13
+ include Mixins::Requests::DocumentAttributes
14
+ include Mixins::Requests::Financial::AsyncAttributes
15
+ include Mixins::Requests::Financial::Business::BusinessAttributes
16
+ include Mixins::Requests::Financial::Cards::FxRateAttributes
17
+ include Mixins::Requests::Financial::Cards::Recurring::RecurringCategoryAttributes
18
+ include Mixins::Requests::Financial::Cards::Recurring::RecurringTypeAttributes
19
+ include Mixins::Requests::Financial::CryptoAttributes
20
+ include Mixins::Requests::Financial::DynamicDescriptorAttributes
21
+ include Mixins::Requests::Financial::GamingAttributes
22
+ include Mixins::Requests::Financial::MotoAttributes
23
+ include Mixins::Requests::Financial::NotificationAttributes
24
+ include Mixins::Requests::Financial::RiskAttributes
25
+ include Mixins::Requests::Financial::ScaAttributes
26
+ include Mixins::Requests::Financial::Threeds::Version2::CommonAttributes
27
+ include Mixins::Requests::RestrictedSetter
28
+
29
+ # Specifies the recurring type of transaction
30
+ def recurring_type=(value)
31
+ allowed_values = [
32
+ GenesisRuby::Api::Constants::Transactions::Parameters::Recurring::Types::INITIAL,
33
+ GenesisRuby::Api::Constants::Transactions::Parameters::Recurring::Types::MANAGED
34
+ ]
35
+
36
+ allowed_options attribute: __method__, allowed: allowed_values, value: value, allow_empty: true
37
+ end
38
+
39
+ protected
40
+
41
+ # Authorize 3D Transaction Type
42
+ def transaction_type
43
+ GenesisRuby::Api::Constants::Transactions::AUTHORIZE_3D
44
+ end
45
+
46
+ # Authorize 3D transaction request parameters
47
+ def payment_transaction_structure # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
48
+ super.merge(
49
+ notification_url: notification_url,
50
+ return_success_url: return_success_url,
51
+ return_failure_url: return_failure_url,
52
+ gaming: gaming,
53
+ moto: moto,
54
+ crypto: crypto,
55
+ customer_email: customer_email,
56
+ customer_phone: customer_phone,
57
+ document_id: document_id,
58
+ fx_rate_id: fx_rate_id,
59
+ billing_address: billing_address_parameters_structure,
60
+ shipping_address: shipping_address_parameters_structure,
61
+ risk_params: risk_parameters_structure,
62
+ dynamic_descriptor_params: dynamic_descriptor_structure,
63
+ business_attributes: business_attributes_structure,
64
+ recurring_type: recurring_type,
65
+ recurring_category: recurring_category,
66
+ sca_params: sca_attributes_structure,
67
+ threeds_v2_params: threeds_v2_common_attributes_structure
68
+ )
69
+ end
70
+
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,59 @@
1
+ require 'genesis_ruby/api/requests/base/financials/credit_card'
2
+
3
+ module GenesisRuby
4
+ module Api
5
+ module Requests
6
+ module Financial
7
+ module Cards
8
+ # Sale transactions combine authorize and capture into one step
9
+ class Sale < Requests::Base::Financials::CreditCard
10
+
11
+ include Mixins::Requests::AddressInfoAttributes
12
+ include Mixins::Requests::DocumentAttributes
13
+ include Mixins::Requests::Financial::Business::BusinessAttributes
14
+ include Mixins::Requests::Financial::Cards::FxRateAttributes
15
+ include Mixins::Requests::Financial::Cards::Recurring::RecurringCategoryAttributes
16
+ include Mixins::Requests::Financial::Cards::Recurring::RecurringTypeAttributes
17
+ include Mixins::Requests::Financial::CryptoAttributes
18
+ include Mixins::Requests::Financial::DynamicDescriptorAttributes
19
+ include Mixins::Requests::Financial::GamingAttributes
20
+ include Mixins::Requests::Financial::MotoAttributes
21
+ include Mixins::Requests::Financial::ReferenceAttributes
22
+ include Mixins::Requests::Financial::RiskAttributes
23
+ include Mixins::Requests::Financial::ScaAttributes
24
+ include Mixins::Requests::RestrictedSetter
25
+
26
+ protected
27
+
28
+ # Sale Transaction Type
29
+ def transaction_type
30
+ GenesisRuby::Api::Constants::Transactions::SALE
31
+ end
32
+
33
+ def payment_transaction_structure # rubocop:disable Metrics/MethodLength
34
+ super.merge(
35
+ gaming: gaming,
36
+ moto: moto,
37
+ crypto: crypto,
38
+ customer_email: customer_email,
39
+ customer_phone: customer_phone,
40
+ reference_id: reference_id,
41
+ document_id: document_id,
42
+ fx_rate_id: fx_rate_id,
43
+ billing_address: billing_address_parameters_structure,
44
+ shipping_address: shipping_address_parameters_structure,
45
+ risk_params: risk_parameters_structure,
46
+ dynamic_descriptor_params: dynamic_descriptor_structure,
47
+ business_attributes: business_attributes_structure,
48
+ recurring_type: recurring_type,
49
+ recurring_category: recurring_category,
50
+ sca_params: sca_attributes_structure
51
+ )
52
+ end
53
+
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,75 @@
1
+ require 'genesis_ruby/api/requests/base/financials/credit_card'
2
+
3
+ module GenesisRuby
4
+ module Api
5
+ module Requests
6
+ module Financial
7
+ module Cards
8
+ # Sale3D combines a Sale transaction request by adding asynchronous processing
9
+ class Sale3d < Requests::Base::Financials::CreditCard
10
+
11
+ include Mixins::Requests::AddressInfoAttributes
12
+ include Mixins::Requests::DocumentAttributes
13
+ include Mixins::Requests::Financial::AsyncAttributes
14
+ include Mixins::Requests::Financial::Business::BusinessAttributes
15
+ include Mixins::Requests::Financial::Cards::FxRateAttributes
16
+ include Mixins::Requests::Financial::Cards::Recurring::RecurringCategoryAttributes
17
+ include Mixins::Requests::Financial::Cards::Recurring::RecurringTypeAttributes
18
+ include Mixins::Requests::Financial::CryptoAttributes
19
+ include Mixins::Requests::Financial::DynamicDescriptorAttributes
20
+ include Mixins::Requests::Financial::GamingAttributes
21
+ include Mixins::Requests::Financial::MotoAttributes
22
+ include Mixins::Requests::Financial::NotificationAttributes
23
+ include Mixins::Requests::Financial::RiskAttributes
24
+ include Mixins::Requests::Financial::ScaAttributes
25
+ include Mixins::Requests::Financial::Threeds::Version2::CommonAttributes
26
+ include Mixins::Requests::RestrictedSetter
27
+
28
+ # Specifies the recurring type of transaction
29
+ def recurring_type=(value)
30
+ allowed_values = [
31
+ GenesisRuby::Api::Constants::Transactions::Parameters::Recurring::Types::INITIAL,
32
+ GenesisRuby::Api::Constants::Transactions::Parameters::Recurring::Types::MANAGED
33
+ ]
34
+
35
+ allowed_options attribute: __method__, allowed: allowed_values, value: value, allow_empty: true
36
+ end
37
+
38
+ protected
39
+
40
+ # Sale 3D Transaction Type
41
+ def transaction_type
42
+ GenesisRuby::Api::Constants::Transactions::SALE_3D
43
+ end
44
+
45
+ # Sale 3D transaction request parameters
46
+ def payment_transaction_structure # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
47
+ super.merge(
48
+ notification_url: notification_url,
49
+ return_success_url: return_success_url,
50
+ return_failure_url: return_failure_url,
51
+ gaming: gaming,
52
+ moto: moto,
53
+ crypto: crypto,
54
+ customer_email: customer_email,
55
+ customer_phone: customer_phone,
56
+ document_id: document_id,
57
+ fx_rate_id: fx_rate_id,
58
+ billing_address: billing_address_parameters_structure,
59
+ shipping_address: shipping_address_parameters_structure,
60
+ risk_params: risk_parameters_structure,
61
+ dynamic_descriptor_params: dynamic_descriptor_structure,
62
+ business_attributes: business_attributes_structure,
63
+ recurring_type: recurring_type,
64
+ recurring_category: recurring_category,
65
+ sca_params: sca_attributes_structure,
66
+ threeds_v2_params: threeds_v2_common_attributes_structure
67
+ )
68
+ end
69
+
70
+ end
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end