genesis_ruby 0.2.1 → 0.2.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f29c5f143d903c4fb42a353861744b184de9a7d48dd8788e7ed53baedc11849a
4
- data.tar.gz: 824210216d4e2f029faf1e8f1896d8c03ad28c4b79f8d7bdd647e73f169175a3
3
+ metadata.gz: b8bb23a143ba4c359861d35f9e03cfde80130d4e7566cd95a899e27e5f77b8d2
4
+ data.tar.gz: 72496117a1a8a3ec4dcca3b39f41ac080b9696b1d16e2844c3f3488b11b15104
5
5
  SHA512:
6
- metadata.gz: a403425c5236e42412d7e103272a1a4895211e3ea5594f27396fdb330d1cef7d538807da4f08fcd9872f3edfd98fa836b30199d3c45080cce12579062c7d00b2
7
- data.tar.gz: 8ea6cf3090a5346a6bdbf760d3ed91908e2b7bb609b050e66a5904b6f965b21defe9b0878cb4bea92772cb70447e5b80003547dcc8b1d9a8556eabc5ac3f8d79
6
+ metadata.gz: 54bfbce4e0a95961f64aafdc168e8509f810c070d9a24ff1430648da7f12611f87e418dea7483e97e655065b24a83bf80d61a9fe870ac6656e9bfd55704e2474
7
+ data.tar.gz: 9a10b7cd257d4dacb18b420d454cc564c265f0e636221454b00b6ed86ca95002a8cc8dfc9212ad599002fd6101da571a63063d14f1c71fe1675430a38443a47b
data/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ 0.2.2
2
+ -----
3
+ **Features**:
4
+
5
+ * Added Installments API services support
6
+ * Added Installments attributes support to the following transaction requests:
7
+ * Authorize
8
+ * Authorize 3D
9
+ * Capture
10
+ * Sale
11
+ * Sale 3D
12
+ * Refund
13
+ * Added Level 3 Travel Data attributes support to Refund transaction request
14
+
1
15
  0.2.1
2
16
  -----
3
17
  **Features**:
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- genesis_ruby (0.2.1)
4
+ genesis_ruby (0.2.2)
5
5
  net-http (~> 0.3.2)
6
6
  nokogiri (~> 1.14)
7
7
 
data/README.md CHANGED
@@ -1053,6 +1053,10 @@ GenesisRuby::Api::Requests::Financial::Refund
1053
1053
  ## Reconcile
1054
1054
  GenesisRuby::Api::Requests::NonFinancial::Reconcile::Transaction
1055
1055
  GenesisRuby::Api::Requests::NonFinancial::Reconcile::DateRange
1056
+
1057
+ ## Installments
1058
+ GenesisRuby::Api::Requests::NonFinancial::Installments::Fetch
1059
+
1056
1060
  ```
1057
1061
 
1058
1062
  ### Manual initialization
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.1
1
+ 0.2.2
@@ -0,0 +1,30 @@
1
+ module GenesisRuby
2
+ module Api
3
+ module Constants
4
+ module Transactions
5
+ module Parameters
6
+ module Refund
7
+ # Credit Reason Indicator allowed values
8
+ class CreditReasonIndicators
9
+
10
+ extend Api::Mixins::Constants::Common
11
+
12
+ # Passenger Transport Ancillary Cancellation
13
+ INDICATOR_A = 'A'.freeze
14
+
15
+ # Travel Ticket and Passenger Transport
16
+ INDICATOR_B = 'B'.freeze
17
+
18
+ # Partial Refund of Travel Ticket
19
+ INDICATOR_P = 'P'.freeze
20
+
21
+ # Other
22
+ INDICATOR_O = 'O'.freeze
23
+
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,24 @@
1
+ module GenesisRuby
2
+ module Api
3
+ module Constants
4
+ module Transactions
5
+ module Parameters
6
+ module Refund
7
+ # Ticket Change Indicator allowed values
8
+ class TicketChangeIndicators
9
+
10
+ extend Api::Mixins::Constants::Common
11
+
12
+ # Change to existing Ticket
13
+ INDICATOR_C = 'C'.freeze
14
+
15
+ # New ticket
16
+ INDICATOR_N = 'N'.freeze
17
+
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,18 @@
1
+ module GenesisRuby
2
+ module Api
3
+ module Mixins
4
+ module Requests
5
+ module Financial
6
+ module Cards
7
+ # Installment shared attributes mixin
8
+ module InstallmentAttributes
9
+
10
+ attr_accessor :installment_plan_id, :installment_plan_reference
11
+
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -7,7 +7,7 @@ require 'genesis_ruby/utils/money_format'
7
7
  module GenesisRuby
8
8
  module Api
9
9
  # Base Request Class
10
- class Request
10
+ class Request # rubocop:disable Metrics/ClassLength
11
11
 
12
12
  include Mixins::Requests::RestrictedSetter
13
13
  include Mixins::Requests::AttributeValidation
@@ -70,6 +70,11 @@ module GenesisRuby
70
70
  @api_config.load_form_config
71
71
  end
72
72
 
73
+ # Pre-defined GET Request Configuration
74
+ def init_get_configuration
75
+ @api_config.load_get_config
76
+ end
77
+
73
78
  # Initializes Api EndPoint Url with request path & terminal token
74
79
  def init_api_gateway_configuration(options = { request_path: 'process', include_token: true })
75
80
  request_path = options.fetch :request_path, 'process'
@@ -0,0 +1,88 @@
1
+ module GenesisRuby
2
+ module Api
3
+ module Requests
4
+ module Base
5
+ # Base Versioned Request class used for Non Financial JSON API services
6
+ class Versioned < Request
7
+
8
+ DEFAULT_VERSION = 'v1'.freeze
9
+ private_constant :DEFAULT_VERSION
10
+
11
+ attr_reader :version, :allowed_versions
12
+
13
+ # Base Versioned Request constructor
14
+ def initialize(configuration, builder_interface = Builder::JSON)
15
+ super configuration, builder_interface
16
+
17
+ self.allowed_versions = [DEFAULT_VERSION]
18
+ self.version = DEFAULT_VERSION
19
+ self.request_path = ''
20
+ end
21
+
22
+ # Defines the version for the request
23
+ def version=(value)
24
+ allowed_options(
25
+ attribute: __method__,
26
+ value: value,
27
+ allowed: allowed_versions,
28
+ allow_empty: false,
29
+ error_message: 'Invalid API version! '
30
+ )
31
+
32
+ init_configuration
33
+ end
34
+
35
+ protected
36
+
37
+ attr_reader :request_path
38
+
39
+ # Every Specific request defines available versions
40
+ def allowed_versions=(value)
41
+ raise InvalidArgumentError, 'Allowed versions accepts only Array values' unless value.is_a? Array
42
+
43
+ @allowed_versions = value
44
+ end
45
+
46
+ # Defines the endpoint of the request
47
+ def request_path=(value)
48
+ @request_path = value.to_s
49
+
50
+ init_configuration
51
+
52
+ @request_path
53
+ rescue BuilderError
54
+ @request_path = ''
55
+
56
+ raise InvalidArgumentError, 'The Request can not be configured!'
57
+ end
58
+
59
+ # Initialize Request configuration
60
+ def init_configuration
61
+ super
62
+
63
+ case @builder_interface
64
+ when Builder::XML then init_xml_configuration
65
+ when Builder::JSON then init_json_configuration
66
+ else raise BuilderError, "Invalid Builder Interface specified for #{self.class.name}"
67
+ end
68
+
69
+ init_api_gateway_configuration request_path: "#{version}/#{request_path}", include_token: false
70
+ end
71
+
72
+ # Request structure. Overridden for common structure parameters
73
+ def populate_structure
74
+ super
75
+
76
+ @tree_structure = request_structure
77
+ end
78
+
79
+ # Request structure
80
+ def request_structure
81
+ raise NoMethodError, 'Request structure must be defined!'
82
+ end
83
+
84
+ end
85
+ end
86
+ end
87
+ end
88
+ end
@@ -6,6 +6,7 @@ module GenesisRuby
6
6
  class Capture < Requests::Base::Reference
7
7
 
8
8
  include Mixins::Requests::Financial::Business::BusinessAttributes
9
+ include Mixins::Requests::Financial::Cards::InstallmentAttributes
9
10
  include Mixins::Requests::Financial::TravelData::TravelAttributes
10
11
 
11
12
  protected
@@ -18,9 +19,11 @@ module GenesisRuby
18
19
  # Capture Transaction Request Structure
19
20
  def reference_transaction_structure
20
21
  {
21
- reference_id: reference_id,
22
- business_attributes: business_attributes_structure,
23
- travel: travel_data_attributes_structure
22
+ reference_id: reference_id,
23
+ business_attributes: business_attributes_structure,
24
+ travel: travel_data_attributes_structure,
25
+ installment_plan_id: installment_plan_id,
26
+ installment_plan_reference: installment_plan_reference
24
27
  }
25
28
  end
26
29
 
@@ -13,6 +13,7 @@ module GenesisRuby
13
13
  include Mixins::Requests::DocumentAttributes
14
14
  include Mixins::Requests::Financial::Business::BusinessAttributes
15
15
  include Mixins::Requests::Financial::Cards::FxRateAttributes
16
+ include Mixins::Requests::Financial::Cards::InstallmentAttributes
16
17
  include Mixins::Requests::Financial::Cards::Recurring::ManagedRecurringAttributes
17
18
  include Mixins::Requests::Financial::Cards::Recurring::RecurringCategoryAttributes
18
19
  include Mixins::Requests::Financial::Cards::Recurring::RecurringTypeAttributes
@@ -50,25 +51,27 @@ module GenesisRuby
50
51
 
51
52
  def payment_transaction_structure # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
52
53
  super.merge(
53
- gaming: gaming,
54
- moto: moto,
55
- crypto: crypto,
56
- customer_email: customer_email,
57
- customer_phone: customer_phone,
58
- reference_id: reference_id,
59
- document_id: document_id,
60
- fx_rate_id: fx_rate_id,
61
- billing_address: billing_address_parameters_structure,
62
- shipping_address: shipping_address_parameters_structure,
63
- risk_params: risk_parameters_structure,
64
- dynamic_descriptor_params: dynamic_descriptor_structure,
65
- business_attributes: business_attributes_structure,
66
- recurring_type: recurring_type,
67
- recurring_category: recurring_category,
68
- sca_params: sca_attributes_structure,
69
- managed_recurring: managed_recurring_attributes_structure,
70
- travel: travel_data_attributes_structure,
71
- funding: funding_attributes_structure
54
+ gaming: gaming,
55
+ moto: moto,
56
+ crypto: crypto,
57
+ customer_email: customer_email,
58
+ customer_phone: customer_phone,
59
+ reference_id: reference_id,
60
+ document_id: document_id,
61
+ fx_rate_id: fx_rate_id,
62
+ billing_address: billing_address_parameters_structure,
63
+ shipping_address: shipping_address_parameters_structure,
64
+ risk_params: risk_parameters_structure,
65
+ dynamic_descriptor_params: dynamic_descriptor_structure,
66
+ business_attributes: business_attributes_structure,
67
+ recurring_type: recurring_type,
68
+ recurring_category: recurring_category,
69
+ sca_params: sca_attributes_structure,
70
+ managed_recurring: managed_recurring_attributes_structure,
71
+ travel: travel_data_attributes_structure,
72
+ funding: funding_attributes_structure,
73
+ installment_plan_id: installment_plan_id,
74
+ installment_plan_reference: installment_plan_reference
72
75
  )
73
76
  end
74
77
 
@@ -14,6 +14,7 @@ module GenesisRuby
14
14
  include Mixins::Requests::Financial::AsyncAttributes
15
15
  include Mixins::Requests::Financial::Business::BusinessAttributes
16
16
  include Mixins::Requests::Financial::Cards::FxRateAttributes
17
+ include Mixins::Requests::Financial::Cards::InstallmentAttributes
17
18
  include Mixins::Requests::Financial::Cards::MpiAttributes
18
19
  include Mixins::Requests::Financial::Cards::Recurring::ManagedRecurringAttributes
19
20
  include Mixins::Requests::Financial::Cards::Recurring::RecurringCategoryAttributes
@@ -61,29 +62,31 @@ module GenesisRuby
61
62
  # Authorize 3D transaction request parameters
62
63
  def payment_transaction_structure # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
63
64
  super.merge(
64
- notification_url: notification_url,
65
- return_success_url: return_success_url,
66
- return_failure_url: return_failure_url,
67
- gaming: gaming,
68
- moto: moto,
69
- crypto: crypto,
70
- customer_email: customer_email,
71
- customer_phone: customer_phone,
72
- document_id: document_id,
73
- fx_rate_id: fx_rate_id,
74
- billing_address: billing_address_parameters_structure,
75
- shipping_address: shipping_address_parameters_structure,
76
- mpi_params: mpi_attributes_structure,
77
- risk_params: risk_parameters_structure,
78
- dynamic_descriptor_params: dynamic_descriptor_structure,
79
- business_attributes: business_attributes_structure,
80
- recurring_type: recurring_type,
81
- recurring_category: recurring_category,
82
- sca_params: sca_attributes_structure,
83
- threeds_v2_params: threeds_v2_common_attributes_structure,
84
- managed_recurring: managed_recurring_attributes_structure,
85
- travel: travel_data_attributes_structure,
86
- funding: funding_attributes_structure
65
+ notification_url: notification_url,
66
+ return_success_url: return_success_url,
67
+ return_failure_url: return_failure_url,
68
+ gaming: gaming,
69
+ moto: moto,
70
+ crypto: crypto,
71
+ customer_email: customer_email,
72
+ customer_phone: customer_phone,
73
+ document_id: document_id,
74
+ fx_rate_id: fx_rate_id,
75
+ billing_address: billing_address_parameters_structure,
76
+ shipping_address: shipping_address_parameters_structure,
77
+ mpi_params: mpi_attributes_structure,
78
+ risk_params: risk_parameters_structure,
79
+ dynamic_descriptor_params: dynamic_descriptor_structure,
80
+ business_attributes: business_attributes_structure,
81
+ recurring_type: recurring_type,
82
+ recurring_category: recurring_category,
83
+ sca_params: sca_attributes_structure,
84
+ threeds_v2_params: threeds_v2_common_attributes_structure,
85
+ managed_recurring: managed_recurring_attributes_structure,
86
+ travel: travel_data_attributes_structure,
87
+ funding: funding_attributes_structure,
88
+ installment_plan_id: installment_plan_id,
89
+ installment_plan_reference: installment_plan_reference
87
90
  )
88
91
  end
89
92
 
@@ -12,6 +12,7 @@ module GenesisRuby
12
12
  include Mixins::Requests::DocumentAttributes
13
13
  include Mixins::Requests::Financial::Business::BusinessAttributes
14
14
  include Mixins::Requests::Financial::Cards::FxRateAttributes
15
+ include Mixins::Requests::Financial::Cards::InstallmentAttributes
15
16
  include Mixins::Requests::Financial::Cards::Recurring::ManagedRecurringAttributes
16
17
  include Mixins::Requests::Financial::Cards::Recurring::RecurringCategoryAttributes
17
18
  include Mixins::Requests::Financial::Cards::Recurring::RecurringTypeAttributes
@@ -49,25 +50,27 @@ module GenesisRuby
49
50
 
50
51
  def payment_transaction_structure # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
51
52
  super.merge(
52
- gaming: gaming,
53
- moto: moto,
54
- crypto: crypto,
55
- customer_email: customer_email,
56
- customer_phone: customer_phone,
57
- reference_id: reference_id,
58
- document_id: document_id,
59
- fx_rate_id: fx_rate_id,
60
- billing_address: billing_address_parameters_structure,
61
- shipping_address: shipping_address_parameters_structure,
62
- risk_params: risk_parameters_structure,
63
- dynamic_descriptor_params: dynamic_descriptor_structure,
64
- business_attributes: business_attributes_structure,
65
- recurring_type: recurring_type,
66
- recurring_category: recurring_category,
67
- sca_params: sca_attributes_structure,
68
- managed_recurring: managed_recurring_attributes_structure,
69
- travel: travel_data_attributes_structure,
70
- funding: funding_attributes_structure
53
+ gaming: gaming,
54
+ moto: moto,
55
+ crypto: crypto,
56
+ customer_email: customer_email,
57
+ customer_phone: customer_phone,
58
+ reference_id: reference_id,
59
+ document_id: document_id,
60
+ fx_rate_id: fx_rate_id,
61
+ billing_address: billing_address_parameters_structure,
62
+ shipping_address: shipping_address_parameters_structure,
63
+ risk_params: risk_parameters_structure,
64
+ dynamic_descriptor_params: dynamic_descriptor_structure,
65
+ business_attributes: business_attributes_structure,
66
+ recurring_type: recurring_type,
67
+ recurring_category: recurring_category,
68
+ sca_params: sca_attributes_structure,
69
+ managed_recurring: managed_recurring_attributes_structure,
70
+ travel: travel_data_attributes_structure,
71
+ funding: funding_attributes_structure,
72
+ installment_plan_id: installment_plan_id,
73
+ installment_plan_reference: installment_plan_reference
71
74
  )
72
75
  end
73
76
 
@@ -13,6 +13,7 @@ module GenesisRuby
13
13
  include Mixins::Requests::Financial::AsyncAttributes
14
14
  include Mixins::Requests::Financial::Business::BusinessAttributes
15
15
  include Mixins::Requests::Financial::Cards::FxRateAttributes
16
+ include Mixins::Requests::Financial::Cards::InstallmentAttributes
16
17
  include Mixins::Requests::Financial::Cards::MpiAttributes
17
18
  include Mixins::Requests::Financial::Cards::Recurring::ManagedRecurringAttributes
18
19
  include Mixins::Requests::Financial::Cards::Recurring::RecurringCategoryAttributes
@@ -60,29 +61,31 @@ module GenesisRuby
60
61
  # Sale 3D transaction request parameters
61
62
  def payment_transaction_structure # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
62
63
  super.merge(
63
- notification_url: notification_url,
64
- return_success_url: return_success_url,
65
- return_failure_url: return_failure_url,
66
- gaming: gaming,
67
- moto: moto,
68
- crypto: crypto,
69
- customer_email: customer_email,
70
- customer_phone: customer_phone,
71
- document_id: document_id,
72
- fx_rate_id: fx_rate_id,
73
- billing_address: billing_address_parameters_structure,
74
- shipping_address: shipping_address_parameters_structure,
75
- mpi_params: mpi_attributes_structure,
76
- risk_params: risk_parameters_structure,
77
- dynamic_descriptor_params: dynamic_descriptor_structure,
78
- business_attributes: business_attributes_structure,
79
- recurring_type: recurring_type,
80
- recurring_category: recurring_category,
81
- sca_params: sca_attributes_structure,
82
- threeds_v2_params: threeds_v2_common_attributes_structure,
83
- managed_recurring: managed_recurring_attributes_structure,
84
- travel: travel_data_attributes_structure,
85
- funding: funding_attributes_structure
64
+ notification_url: notification_url,
65
+ return_success_url: return_success_url,
66
+ return_failure_url: return_failure_url,
67
+ gaming: gaming,
68
+ moto: moto,
69
+ crypto: crypto,
70
+ customer_email: customer_email,
71
+ customer_phone: customer_phone,
72
+ document_id: document_id,
73
+ fx_rate_id: fx_rate_id,
74
+ billing_address: billing_address_parameters_structure,
75
+ shipping_address: shipping_address_parameters_structure,
76
+ mpi_params: mpi_attributes_structure,
77
+ risk_params: risk_parameters_structure,
78
+ dynamic_descriptor_params: dynamic_descriptor_structure,
79
+ business_attributes: business_attributes_structure,
80
+ recurring_type: recurring_type,
81
+ recurring_category: recurring_category,
82
+ sca_params: sca_attributes_structure,
83
+ threeds_v2_params: threeds_v2_common_attributes_structure,
84
+ managed_recurring: managed_recurring_attributes_structure,
85
+ travel: travel_data_attributes_structure,
86
+ funding: funding_attributes_structure,
87
+ installment_plan_id: installment_plan_id,
88
+ installment_plan_reference: installment_plan_reference
86
89
  )
87
90
  end
88
91
 
@@ -1,5 +1,8 @@
1
1
  require 'genesis_ruby/api/constants/transactions/parameters/refund/bank_account_types'
2
+ require 'genesis_ruby/api/constants/transactions/parameters/refund/credit_reason_indicators'
3
+ require 'genesis_ruby/api/constants/transactions/parameters/refund/ticket_change_indicators'
2
4
 
5
+ # rubocop:disable Naming/VariableNumber
3
6
  module GenesisRuby
4
7
  module Api
5
8
  module Requests
@@ -7,27 +10,34 @@ module GenesisRuby
7
10
  # Refund reference transaction request
8
11
  class Refund < Requests::Base::Reference
9
12
 
13
+ include Mixins::Requests::Financial::Cards::InstallmentAttributes
14
+
10
15
  attr_accessor :beneficiary_bank_code, :beneficiary_name, :beneficiary_account_number, :bank, :bank_branch,
11
- :bank_account
12
- attr_reader :bank_account_type
13
-
14
- # The type of account
15
- def bank_account_type=(value)
16
- allowed_options attribute: __method__,
17
- allowed: Api::Constants::Transactions::Parameters::Refund::BankAccountTypes.all,
18
- value: value,
19
- allow_empty: true
20
- end
16
+ :bank_account, :bank_account_type, :credit_reason_indicator_1, :credit_reason_indicator_2,
17
+ :ticket_change_indicator
21
18
 
22
19
  protected
23
20
 
21
+ # Field Validations
22
+ def init_field_validations
23
+ super
24
+
25
+ field_values.merge! bank_account_type: Constants::Transactions::Parameters::Refund::BankAccountTypes.all,
26
+ credit_reason_indicator_1: Constants::Transactions::Parameters::Refund::
27
+ CreditReasonIndicators.all,
28
+ credit_reason_indicator_2: Constants::Transactions::Parameters::Refund::
29
+ CreditReasonIndicators.all,
30
+ ticket_change_indicator: Constants::Transactions::Parameters::Refund::
31
+ TicketChangeIndicators.all
32
+ end
33
+
24
34
  # Refund Transaction Request type
25
35
  def transaction_type
26
36
  Api::Constants::Transactions::REFUND
27
37
  end
28
38
 
29
39
  # Refund Transaction Request Structure
30
- def reference_transaction_structure
40
+ def reference_transaction_structure # rubocop:disable Metrics/MethodLength
31
41
  {
32
42
  beneficiary_bank_code: beneficiary_bank_code,
33
43
  beneficiary_name: beneficiary_name,
@@ -35,7 +45,16 @@ module GenesisRuby
35
45
  bank: bank,
36
46
  bank_branch: bank_branch,
37
47
  bank_account: bank_account,
38
- bank_account_type: bank_account_type
48
+ bank_account_type: bank_account_type,
49
+ installment_plan_id: installment_plan_id,
50
+ installment_plan_reference: installment_plan_reference,
51
+ travel: {
52
+ ticket: {
53
+ credit_reason_indicator_1: credit_reason_indicator_1,
54
+ credit_reason_indicator_2: credit_reason_indicator_2,
55
+ ticket_change_indicator: ticket_change_indicator
56
+ }
57
+ }
39
58
  }
40
59
  end
41
60
 
@@ -44,3 +63,4 @@ module GenesisRuby
44
63
  end
45
64
  end
46
65
  end
66
+ # rubocop:enable Naming/VariableNumber
@@ -0,0 +1,59 @@
1
+ module GenesisRuby
2
+ module Api
3
+ module Requests
4
+ module NonFinancial
5
+ module Installments
6
+ # Fetch the applicable installments for a given amount, currency and card brand.
7
+ class Fetch < Base::Versioned
8
+
9
+ attr_reader :amount, :card_number
10
+ attr_accessor :currency
11
+
12
+ # Installments Fetch initialization
13
+ def initialize(configuration, _builder_interface = nil)
14
+ super configuration
15
+
16
+ self.request_path = 'installments'
17
+ end
18
+
19
+ # Amount of transaction in minor currency unit
20
+ def amount=(value)
21
+ raise InvalidArgumentError, 'Invalid Amount given, only integer value allowed!' unless value.is_a? Integer
22
+
23
+ @amount = value
24
+ end
25
+
26
+ # Complete cc number of customer
27
+ def card_number=(value)
28
+ value = value.to_s
29
+
30
+ raise InvalidArgumentError, 'Invalid Credit Card number given!' unless value =~ /\A[0-9]{13,19}\Z/
31
+
32
+ @card_number = value
33
+ end
34
+
35
+ protected
36
+
37
+ # Fetch request field validations
38
+ def init_field_validations
39
+ super
40
+
41
+ required_fields.push *%i[amount currency card_number]
42
+ field_values.merge! currency: Constants::Currencies::Iso4217.all.map(&:upcase)
43
+ end
44
+
45
+ # Installments Fetch request structure
46
+ def request_structure
47
+ {
48
+ amount: amount,
49
+ currency: currency,
50
+ card_number: card_number
51
+ }
52
+ end
53
+
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,58 @@
1
+ module GenesisRuby
2
+ module Api
3
+ module Requests
4
+ module NonFinancial
5
+ module Installments
6
+ # Retrieves details about a specific installment based on its ID.
7
+ class Show < Base::Versioned
8
+
9
+ attr_writer :installment_id
10
+
11
+ # Installments Show initialization
12
+ def initialize(configuration, _builder_interface = nil)
13
+ super configuration
14
+
15
+ self.request_path = 'installments/:installment_id'
16
+ end
17
+
18
+ # Installment identifier
19
+ def installment_id
20
+ @installment_id.to_s
21
+ end
22
+
23
+ protected
24
+
25
+ # Override default Versioned Network configuration
26
+ def init_configuration
27
+ super
28
+
29
+ init_get_configuration
30
+ end
31
+
32
+ # Fetch request field validations
33
+ def init_field_validations
34
+ super
35
+
36
+ required_fields.push *%i[installment_id]
37
+ end
38
+
39
+ # Installments Show request structure
40
+ def request_structure
41
+ {}
42
+ end
43
+
44
+ # Override API endpoint with provided Installment ID
45
+ def process_request_parameters
46
+ super
47
+
48
+ request_path.sub!(':installment_id', installment_id)
49
+
50
+ init_api_gateway_configuration request_path: "#{version}/#{request_path}", include_token: false
51
+ end
52
+
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
@@ -1,5 +1,6 @@
1
1
  require 'genesis_ruby/builders/xml'
2
2
  require 'genesis_ruby/builders/form'
3
+ require 'genesis_ruby/builders/json'
3
4
  require 'genesis_ruby/errors/builder_error'
4
5
 
5
6
  module GenesisRuby
@@ -20,6 +21,7 @@ module GenesisRuby
20
21
  case request_interface
21
22
  when XML then @builder_context = Builders::Xml.new
22
23
  when FORM then @builder_context = Builders::Form.new
24
+ when JSON then @builder_context = Builders::Json.new
23
25
  else
24
26
  raise GenesisRuby::BuilderError, 'Invalid Builder interface!'
25
27
  end
@@ -0,0 +1,30 @@
1
+ require 'genesis_ruby/builders/base'
2
+ require 'json'
3
+
4
+ module GenesisRuby
5
+ module Builders
6
+ # JSON Document builder
7
+ class Json < Base
8
+
9
+ # JSON constructor
10
+ def initialize
11
+ @document = ''
12
+
13
+ super
14
+ end
15
+
16
+ # JSON output string
17
+ def output
18
+ @document
19
+ end
20
+
21
+ # Generate JSON document
22
+ def populate_nodes(structure)
23
+ @document = JSON.pretty_generate structure
24
+ rescue StandardError => e
25
+ raise BuilderError, "Given request structure can not be generated! #{e.message}"
26
+ end
27
+
28
+ end
29
+ end
30
+ end
@@ -20,6 +20,7 @@ require 'genesis_ruby/api/requests/base/financial'
20
20
  require 'genesis_ruby/api/requests/base/financials/credit_card'
21
21
  require 'genesis_ruby/api/requests/base/financials/south_american_payments'
22
22
  require 'genesis_ruby/api/requests/base/reference'
23
+ require 'genesis_ruby/api/requests/base/versioned'
23
24
  require 'genesis_ruby/api/notification'
24
25
 
25
26
  # Load Financial and Non Financial API Requests
@@ -22,15 +22,15 @@ module GenesisRuby
22
22
  end
23
23
 
24
24
  # Send the request
25
- def execute
25
+ def execute # rubocop:disable Metrics/AbcSize
26
26
  raise NetworkError, 'Request is not initialized' unless @request
27
27
 
28
28
  safe_execute do
29
29
  case request_data.type
30
30
  when Api::Request::METHOD_POST then @response = @request.post path, request_data.body, headers
31
31
  when Api::Request::METHOD_PUT then @response = @request.put path, request_data.body, headers
32
- else
33
- raise 'Invalid Request Type!'
32
+ when Api::Request::METHOD_GET then @response = @request.get path, headers
33
+ else raise 'Invalid Request Type!'
34
34
  end
35
35
  end
36
36
  end
@@ -90,12 +90,17 @@ module GenesisRuby
90
90
 
91
91
  # Define Headers
92
92
  def headers
93
- {
94
- 'Content-Type' => request_data.format,
95
- 'Content-Length' => request_data.body&.length.to_s,
96
- 'Authorization' => "Basic #{request_data.user_login}",
97
- 'User-Agent' => request_data.user_agent
93
+ headers = {
94
+ 'Authorization' => "Basic #{request_data.user_login}",
95
+ 'User-Agent' => request_data.user_agent
98
96
  }
97
+
98
+ unless request_data.type == Api::Request::METHOD_GET
99
+ headers.merge! 'Content-Type' => request_data.format,
100
+ 'Content-Length' => request_data.body&.length.to_s
101
+ end
102
+
103
+ headers
99
104
  end
100
105
 
101
106
  # Safe Request execution
@@ -1,4 +1,5 @@
1
1
  require 'genesis_ruby/parsers/xml'
2
+ require 'genesis_ruby/parsers/json'
2
3
  require 'genesis_ruby/errors/parser_error'
3
4
 
4
5
  module GenesisRuby
@@ -16,6 +17,8 @@ module GenesisRuby
16
17
  case response_interface
17
18
  when XML
18
19
  @parser_context = GenesisRuby::Parsers::Xml.new
20
+ when JSON
21
+ @parser_context = GenesisRuby::Parsers::Json.new
19
22
  else
20
23
  raise GenesisRuby::ParserError, 'Invalid Parser interface!'
21
24
  end
@@ -0,0 +1,18 @@
1
+ require 'genesis_ruby/parsers/base'
2
+ require 'json'
3
+
4
+ module GenesisRuby
5
+ module Parsers
6
+ # JSON Document parser
7
+ class Json < Base
8
+
9
+ # Parse received document
10
+ def parse_document(document)
11
+ @structure = JSON.parse(document, symbolize_names: true)
12
+ rescue StandardError => e
13
+ raise ParserError, "Given JSON string can not be parsed! #{e.message}"
14
+ end
15
+
16
+ end
17
+ end
18
+ end
@@ -33,6 +33,15 @@ module GenesisRuby
33
33
  self.parser_skip_root_node = true
34
34
  end
35
35
 
36
+ # Load pre-defined GET configuration
37
+ def load_get_config
38
+ self.protocol = GenesisRuby::Api::Request::PROTOCOL_HTTPS
39
+ self.port = GenesisRuby::Api::Request::PORT_HTTPS
40
+ self.type = GenesisRuby::Api::Request::METHOD_GET
41
+ self.format = Builder::XML
42
+ self.parser_skip_root_node = false
43
+ end
44
+
36
45
  end
37
46
  end
38
47
  end
@@ -1,5 +1,5 @@
1
1
  module GenesisRuby
2
2
 
3
- VERSION = '0.2.1'.freeze
3
+ VERSION = '0.2.2'.freeze
4
4
 
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: genesis_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - emerchantpay Ltd.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-02-27 00:00:00.000000000 Z
11
+ date: 2025-03-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: net-http
@@ -270,6 +270,8 @@ files:
270
270
  - lib/genesis_ruby/api/constants/transactions/parameters/recurring/categories.rb
271
271
  - lib/genesis_ruby/api/constants/transactions/parameters/recurring/types.rb
272
272
  - lib/genesis_ruby/api/constants/transactions/parameters/refund/bank_account_types.rb
273
+ - lib/genesis_ruby/api/constants/transactions/parameters/refund/credit_reason_indicators.rb
274
+ - lib/genesis_ruby/api/constants/transactions/parameters/refund/ticket_change_indicators.rb
273
275
  - lib/genesis_ruby/api/constants/transactions/parameters/sca_exemptions.rb
274
276
  - lib/genesis_ruby/api/constants/transactions/parameters/threeds/version2/browser/color_depths.rb
275
277
  - lib/genesis_ruby/api/constants/transactions/parameters/threeds/version2/card_holder_account/password_change_indicators.rb
@@ -312,6 +314,7 @@ files:
312
314
  - lib/genesis_ruby/api/mixins/requests/financial/cards/credential_on_file_attributes.rb
313
315
  - lib/genesis_ruby/api/mixins/requests/financial/cards/credit_card_attributes.rb
314
316
  - lib/genesis_ruby/api/mixins/requests/financial/cards/fx_rate_attributes.rb
317
+ - lib/genesis_ruby/api/mixins/requests/financial/cards/installment_attributes.rb
315
318
  - lib/genesis_ruby/api/mixins/requests/financial/cards/mpi_attributes.rb
316
319
  - lib/genesis_ruby/api/mixins/requests/financial/cards/recurring/managed_recurring_attributes.rb
317
320
  - lib/genesis_ruby/api/mixins/requests/financial/cards/recurring/managed_recurring_indian_card_attributes.rb
@@ -358,6 +361,7 @@ files:
358
361
  - lib/genesis_ruby/api/requests/base/financials/credit_card.rb
359
362
  - lib/genesis_ruby/api/requests/base/financials/south_american_payments.rb
360
363
  - lib/genesis_ruby/api/requests/base/reference.rb
364
+ - lib/genesis_ruby/api/requests/base/versioned.rb
361
365
  - lib/genesis_ruby/api/requests/financial/capture.rb
362
366
  - lib/genesis_ruby/api/requests/financial/cards/argencard.rb
363
367
  - lib/genesis_ruby/api/requests/financial/cards/aura.rb
@@ -397,6 +401,8 @@ files:
397
401
  - lib/genesis_ruby/api/requests/financial/refund.rb
398
402
  - lib/genesis_ruby/api/requests/financial/void.rb
399
403
  - lib/genesis_ruby/api/requests/financial/wallets/pay_pay.rb
404
+ - lib/genesis_ruby/api/requests/non_financial/installments/fetch.rb
405
+ - lib/genesis_ruby/api/requests/non_financial/installments/show.rb
400
406
  - lib/genesis_ruby/api/requests/non_financial/reconcile/date_range.rb
401
407
  - lib/genesis_ruby/api/requests/non_financial/reconcile/transaction.rb
402
408
  - lib/genesis_ruby/api/requests/wpf/create.rb
@@ -405,6 +411,7 @@ files:
405
411
  - lib/genesis_ruby/builder.rb
406
412
  - lib/genesis_ruby/builders/base.rb
407
413
  - lib/genesis_ruby/builders/form.rb
414
+ - lib/genesis_ruby/builders/json.rb
408
415
  - lib/genesis_ruby/builders/xml.rb
409
416
  - lib/genesis_ruby/configuration.rb
410
417
  - lib/genesis_ruby/connection.rb
@@ -425,6 +432,7 @@ files:
425
432
  - lib/genesis_ruby/network/net_http.rb
426
433
  - lib/genesis_ruby/parser.rb
427
434
  - lib/genesis_ruby/parsers/base.rb
435
+ - lib/genesis_ruby/parsers/json.rb
428
436
  - lib/genesis_ruby/parsers/xml.rb
429
437
  - lib/genesis_ruby/utils/common.rb
430
438
  - lib/genesis_ruby/utils/formatters/base.rb
@@ -475,7 +483,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
475
483
  - !ruby/object:Gem::Version
476
484
  version: '0'
477
485
  requirements: []
478
- rubygems_version: 3.1.2
486
+ rubygems_version: 3.2.33
479
487
  signing_key:
480
488
  specification_version: 4
481
489
  summary: Ruby Client for Genesis Payment Processing Gateway