genesis_ruby 0.3.2 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +35 -0
- data/README.md +169 -1
- data/VERSION +1 -1
- data/lib/genesis_ruby/api/constants/non_financial/alternatives/alipay/merchant_types.rb +26 -0
- data/lib/genesis_ruby/api/constants/non_financial/alternatives/alipay/site_types.rb +26 -0
- data/lib/genesis_ruby/api/constants/non_financial/kyc/bank_account_types.rb +24 -0
- data/lib/genesis_ruby/api/constants/transactions/parameters/foreign_retailer_indicators.rb +24 -0
- data/lib/genesis_ruby/api/constants/transactions/parameters/funding/person_types.rb +26 -0
- data/lib/genesis_ruby/api/constants/transactions/parameters/money_transfer/purpose_of_payments.rb +46 -19
- data/lib/genesis_ruby/api/constants/transactions/parameters/money_transfer/sender_account_number_types.rb +14 -17
- data/lib/genesis_ruby/api/constants/transactions/parameters/money_transfer/source_of_funds.rb +9 -18
- data/lib/genesis_ruby/api/constants/transactions/parameters/money_transfer/types.rb +31 -4
- data/lib/genesis_ruby/api/constants/transactions/parameters/non_financial/billing_api/enhanced_statement_response_fields.rb +39 -0
- data/lib/genesis_ruby/api/constants/transactions/parameters/non_financial/billing_api/response_fields.rb +2 -0
- data/lib/genesis_ruby/api/constants/transactions/parameters/non_financial/billing_api/statement_order_by_fields.rb +31 -0
- data/lib/genesis_ruby/api/constants/transactions/parameters/non_financial/billing_api/statement_response_fields.rb +14 -13
- data/lib/genesis_ruby/api/constants/transactions/parameters/non_financial/{processing_type.rb → scopes.rb} +4 -3
- data/lib/genesis_ruby/api/constants/transactions/parameters/purpose_of_payment.rb +117 -0
- data/lib/genesis_ruby/api/constants/transactions/parameters/purpose_of_payment_values.rb +267 -0
- data/lib/genesis_ruby/api/constants/transactions/parameters/wallets/e_wallet/payment_types.rb +46 -0
- data/lib/genesis_ruby/api/constants/transactions.rb +9 -0
- data/lib/genesis_ruby/api/mixins/requests/customer_address/billing_info_attributes.rb +3 -1
- data/lib/genesis_ruby/api/mixins/requests/financial/cards/credential_on_file_transaction_link_attributes.rb +83 -0
- data/lib/genesis_ruby/api/mixins/requests/financial/commercial_card_attributes.rb +143 -0
- data/lib/genesis_ruby/api/mixins/requests/financial/funding_attributes.rb +32 -3
- data/lib/genesis_ruby/api/mixins/requests/financial/marketplace_data_attributes.rb +179 -0
- data/lib/genesis_ruby/api/mixins/requests/financial/money_transfer_payout_attributes.rb +49 -46
- data/lib/genesis_ruby/api/mixins/requests/financial/order_attributes.rb +36 -0
- data/lib/genesis_ruby/api/mixins/requests/financial/purpose_of_payment_attributes.rb +14 -4
- data/lib/genesis_ruby/api/mixins/requests/financial/refund/bank_attributes.rb +41 -0
- data/lib/genesis_ruby/api/mixins/requests/financial/refund/beneficiary_attributes.rb +31 -0
- data/lib/genesis_ruby/api/mixins/requests/financial/refund/travel_ticket_attributes.rb +52 -0
- data/lib/genesis_ruby/api/mixins/requests/financial/threeds/force_threeds_attributes.rb +29 -0
- data/lib/genesis_ruby/api/mixins/requests/non_financial/alternatives/alipay/site_information_attributes.rb +57 -0
- data/lib/genesis_ruby/api/mixins/requests/non_financial/date_time_from_to_attributes.rb +102 -0
- data/lib/genesis_ruby/api/mixins/requests/non_financial/kyc/background_checks_attributes.rb +31 -10
- data/lib/genesis_ruby/api/mixins/requests/non_financial/kyc/verification_document_attributes.rb +49 -7
- data/lib/genesis_ruby/api/mixins/requests/non_financial/kyc/verification_instructions_attributes.rb +90 -0
- data/lib/genesis_ruby/api/mixins/requests/non_financial/reconcile_order_attributes.rb +30 -0
- data/lib/genesis_ruby/api/mixins/requests/non_financial/scope_attributes.rb +29 -0
- data/lib/genesis_ruby/api/mixins/requests/restricted_setter.rb +12 -0
- data/lib/genesis_ruby/api/mixins/requests/scheme_tokenized_attributes.rb +35 -0
- data/lib/genesis_ruby/api/requests/base/financials/credit_card.rb +1 -12
- data/lib/genesis_ruby/api/requests/base/graphql.rb +7 -0
- data/lib/genesis_ruby/api/requests/base/non_financial/billing_api/abstract_statement.rb +226 -0
- data/lib/genesis_ruby/api/requests/base/non_financial/billing_api/base.rb +39 -37
- data/lib/genesis_ruby/api/requests/base/non_financial/reconcile/base.rb +45 -0
- data/lib/genesis_ruby/api/requests/financial/async_refund.rb +41 -0
- data/lib/genesis_ruby/api/requests/financial/cards/authorize.rb +43 -24
- data/lib/genesis_ruby/api/requests/financial/cards/authorize3d.rb +13 -1
- data/lib/genesis_ruby/api/requests/financial/cards/payout.rb +21 -5
- data/lib/genesis_ruby/api/requests/financial/cards/sale.rb +42 -23
- data/lib/genesis_ruby/api/requests/financial/cards/sale3d.rb +13 -1
- data/lib/genesis_ruby/api/requests/financial/mobile/apple_pay.rb +5 -1
- data/lib/genesis_ruby/api/requests/financial/mobile/google_pay.rb +6 -2
- data/lib/genesis_ruby/api/requests/financial/online_banking_payments/my_bank.rb +1 -1
- data/lib/genesis_ruby/api/requests/financial/refund.rb +20 -35
- data/lib/genesis_ruby/api/requests/financial/sdd/sale.rb +6 -1
- data/lib/genesis_ruby/api/requests/financial/wallets/e_wallet.rb +72 -0
- data/lib/genesis_ruby/api/requests/non_financial/alternatives/alipay/register_merchant.rb +147 -0
- data/lib/genesis_ruby/api/requests/non_financial/billing_api/enhanced_statement.rb +46 -0
- data/lib/genesis_ruby/api/requests/non_financial/billing_api/statement.rb +12 -137
- data/lib/genesis_ruby/api/requests/non_financial/billing_api/transactions.rb +4 -2
- data/lib/genesis_ruby/api/requests/non_financial/fraud/chargeback/date_range.rb +10 -19
- data/lib/genesis_ruby/api/requests/non_financial/fraud/rdr/date_range.rb +91 -0
- data/lib/genesis_ruby/api/requests/non_financial/fraud/rdr/transaction.rb +54 -0
- data/lib/genesis_ruby/api/requests/non_financial/fraud/retrieval/date_range.rb +10 -19
- data/lib/genesis_ruby/api/requests/non_financial/kyc/verifications/bank_account.rb +76 -0
- data/lib/genesis_ruby/api/requests/non_financial/kyc/verifications/create.rb +31 -4
- data/lib/genesis_ruby/api/requests/non_financial/payment_authorizations/date_range.rb +124 -0
- data/lib/genesis_ruby/api/requests/non_financial/processed_transactions/date_range.rb +8 -15
- data/lib/genesis_ruby/api/requests/non_financial/processed_transactions/post_date_range.rb +12 -18
- data/lib/genesis_ruby/api/requests/non_financial/reconcile/date_range.rb +29 -4
- data/lib/genesis_ruby/api/requests/non_financial/reconcile/order.rb +40 -0
- data/lib/genesis_ruby/api/requests/non_financial/reconcile/transaction.rb +1 -15
- data/lib/genesis_ruby/api/requests/non_financial/tokenization/cryptogram.rb +3 -1
- data/lib/genesis_ruby/api/requests/non_financial/tokenization/tokenize.rb +3 -1
- data/lib/genesis_ruby/api/requests/wpf/create.rb +4 -0
- data/lib/genesis_ruby/api/requests/wpf/reconcile.rb +11 -4
- data/lib/genesis_ruby/api/requests/wpf/reconcile_by_date.rb +62 -0
- data/lib/genesis_ruby/api/requests/wpf/reconcile_by_order.rb +38 -0
- data/lib/genesis_ruby/builders/graphql.rb +95 -40
- data/lib/genesis_ruby/dependencies.rb +2 -0
- data/lib/genesis_ruby/utils/money/format.rb +2 -1
- data/lib/genesis_ruby/utils/transactions/financial_types.rb +3 -2
- data/lib/genesis_ruby/utils/transactions/references/refundable_types.rb +2 -1
- data/lib/genesis_ruby/utils/transactions/wpf_types.rb +1 -1
- data/lib/genesis_ruby/version.rb +1 -1
- metadata +40 -35
- data/.kiro/specs/f2025112509-add_managed_recurring_api/.config.kiro +0 -1
- data/.kiro/specs/f2025112509-add_managed_recurring_api/design.md +0 -332
- data/.kiro/specs/f2025112509-add_managed_recurring_api/requirements.md +0 -91
- data/.kiro/specs/f2025112509-add_managed_recurring_api/tasks.md +0 -139
- data/.kiro/specs/f2025112603-add_reverify_endpoint_to_payee_account/.config.kiro +0 -1
- data/.kiro/specs/f2025112603-add_reverify_endpoint_to_payee_account/design.md +0 -148
- data/.kiro/specs/f2025112603-add_reverify_endpoint_to_payee_account/requirements.md +0 -81
- data/.kiro/specs/f2025112603-add_reverify_endpoint_to_payee_account/tasks.md +0 -48
- data/.kiro/specs/f2025112606-add_list_payees_trx_request/.config.kiro +0 -1
- data/.kiro/specs/f2025112606-add_list_payees_trx_request/design.md +0 -112
- data/.kiro/specs/f2025112606-add_list_payees_trx_request/requirements.md +0 -74
- data/.kiro/specs/f2025112606-add_list_payees_trx_request/tasks.md +0 -38
- data/.kiro/specs/f2025112609_update_payee_request_params/design.md +0 -86
- data/.kiro/specs/f2025112609_update_payee_request_params/requirements.md +0 -86
- data/.kiro/specs/f2025112609_update_payee_request_params/tasks.md +0 -40
- data/.kiro/specs/f2025112612-add_payee_owner_documents_and_verification_requests/.config.kiro +0 -1
- data/.kiro/specs/f2025112612-add_payee_owner_documents_and_verification_requests/design.md +0 -246
- data/.kiro/specs/f2025112612-add_payee_owner_documents_and_verification_requests/requirements.md +0 -287
- data/.kiro/specs/f2025112612-add_payee_owner_documents_and_verification_requests/tasks.md +0 -76
- data/.kiro/specs/f2025112614-add_money_transfer_payout_attributes_to_payout_rq/design.md +0 -84
- data/.kiro/specs/f2025112614-add_money_transfer_payout_attributes_to_payout_rq/requirements.md +0 -88
- data/.kiro/specs/f2025112614-add_money_transfer_payout_attributes_to_payout_rq/tasks.md +0 -38
- data/.kiro/steering/product.md +0 -15
- data/.kiro/steering/spec-folder-naming.md +0 -16
- data/.kiro/steering/structure.md +0 -96
- data/.kiro/steering/tech.md +0 -66
- data/Gemfile +0 -6
- data/Gemfile.lock +0 -176
- data/Rakefile +0 -24
- data/genesis_ruby.gemspec +0 -47
- data/lib/genesis_ruby/api/constants/transactions/parameters/non_financial/externally_processed.rb +0 -24
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module GenesisRuby
|
|
4
|
+
module Api
|
|
5
|
+
module Mixins
|
|
6
|
+
module Requests
|
|
7
|
+
# Scheme Tokenized Attributes mixin
|
|
8
|
+
module SchemeTokenizedAttributes
|
|
9
|
+
|
|
10
|
+
attr_reader :scheme_tokenized
|
|
11
|
+
|
|
12
|
+
# Optional boolean that indicates whether Card Scheme Tokenization is used
|
|
13
|
+
# (Visa Tokenization for Visa, Digital Secure Remote Payments (DSRP) for Mastercard)
|
|
14
|
+
def scheme_tokenized=(value)
|
|
15
|
+
allowed_options attribute: __method__,
|
|
16
|
+
allowed: [true, false],
|
|
17
|
+
value: value,
|
|
18
|
+
allow_empty: true,
|
|
19
|
+
error_message: 'Accepts only boolean values'
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
protected
|
|
23
|
+
|
|
24
|
+
# Scheme Tokenized Attributes Structure
|
|
25
|
+
def scheme_tokenized_attributes_structure
|
|
26
|
+
{
|
|
27
|
+
scheme_tokenized: scheme_tokenized
|
|
28
|
+
}
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -14,18 +14,7 @@ module GenesisRuby
|
|
|
14
14
|
include Mixins::Requests::Financial::Cards::TokenizationAttributes
|
|
15
15
|
include Mixins::Requests::Financial::Cards::TokenizationParamsAttributes
|
|
16
16
|
include Mixins::Requests::Financial::Cards::UcofAttributes
|
|
17
|
-
|
|
18
|
-
attr_reader :scheme_tokenized
|
|
19
|
-
|
|
20
|
-
# Visa tokenization for Visa
|
|
21
|
-
# Digital Secure Remote Payments (DSRP) for Mastercard.
|
|
22
|
-
def scheme_tokenized=(value)
|
|
23
|
-
allowed_options attribute: __method__,
|
|
24
|
-
allowed: [true, false],
|
|
25
|
-
value: value,
|
|
26
|
-
allow_empty: true,
|
|
27
|
-
error_message: 'Accepts only boolean values'
|
|
28
|
-
end
|
|
17
|
+
include Mixins::Requests::SchemeTokenizedAttributes
|
|
29
18
|
|
|
30
19
|
protected
|
|
31
20
|
|
|
@@ -43,6 +43,12 @@ module GenesisRuby
|
|
|
43
43
|
raise NoMethodError, "Response Fields isn't defined for #{self.class.name}"
|
|
44
44
|
end
|
|
45
45
|
|
|
46
|
+
# Filter keys rendered without surrounding quotes (bare GraphQL ENUM tokens).
|
|
47
|
+
# Defaults to none; concrete requests override to expose bare ENUM filters.
|
|
48
|
+
def filters_without_quotes
|
|
49
|
+
[]
|
|
50
|
+
end
|
|
51
|
+
|
|
46
52
|
# GraphQL request structure
|
|
47
53
|
def request_structure
|
|
48
54
|
Hash[
|
|
@@ -50,6 +56,7 @@ module GenesisRuby
|
|
|
50
56
|
Hash[
|
|
51
57
|
:action, request_name,
|
|
52
58
|
:filters, query_filters,
|
|
59
|
+
:filters_without_quotes, filters_without_quotes,
|
|
53
60
|
:response_fields, query_response_fields
|
|
54
61
|
]
|
|
55
62
|
]
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'date'
|
|
4
|
+
require 'genesis_ruby/api/constants/date_time_formats'
|
|
5
|
+
require 'genesis_ruby/api/constants/currencies/iso4217'
|
|
6
|
+
require 'genesis_ruby/api/requests/base/non_financial/billing_api/base'
|
|
7
|
+
|
|
8
|
+
module GenesisRuby
|
|
9
|
+
module Api
|
|
10
|
+
module Requests
|
|
11
|
+
module Base
|
|
12
|
+
module NonFinancial
|
|
13
|
+
module BillingApi
|
|
14
|
+
# Shared base for billingStatements and enhancedBillingStatements requests
|
|
15
|
+
class AbstractStatement < NonFinancial::BillingApi::Base # rubocop:disable Metrics/ClassLength
|
|
16
|
+
|
|
17
|
+
include Api::Mixins::Requests::NonFinancial::DateTimeFromToAttributes
|
|
18
|
+
|
|
19
|
+
MAX_COUNT_BILLING_STATEMENT = 1_000
|
|
20
|
+
MAX_COUNT_MASTER_ACCOUNT_MID = 1_000
|
|
21
|
+
MAX_DAYS_DIFFERENCE = 7
|
|
22
|
+
|
|
23
|
+
# Allowed values for the +status+ filter
|
|
24
|
+
STATUSES = %w(open pending paid bounced).freeze
|
|
25
|
+
|
|
26
|
+
attr_accessor :payment_method, :status
|
|
27
|
+
attr_reader :currency
|
|
28
|
+
|
|
29
|
+
# Cursor for the next page of results
|
|
30
|
+
attr_writer :next
|
|
31
|
+
|
|
32
|
+
# ISO 4217 currency code, stored upper-cased
|
|
33
|
+
def currency=(value)
|
|
34
|
+
@currency = value.to_s.empty? ? nil : value.to_s.upcase
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# Returns the creation date formatted as YYYY-MM-DD
|
|
38
|
+
def creation_date
|
|
39
|
+
@creation_date&.strftime Api::Constants::DateTimeFormats::YYYY_MM_DD_ISO_8601
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# Sets the creation date filter
|
|
43
|
+
def creation_date=(value)
|
|
44
|
+
parse_date attribute: __method__, value: value, allow_empty: true
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# List of master account MIDs (max 1000). Rendered as a quoted GraphQL list literal.
|
|
48
|
+
def master_account_mid
|
|
49
|
+
@master_account_mid || []
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# Sets the list of master account MIDs
|
|
53
|
+
def master_account_mid=(value)
|
|
54
|
+
parse_array_of_strings attribute: __method__, value: value, allow_empty: true
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# List of requested response fields
|
|
58
|
+
def response_fields
|
|
59
|
+
@response_fields || []
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
# Accepts flat names and/or single-pair Hash[name => nested selection]
|
|
63
|
+
def response_fields=(value)
|
|
64
|
+
validate_response_fields_structure value
|
|
65
|
+
|
|
66
|
+
@response_fields = value
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
protected
|
|
70
|
+
|
|
71
|
+
# Abstract: concrete request must define the GraphQL query name
|
|
72
|
+
def request_name
|
|
73
|
+
raise NoMethodError, "request_name isn't defined for #{self.class.name}"
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
# Abstract: concrete request must define the allowed top-level response fields
|
|
77
|
+
def allowed_response_fields
|
|
78
|
+
raise NoMethodError, "allowed_response_fields isn't defined for #{self.class.name}"
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
# Abstract: concrete request must define the allowed order-by fields
|
|
82
|
+
def allowed_order_by_fields
|
|
83
|
+
raise NoMethodError, "allowed_order_by_fields isn't defined for #{self.class.name}"
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
# Registers response_fields as required and merges allowed values
|
|
87
|
+
def init_field_validations
|
|
88
|
+
super
|
|
89
|
+
|
|
90
|
+
required_fields.push :response_fields
|
|
91
|
+
field_values.merge! currency: Api::Constants::Currencies::Iso4217.all.map(&:upcase),
|
|
92
|
+
status: STATUSES,
|
|
93
|
+
sort_by_field: allowed_order_by_fields.all
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
# Validates all request requirements including filters and date ranges
|
|
97
|
+
def check_requirements
|
|
98
|
+
super
|
|
99
|
+
|
|
100
|
+
validate_filters
|
|
101
|
+
validate_statement_date_ranges
|
|
102
|
+
validate_array_size :billing_statement, MAX_COUNT_BILLING_STATEMENT
|
|
103
|
+
validate_array_size :master_account_mid, MAX_COUNT_MASTER_ACCOUNT_MID
|
|
104
|
+
validate_response_fields_allowed
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
# Declarative filter map; empty values are omitted by the builder
|
|
108
|
+
def query_filters # rubocop:disable Metrics/MethodLength
|
|
109
|
+
filters = {
|
|
110
|
+
startDateFrom: start_date_from,
|
|
111
|
+
startDateTo: start_date_to,
|
|
112
|
+
endDateFrom: end_date_from,
|
|
113
|
+
endDateTo: end_date_to,
|
|
114
|
+
billingStatement: billing_statement,
|
|
115
|
+
masterAccountMID: master_account_mid,
|
|
116
|
+
currency: currency,
|
|
117
|
+
status: status,
|
|
118
|
+
paymentMethod: payment_method,
|
|
119
|
+
creationDate: creation_date
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
{ filter: filters, **paging_and_sort }
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
# Filters rendered without surrounding quotes
|
|
126
|
+
def filters_without_quotes
|
|
127
|
+
%w(billingStatement status masterAccountMID)
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
# Builds the GraphQL response fields structure including paging metadata
|
|
131
|
+
def query_response_fields
|
|
132
|
+
{ items: response_fields, paging: %w(count perPage after before) }
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
private
|
|
136
|
+
|
|
137
|
+
# Merges sort and cursor-based paging into a single hash, omitting empty values
|
|
138
|
+
def paging_and_sort
|
|
139
|
+
result = {}
|
|
140
|
+
result[:sort] = { byDirection: sort_by_direction, byField: sort_by_field }.compact
|
|
141
|
+
result[:paging] = cursor_paging
|
|
142
|
+
result.reject { |_, v| v.respond_to?(:empty?) && v.empty? }
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
# Builds the cursor-based paging hash
|
|
146
|
+
def cursor_paging
|
|
147
|
+
paging = {}
|
|
148
|
+
paging[:perPage] = per_page if per_page
|
|
149
|
+
paging[:next] = @next if @next
|
|
150
|
+
paging
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
# Assignment-time structural check for response_fields
|
|
154
|
+
def validate_response_fields_structure(value)
|
|
155
|
+
raise InvalidArgumentError, 'response_fields accepts only Array value.' unless value.is_a?(Array)
|
|
156
|
+
|
|
157
|
+
value.each { |node| validate_selection_node node }
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
# Validates a single response-field node (flat name or single-key Hash)
|
|
161
|
+
def validate_selection_node(node) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity
|
|
162
|
+
return if node.is_a?(String) || node.is_a?(Symbol)
|
|
163
|
+
|
|
164
|
+
unless node.is_a?(Hash) && node.size == 1
|
|
165
|
+
raise InvalidArgumentError, 'response_fields entries must be a field name or a single-key Hash.'
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
sub = node.values.first
|
|
169
|
+
if !sub.is_a?(Array) || sub.empty?
|
|
170
|
+
raise InvalidArgumentError, "Empty sub-selection for #{node.keys.first}."
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
sub.each { |child| validate_selection_node child }
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
# Applies Date_Range_Pair validation to both statement range pairs.
|
|
177
|
+
# Each pair is validated only when at least one of its boundaries is set, so a
|
|
178
|
+
# request filtering solely on non-date attributes (e.g. currency) is not forced
|
|
179
|
+
# to supply a date pair; a single-boundary pair still raises (R2.1).
|
|
180
|
+
def validate_statement_date_ranges
|
|
181
|
+
if @start_date_from || @start_date_to
|
|
182
|
+
validate_date_range :start_date_from, :start_date_to, MAX_DAYS_DIFFERENCE, allow_equal: true
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
return unless @end_date_from || @end_date_to
|
|
186
|
+
|
|
187
|
+
validate_date_range :end_date_from, :end_date_to, MAX_DAYS_DIFFERENCE, allow_equal: true
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
# Raises an error when no filter attributes are set
|
|
191
|
+
def validate_filters
|
|
192
|
+
return unless no_filter_set?
|
|
193
|
+
|
|
194
|
+
raise ParameterError, 'At least one filter is required!'
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
# Determines whether no filter attribute has been set
|
|
198
|
+
def no_filter_set? # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
|
199
|
+
start_date_from.nil? && start_date_to.nil? &&
|
|
200
|
+
end_date_from.nil? && end_date_to.nil? &&
|
|
201
|
+
billing_statement.empty? && master_account_mid.empty? &&
|
|
202
|
+
currency.nil? && status.nil? &&
|
|
203
|
+
payment_method.nil? && creation_date.nil?
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
# Build-time allowed-set check on top-level names only (case-sensitive, exact)
|
|
207
|
+
def validate_response_fields_allowed
|
|
208
|
+
invalid = top_level_names(response_fields) - allowed_response_fields.all
|
|
209
|
+
return if invalid.empty?
|
|
210
|
+
|
|
211
|
+
raise ParameterError, "Invalid response fields: #{invalid.join(", ")}. " \
|
|
212
|
+
"Allowed: #{allowed_response_fields.all.join(", ")}."
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
# Extracts the top-level field names from a response-field selection
|
|
216
|
+
def top_level_names(selection)
|
|
217
|
+
selection.map { |node| node.is_a?(Hash) ? node.keys.first.to_s : node.to_s }
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
end
|
|
221
|
+
end
|
|
222
|
+
end
|
|
223
|
+
end
|
|
224
|
+
end
|
|
225
|
+
end
|
|
226
|
+
end
|
|
@@ -13,7 +13,6 @@ module GenesisRuby
|
|
|
13
13
|
class Base < Requests::Base::Graphql
|
|
14
14
|
|
|
15
15
|
include Api::Mixins::Requests::NonFinancial::BillingApi::SortAttributes
|
|
16
|
-
include Api::Mixins::Requests::NonFinancial::DateAttributes
|
|
17
16
|
include Api::Mixins::Requests::NonFinancial::PagingAttributes
|
|
18
17
|
|
|
19
18
|
# List of billing statement names
|
|
@@ -33,11 +32,6 @@ module GenesisRuby
|
|
|
33
32
|
api_config.bearer_token = configuration.billing_api_token
|
|
34
33
|
end
|
|
35
34
|
|
|
36
|
-
# Additional optional filter arguments (sort + paging)
|
|
37
|
-
def additional_arguments
|
|
38
|
-
[request_order, request_paging].reject(&:empty?).join(' ')
|
|
39
|
-
end
|
|
40
|
-
|
|
41
35
|
# Validate max size of an array attribute
|
|
42
36
|
def validate_array_size(attribute, size)
|
|
43
37
|
return if __send__(attribute).length <= size
|
|
@@ -47,14 +41,19 @@ module GenesisRuby
|
|
|
47
41
|
attribute: attribute, size: size)
|
|
48
42
|
end
|
|
49
43
|
|
|
50
|
-
# Validate a pair of date attributes: both required, from
|
|
51
|
-
|
|
44
|
+
# Validate a pair of date attributes: both required, from before/equal to.
|
|
45
|
+
# When allow_equal is false (default) a zero-length span raises; strict pairs
|
|
46
|
+
# (e.g. Transactions startDate/endDate) keep the historical from < to behaviour.
|
|
47
|
+
# When allow_equal is true a zero-length span (from == to) and an exactly
|
|
48
|
+
# max_days_difference span are accepted (statement range pairs, R2.3/R2.4).
|
|
49
|
+
def validate_date_range(from_attr, to_attr, max_days_difference = 7, allow_equal: false)
|
|
52
50
|
from_val = instance_variable_get("@#{from_attr}")
|
|
53
51
|
to_val = instance_variable_get("@#{to_attr}")
|
|
54
52
|
message = "If filter #{from_attr} is provided, then #{to_attr} should also be provided and vice versa."
|
|
55
53
|
|
|
56
54
|
raise ParameterError, message unless from_val.is_a?(DateTime) && to_val.is_a?(DateTime)
|
|
57
|
-
|
|
55
|
+
|
|
56
|
+
validate_date_order from_attr, to_attr, from_val, to_val, allow_equal
|
|
58
57
|
|
|
59
58
|
days_diff = to_val - from_val
|
|
60
59
|
return unless days_diff > max_days_difference
|
|
@@ -62,41 +61,44 @@ module GenesisRuby
|
|
|
62
61
|
raise ParameterError, "Maximum difference between date range is #{max_days_difference} days"
|
|
63
62
|
end
|
|
64
63
|
|
|
65
|
-
#
|
|
66
|
-
def
|
|
67
|
-
|
|
68
|
-
val.to_s.empty? ? nil : "\"#{val}\""
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
# Wraps a string value in GraphQL double-quotes, or returns nil if blank
|
|
72
|
-
def escape_string(val)
|
|
73
|
-
val.to_s.empty? ? nil : "\"#{val}\""
|
|
74
|
-
end
|
|
64
|
+
# Enforce chronological order for a date pair, honouring allow_equal
|
|
65
|
+
def validate_date_order(from_attr, to_attr, from_val, to_val, allow_equal)
|
|
66
|
+
return if allow_equal ? from_val <= to_val : from_val < to_val
|
|
75
67
|
|
|
76
|
-
|
|
68
|
+
message = if allow_equal
|
|
69
|
+
"#{from_attr} must not be later than #{to_attr}!"
|
|
70
|
+
else
|
|
71
|
+
"#{to_attr} must be after #{from_attr}!"
|
|
72
|
+
end
|
|
77
73
|
|
|
78
|
-
|
|
79
|
-
def request_paging
|
|
80
|
-
paging = {}
|
|
81
|
-
paging[:page] = page if page
|
|
82
|
-
paging[:perPage] = per_page if per_page
|
|
83
|
-
generate_graphql_code(paging, 'paging')
|
|
74
|
+
raise ParameterError, message
|
|
84
75
|
end
|
|
85
76
|
|
|
86
|
-
#
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
77
|
+
# GraphQL string escape table. Backslash MUST stay first so the backslashes
|
|
78
|
+
# introduced by the other sequences are not escaped a second time.
|
|
79
|
+
GRAPHQL_STRING_ESCAPES = {
|
|
80
|
+
'\\' => '\\\\',
|
|
81
|
+
'"' => '\\"',
|
|
82
|
+
"\n" => '\\n',
|
|
83
|
+
"\r" => '\\r',
|
|
84
|
+
"\t" => '\\t',
|
|
85
|
+
"\b" => '\\b',
|
|
86
|
+
"\f" => '\\f'
|
|
87
|
+
}.freeze
|
|
88
|
+
|
|
89
|
+
# Escape a scalar for embedding inside GraphQL double quotes.
|
|
90
|
+
# Escapes backslash, double-quote and the five control characters in a single
|
|
91
|
+
# left-to-right pass so a raw \" becomes \\\" without double-escaping.
|
|
92
|
+
def escape_graphql_string(value)
|
|
93
|
+
value.to_s.gsub(/[\\"\n\r\t\b\f]/, GRAPHQL_STRING_ESCAPES)
|
|
92
94
|
end
|
|
93
95
|
|
|
94
|
-
# Render
|
|
95
|
-
|
|
96
|
-
|
|
96
|
+
# Render an Array of strings as a GraphQL list literal: ["a","b"]
|
|
97
|
+
# Each element is individually escaped and double-quoted, comma-separated, no whitespace.
|
|
98
|
+
def format_string_list(values)
|
|
99
|
+
inner = values.map { |value| %("#{escape_graphql_string(value)}") }.join(',')
|
|
97
100
|
|
|
98
|
-
|
|
99
|
-
"#{key} { #{pairs} }"
|
|
101
|
+
"[#{inner}]"
|
|
100
102
|
end
|
|
101
103
|
|
|
102
104
|
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module GenesisRuby
|
|
4
|
+
module Api
|
|
5
|
+
module Requests
|
|
6
|
+
module Base
|
|
7
|
+
module NonFinancial
|
|
8
|
+
module Reconcile
|
|
9
|
+
# Base Request class for the S2S Reconcile API requests.
|
|
10
|
+
# Builds the terminal based endpoint, or the Smart Router one when Smart Routing is used.
|
|
11
|
+
class Base < Api::Request
|
|
12
|
+
|
|
13
|
+
include Mixins::Requests::SmartRouterAttributes
|
|
14
|
+
|
|
15
|
+
protected
|
|
16
|
+
|
|
17
|
+
# The Reconcile API path, defined by the concrete request
|
|
18
|
+
def request_path
|
|
19
|
+
'reconcile'
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# Set Gateway API configuration
|
|
23
|
+
def init_configuration
|
|
24
|
+
init_xml_configuration
|
|
25
|
+
init_api_gateway_configuration request_path: request_path
|
|
26
|
+
init_api_smart_router_configuration if @configuration.force_smart_routing
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# Initialize Smart Router endpoint
|
|
30
|
+
def init_api_smart_router_configuration
|
|
31
|
+
api_config.url = build_request_url({ subdomain: 'smart_router', path: request_path })
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# Smart Routing is requested for the current request or forced by the configuration
|
|
35
|
+
def smart_router_active?
|
|
36
|
+
use_smart_router || @configuration.force_smart_routing
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module GenesisRuby
|
|
4
|
+
module Api
|
|
5
|
+
module Requests
|
|
6
|
+
module Financial
|
|
7
|
+
# Async Refund reference transaction request. Returns already billed amounts through an asynchronous workflow
|
|
8
|
+
class AsyncRefund < Requests::Base::Reference
|
|
9
|
+
|
|
10
|
+
include Mixins::Requests::Financial::Refund::BankAttributes
|
|
11
|
+
include Mixins::Requests::Financial::Refund::BeneficiaryAttributes
|
|
12
|
+
include Mixins::Requests::Financial::Refund::TravelTicketAttributes
|
|
13
|
+
|
|
14
|
+
protected
|
|
15
|
+
|
|
16
|
+
# Async Refund field validations
|
|
17
|
+
def init_field_validations
|
|
18
|
+
super
|
|
19
|
+
|
|
20
|
+
field_values.merge! refund_bank_attributes_field_validations,
|
|
21
|
+
refund_travel_ticket_attributes_field_validations
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# Async Refund transaction type
|
|
25
|
+
def transaction_type
|
|
26
|
+
Api::Constants::Transactions::ASYNC_REFUND
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# Async Refund request structure
|
|
30
|
+
def reference_transaction_structure
|
|
31
|
+
refund_beneficiary_attributes_structure.merge(
|
|
32
|
+
refund_bank_attributes_structure,
|
|
33
|
+
refund_travel_ticket_attributes_structure
|
|
34
|
+
)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
@@ -15,17 +15,22 @@ module GenesisRuby
|
|
|
15
15
|
include Mixins::Requests::DigitalAssetTypeAttributes
|
|
16
16
|
include Mixins::Requests::DocumentAttributes
|
|
17
17
|
include Mixins::Requests::Financial::Business::BusinessAttributes
|
|
18
|
+
include Mixins::Requests::Financial::Cards::CredentialOnFileTransactionLinkAttributes
|
|
18
19
|
include Mixins::Requests::Financial::Cards::FxRateAttributes
|
|
19
20
|
include Mixins::Requests::Financial::Cards::InstallmentAttributes
|
|
20
21
|
include Mixins::Requests::Financial::Cards::Recurring::ManagedRecurringAttributes
|
|
21
22
|
include Mixins::Requests::Financial::Cards::Recurring::RecurringCategoryAttributes
|
|
22
23
|
include Mixins::Requests::Financial::Cards::Recurring::RecurringTypeAttributes
|
|
24
|
+
include Mixins::Requests::Financial::CommercialCardAttributes
|
|
23
25
|
include Mixins::Requests::Financial::CryptoAttributes
|
|
24
26
|
include Mixins::Requests::Financial::DynamicDescriptorAttributes
|
|
25
27
|
include Mixins::Requests::Financial::FundingAttributes
|
|
26
28
|
include Mixins::Requests::Financial::GamingAttributes
|
|
29
|
+
include Mixins::Requests::Financial::MarketplaceDataAttributes
|
|
27
30
|
include Mixins::Requests::Financial::MotoAttributes
|
|
31
|
+
include Mixins::Requests::Financial::OrderAttributes
|
|
28
32
|
include Mixins::Requests::Financial::PreauthorizationAttributes
|
|
33
|
+
include Mixins::Requests::Financial::PurposeOfPaymentAttributes
|
|
29
34
|
include Mixins::Requests::Financial::ReferenceAttributes
|
|
30
35
|
include Mixins::Requests::Financial::RiskAttributes
|
|
31
36
|
include Mixins::Requests::Financial::ScaAttributes
|
|
@@ -53,32 +58,46 @@ module GenesisRuby
|
|
|
53
58
|
self.required_fields = recurring_type_subsequent_required_request_attributes
|
|
54
59
|
end
|
|
55
60
|
|
|
61
|
+
# Special validations upon document building
|
|
62
|
+
def check_requirements
|
|
63
|
+
validate_credential_on_file_transaction_link_id
|
|
64
|
+
|
|
65
|
+
super
|
|
66
|
+
|
|
67
|
+
validate_marketplace_data_attributes
|
|
68
|
+
validate_commercial_card_attributes
|
|
69
|
+
end
|
|
70
|
+
|
|
56
71
|
def payment_transaction_structure # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
|
57
72
|
super.merge(
|
|
58
|
-
gaming:
|
|
59
|
-
moto:
|
|
60
|
-
preauthorization:
|
|
61
|
-
crypto:
|
|
62
|
-
customer_email:
|
|
63
|
-
customer_phone:
|
|
64
|
-
reference_id:
|
|
65
|
-
document_id:
|
|
66
|
-
fx_rate_id:
|
|
67
|
-
billing_address:
|
|
68
|
-
shipping_address:
|
|
69
|
-
risk_params:
|
|
70
|
-
dynamic_descriptor_params:
|
|
71
|
-
business_attributes:
|
|
72
|
-
recurring_type:
|
|
73
|
-
recurring_category:
|
|
74
|
-
sca_params:
|
|
75
|
-
managed_recurring:
|
|
76
|
-
travel:
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
73
|
+
gaming: gaming,
|
|
74
|
+
moto: moto,
|
|
75
|
+
preauthorization: preauthorization,
|
|
76
|
+
crypto: crypto,
|
|
77
|
+
customer_email: customer_email,
|
|
78
|
+
customer_phone: customer_phone,
|
|
79
|
+
reference_id: reference_id,
|
|
80
|
+
document_id: document_id,
|
|
81
|
+
fx_rate_id: fx_rate_id,
|
|
82
|
+
billing_address: billing_address_parameters_structure,
|
|
83
|
+
shipping_address: shipping_address_parameters_structure,
|
|
84
|
+
risk_params: risk_parameters_structure,
|
|
85
|
+
dynamic_descriptor_params: dynamic_descriptor_structure,
|
|
86
|
+
business_attributes: business_attributes_structure,
|
|
87
|
+
recurring_type: recurring_type,
|
|
88
|
+
recurring_category: recurring_category,
|
|
89
|
+
sca_params: sca_attributes_structure,
|
|
90
|
+
managed_recurring: managed_recurring_attributes_structure,
|
|
91
|
+
travel: travel_data_attributes_structure,
|
|
92
|
+
marketplace_data: marketplace_data_attributes_structure,
|
|
93
|
+
funding: funding_attributes_structure,
|
|
94
|
+
items: commercial_card_attributes_structure,
|
|
95
|
+
purpose_of_payment: purpose_of_payment,
|
|
96
|
+
installment_plan_id: installment_plan_id,
|
|
97
|
+
installment_plan_reference: installment_plan_reference,
|
|
98
|
+
digital_asset_type: digital_asset_type,
|
|
99
|
+
credential_on_file_transaction_link_id: credential_on_file_transaction_link_id
|
|
100
|
+
).merge(order_attributes_structure)
|
|
82
101
|
end
|
|
83
102
|
|
|
84
103
|
end
|
|
@@ -22,15 +22,20 @@ module GenesisRuby
|
|
|
22
22
|
include Mixins::Requests::Financial::Cards::Recurring::ManagedRecurringAttributes
|
|
23
23
|
include Mixins::Requests::Financial::Cards::Recurring::RecurringCategoryAttributes
|
|
24
24
|
include Mixins::Requests::Financial::Cards::Recurring::RecurringTypeAttributes
|
|
25
|
+
include Mixins::Requests::Financial::CommercialCardAttributes
|
|
25
26
|
include Mixins::Requests::Financial::CryptoAttributes
|
|
26
27
|
include Mixins::Requests::Financial::DynamicDescriptorAttributes
|
|
27
28
|
include Mixins::Requests::Financial::FundingAttributes
|
|
28
29
|
include Mixins::Requests::Financial::GamingAttributes
|
|
30
|
+
include Mixins::Requests::Financial::MarketplaceDataAttributes
|
|
29
31
|
include Mixins::Requests::Financial::MotoAttributes
|
|
30
32
|
include Mixins::Requests::Financial::NotificationAttributes
|
|
33
|
+
include Mixins::Requests::Financial::OrderAttributes
|
|
31
34
|
include Mixins::Requests::Financial::PreauthorizationAttributes
|
|
35
|
+
include Mixins::Requests::Financial::PurposeOfPaymentAttributes
|
|
32
36
|
include Mixins::Requests::Financial::RiskAttributes
|
|
33
37
|
include Mixins::Requests::Financial::ScaAttributes
|
|
38
|
+
include Mixins::Requests::Financial::Threeds::ForceThreedsAttributes
|
|
34
39
|
include Mixins::Requests::Financial::Threeds::Version2::CommonAttributes
|
|
35
40
|
include Mixins::Requests::Financial::TravelData::TravelAttributes
|
|
36
41
|
|
|
@@ -59,6 +64,9 @@ module GenesisRuby
|
|
|
59
64
|
validate_threeds_card_holder_dates
|
|
60
65
|
|
|
61
66
|
super
|
|
67
|
+
|
|
68
|
+
validate_marketplace_data_attributes
|
|
69
|
+
validate_commercial_card_attributes
|
|
62
70
|
end
|
|
63
71
|
|
|
64
72
|
# Authorize 3D transaction request parameters
|
|
@@ -85,13 +93,17 @@ module GenesisRuby
|
|
|
85
93
|
recurring_category: recurring_category,
|
|
86
94
|
sca_params: sca_attributes_structure,
|
|
87
95
|
threeds_v2_params: threeds_v2_common_attributes_structure,
|
|
96
|
+
force_threeds: force_threeds,
|
|
88
97
|
managed_recurring: managed_recurring_attributes_structure,
|
|
89
98
|
travel: travel_data_attributes_structure,
|
|
99
|
+
marketplace_data: marketplace_data_attributes_structure,
|
|
90
100
|
funding: funding_attributes_structure,
|
|
101
|
+
items: commercial_card_attributes_structure,
|
|
102
|
+
purpose_of_payment: purpose_of_payment,
|
|
91
103
|
installment_plan_id: installment_plan_id,
|
|
92
104
|
installment_plan_reference: installment_plan_reference,
|
|
93
105
|
digital_asset_type: digital_asset_type
|
|
94
|
-
)
|
|
106
|
+
).merge(order_attributes_structure)
|
|
95
107
|
end
|
|
96
108
|
|
|
97
109
|
end
|