checkout_sdk 0.3.2 → 1.0.0.beta.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/.rubocop.yml +31 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/Gemfile +5 -2
- data/LICENSE.md +9 -0
- data/README.md +96 -110
- data/Rakefile +3 -1
- data/lib/checkout_sdk/abstract_checkout_sdk_builder.rb +28 -0
- data/lib/checkout_sdk/api_client.rb +135 -0
- data/lib/checkout_sdk/apm/apm.rb +12 -0
- data/lib/checkout_sdk/apm/ideal/ideal_client.rb +25 -0
- data/lib/checkout_sdk/apm/previous/klarna/credit_session_request.rb +30 -0
- data/lib/checkout_sdk/apm/previous/klarna/klarna.rb +24 -0
- data/lib/checkout_sdk/apm/previous/klarna/klarna_client.rb +55 -0
- data/lib/checkout_sdk/apm/previous/klarna/klarna_product.rb +30 -0
- data/lib/checkout_sdk/apm/previous/klarna/klarna_shipping_info.rb +33 -0
- data/lib/checkout_sdk/apm/previous/klarna/order_capture_request.rb +37 -0
- data/lib/checkout_sdk/apm/previous/sepa/sepa_client.rb +42 -0
- data/lib/checkout_sdk/authorization_type.rb +12 -0
- data/lib/checkout_sdk/checkout_api.rb +51 -0
- data/lib/checkout_sdk/checkout_configuration.rb +22 -0
- data/lib/checkout_sdk/checkout_oauth_sdk_builder.rb +52 -0
- data/lib/checkout_sdk/checkout_sdk_builder.rb +20 -0
- data/lib/checkout_sdk/checkout_static_keys_sdk_builder.rb +23 -0
- data/lib/checkout_sdk/checkout_utils.rb +15 -0
- data/lib/checkout_sdk/client.rb +46 -0
- data/lib/checkout_sdk/common/abstract_file_request.rb +11 -0
- data/lib/checkout_sdk/common/account_holder.rb +44 -0
- data/lib/checkout_sdk/common/account_holder_identification.rb +20 -0
- data/lib/checkout_sdk/common/account_holder_identification_type.rb +13 -0
- data/lib/checkout_sdk/common/account_holder_type.rb +11 -0
- data/lib/checkout_sdk/common/account_type.rb +11 -0
- data/lib/checkout_sdk/common/address.rb +26 -0
- data/lib/checkout_sdk/common/amount_allocations.rb +20 -0
- data/lib/checkout_sdk/common/bank_details.rb +17 -0
- data/lib/checkout_sdk/common/challenge_indicator.rb +12 -0
- data/lib/checkout_sdk/common/commission.rb +14 -0
- data/lib/checkout_sdk/common/common.rb +22 -0
- data/lib/checkout_sdk/common/country.rb +260 -0
- data/lib/checkout_sdk/common/currency.rb +168 -0
- data/lib/checkout_sdk/common/customer_request.rb +26 -0
- data/lib/checkout_sdk/common/file_purpose.rb +9 -0
- data/lib/checkout_sdk/common/file_request.rb +11 -0
- data/lib/checkout_sdk/common/instrument_type.rb +11 -0
- data/lib/checkout_sdk/common/payment_source_type.rb +52 -0
- data/lib/checkout_sdk/common/phone.rb +14 -0
- data/lib/checkout_sdk/common/update_customer_request.rb +14 -0
- data/lib/checkout_sdk/customers/customer_request.rb +26 -0
- data/lib/checkout_sdk/customers/customers.rb +4 -0
- data/lib/checkout_sdk/customers/customers_client.rb +37 -0
- data/lib/checkout_sdk/disputes/dispute_evidence_request.rb +60 -0
- data/lib/checkout_sdk/disputes/dispute_status.rb +19 -0
- data/lib/checkout_sdk/disputes/disputes.rb +6 -0
- data/lib/checkout_sdk/disputes/disputes_client.rb +55 -0
- data/lib/checkout_sdk/disputes/disputes_query_filter.rb +47 -0
- data/lib/checkout_sdk/environment.rb +59 -0
- data/lib/checkout_sdk/error.rb +30 -0
- data/lib/checkout_sdk/forex/forex.rb +4 -0
- data/lib/checkout_sdk/forex/forex_client.rb +21 -0
- data/lib/checkout_sdk/forex/quote_request.rb +23 -0
- data/lib/checkout_sdk/http_metadata.rb +9 -0
- data/lib/checkout_sdk/instruments/create/instrument_bank_account_request.rb +51 -0
- data/lib/checkout_sdk/instruments/create/instrument_request.rb +17 -0
- data/lib/checkout_sdk/instruments/create/instrument_token_request.rb +21 -0
- data/lib/checkout_sdk/instruments/get/bank_account_field_query.rb +14 -0
- data/lib/checkout_sdk/instruments/get/payment_network.rb +14 -0
- data/lib/checkout_sdk/instruments/instruments.rb +15 -0
- data/lib/checkout_sdk/instruments/instruments_client.rb +49 -0
- data/lib/checkout_sdk/instruments/update/update_instrument_bank_account_request.rb +51 -0
- data/lib/checkout_sdk/instruments/update/update_instrument_card_request.rb +27 -0
- data/lib/checkout_sdk/instruments/update/update_instrument_request.rb +17 -0
- data/lib/checkout_sdk/instruments/update/update_instrument_token_request.rb +15 -0
- data/lib/checkout_sdk/json_serializer.rb +54 -0
- data/lib/checkout_sdk/oauth_access_token.rb +27 -0
- data/lib/checkout_sdk/oauth_scopes.rb +41 -0
- data/lib/checkout_sdk/oauth_sdk_credentials.rb +112 -0
- data/lib/checkout_sdk/payments/airline_data.rb +17 -0
- data/lib/checkout_sdk/payments/authorization_request.rb +17 -0
- data/lib/checkout_sdk/payments/authorization_type.rb +11 -0
- data/lib/checkout_sdk/payments/billing_descriptor.rb +17 -0
- data/lib/checkout_sdk/payments/capture_request.rb +41 -0
- data/lib/checkout_sdk/payments/capture_type.rb +10 -0
- data/lib/checkout_sdk/payments/charge_bearer.rb +10 -0
- data/lib/checkout_sdk/payments/d_local_installments.rb +11 -0
- data/lib/checkout_sdk/payments/d_local_processing_settings.rb +17 -0
- data/lib/checkout_sdk/payments/destination/bank_account_destination.rb +42 -0
- data/lib/checkout_sdk/payments/destination/card_destination.rb +24 -0
- data/lib/checkout_sdk/payments/destination/destination.rb +19 -0
- data/lib/checkout_sdk/payments/destination/destination_type.rb +12 -0
- data/lib/checkout_sdk/payments/destination/id_destination.rb +18 -0
- data/lib/checkout_sdk/payments/destination/token_destination.rb +18 -0
- data/lib/checkout_sdk/payments/exemption.rb +17 -0
- data/lib/checkout_sdk/payments/flight_leg_details.rb +35 -0
- data/lib/checkout_sdk/payments/instruction_scheme.rb +11 -0
- data/lib/checkout_sdk/payments/merchant_initiated_reason.rb +12 -0
- data/lib/checkout_sdk/payments/network_token_type.rb +12 -0
- data/lib/checkout_sdk/payments/os_type.rb +10 -0
- data/lib/checkout_sdk/payments/passenger.rb +17 -0
- data/lib/checkout_sdk/payments/passenger_name.rb +11 -0
- data/lib/checkout_sdk/payments/payer.rb +17 -0
- data/lib/checkout_sdk/payments/payment_instruction.rb +32 -0
- data/lib/checkout_sdk/payments/payment_recipient.rb +20 -0
- data/lib/checkout_sdk/payments/payment_request.rb +86 -0
- data/lib/checkout_sdk/payments/payment_type.rb +13 -0
- data/lib/checkout_sdk/payments/payments.rb +82 -0
- data/lib/checkout_sdk/payments/payments_client.rb +86 -0
- data/lib/checkout_sdk/payments/payout_billing_descriptor.rb +11 -0
- data/lib/checkout_sdk/payments/payout_request.rb +38 -0
- data/lib/checkout_sdk/payments/preferred_schema.rb +11 -0
- data/lib/checkout_sdk/payments/processing_settings.rb +80 -0
- data/lib/checkout_sdk/payments/product.rb +47 -0
- data/lib/checkout_sdk/payments/product_type.rb +12 -0
- data/lib/checkout_sdk/payments/refund_request.rb +17 -0
- data/lib/checkout_sdk/payments/risk_request.rb +11 -0
- data/lib/checkout_sdk/payments/sender/corporate_sender.rb +27 -0
- data/lib/checkout_sdk/payments/sender/government_sender.rb +27 -0
- data/lib/checkout_sdk/payments/sender/individual_sender.rb +42 -0
- data/lib/checkout_sdk/payments/sender/instrument_sender.rb +11 -0
- data/lib/checkout_sdk/payments/sender/sender.rb +22 -0
- data/lib/checkout_sdk/payments/sender/sender_type.rb +12 -0
- data/lib/checkout_sdk/payments/sender/source_of_funds.rb +14 -0
- data/lib/checkout_sdk/payments/sender/ticket.rb +23 -0
- data/lib/checkout_sdk/payments/shipping_details.rb +17 -0
- data/lib/checkout_sdk/payments/shipping_preference.rb +11 -0
- data/lib/checkout_sdk/payments/source/apm/after_pay_source.rb +15 -0
- data/lib/checkout_sdk/payments/source/apm/alipay_plus_source.rb +47 -0
- data/lib/checkout_sdk/payments/source/apm/bancontact_source.rb +24 -0
- data/lib/checkout_sdk/payments/source/apm/benefit_source.rb +11 -0
- data/lib/checkout_sdk/payments/source/apm/eps_source.rb +15 -0
- data/lib/checkout_sdk/payments/source/apm/giropay_source.rb +27 -0
- data/lib/checkout_sdk/payments/source/apm/ideal_source.rb +21 -0
- data/lib/checkout_sdk/payments/source/apm/knet_source.rb +36 -0
- data/lib/checkout_sdk/payments/source/apm/mbway_source.rb +11 -0
- data/lib/checkout_sdk/payments/source/apm/multi_banco_source.rb +21 -0
- data/lib/checkout_sdk/payments/source/apm/p24_source.rb +24 -0
- data/lib/checkout_sdk/payments/source/apm/paypal_source.rb +11 -0
- data/lib/checkout_sdk/payments/source/apm/post_finance_source.rb +21 -0
- data/lib/checkout_sdk/payments/source/apm/qpay_source.rb +24 -0
- data/lib/checkout_sdk/payments/source/apm/sofort_source.rb +18 -0
- data/lib/checkout_sdk/payments/source/apm/stcpay_source.rb +11 -0
- data/lib/checkout_sdk/payments/source/apm/tamara_source.rb +15 -0
- data/lib/checkout_sdk/payments/source/apm/we_chat_pay_source.rb +15 -0
- data/lib/checkout_sdk/payments/source/bank_account_source.rb +30 -0
- data/lib/checkout_sdk/payments/source/card_source.rb +39 -0
- data/lib/checkout_sdk/payments/source/currency_account_source.rb +15 -0
- data/lib/checkout_sdk/payments/source/id_source.rb +21 -0
- data/lib/checkout_sdk/payments/source/network_token_source.rb +45 -0
- data/lib/checkout_sdk/payments/source/payment_request_source.rb +18 -0
- data/lib/checkout_sdk/payments/source/payout_request_source.rb +22 -0
- data/lib/checkout_sdk/payments/source/payout_source_type.rb +9 -0
- data/lib/checkout_sdk/payments/source/provider_token_source.rb +21 -0
- data/lib/checkout_sdk/payments/source/token_source.rb +24 -0
- data/lib/checkout_sdk/payments/terminal_type.rb +11 -0
- data/lib/checkout_sdk/payments/three_ds_flow_type.rb +11 -0
- data/lib/checkout_sdk/payments/three_ds_request.rb +56 -0
- data/lib/checkout_sdk/payments/user_action.rb +10 -0
- data/lib/checkout_sdk/payments/void_request.rb +14 -0
- data/lib/checkout_sdk/platform_type.rb +10 -0
- data/lib/checkout_sdk/previous/checkout_api.rb +29 -0
- data/lib/checkout_sdk/previous/checkout_previous_sdk_builder.rb +11 -0
- data/lib/checkout_sdk/previous/checkout_previous_static_keys_sdk_builder.rb +24 -0
- data/lib/checkout_sdk/previous/previous_static_keys_sdk_credentials.rb +38 -0
- data/lib/checkout_sdk/sdk_authorization.rb +25 -0
- data/lib/checkout_sdk/sdk_credentials.rb +12 -0
- data/lib/checkout_sdk/sessions/authentication_method.rb +14 -0
- data/lib/checkout_sdk/sessions/authentication_type.rb +10 -0
- data/lib/checkout_sdk/sessions/card_holder_account_info.rb +32 -0
- data/lib/checkout_sdk/sessions/category.rb +10 -0
- data/lib/checkout_sdk/sessions/channel/app_session.rb +36 -0
- data/lib/checkout_sdk/sessions/channel/browser_session.rb +42 -0
- data/lib/checkout_sdk/sessions/channel/channel_data.rb +19 -0
- data/lib/checkout_sdk/sessions/channel/channel_data_type.rb +10 -0
- data/lib/checkout_sdk/sessions/channel/sdk_ephemeral_public_key.rb +19 -0
- data/lib/checkout_sdk/sessions/channel/sdk_interface_type.rb +11 -0
- data/lib/checkout_sdk/sessions/channel/three_ds_method_completion.rb +11 -0
- data/lib/checkout_sdk/sessions/channel/uie_elements.rb +13 -0
- data/lib/checkout_sdk/sessions/completion/completion_info.rb +19 -0
- data/lib/checkout_sdk/sessions/completion/completion_info_type.rb +10 -0
- data/lib/checkout_sdk/sessions/completion/hosted_completion_info.rb +21 -0
- data/lib/checkout_sdk/sessions/completion/non_hosted_completion_info.rb +15 -0
- data/lib/checkout_sdk/sessions/delivery_timeframe.rb +12 -0
- data/lib/checkout_sdk/sessions/installment.rb +17 -0
- data/lib/checkout_sdk/sessions/merchant_risk_info.rb +23 -0
- data/lib/checkout_sdk/sessions/recurring.rb +14 -0
- data/lib/checkout_sdk/sessions/session_address.rb +11 -0
- data/lib/checkout_sdk/sessions/session_marketplace_data.rb +11 -0
- data/lib/checkout_sdk/sessions/session_request.rb +68 -0
- data/lib/checkout_sdk/sessions/session_secret_credentials.rb +28 -0
- data/lib/checkout_sdk/sessions/session_source_type.rb +12 -0
- data/lib/checkout_sdk/sessions/sessions.rb +47 -0
- data/lib/checkout_sdk/sessions/sessions_billing_descriptor.rb +11 -0
- data/lib/checkout_sdk/sessions/sessions_client.rb +64 -0
- data/lib/checkout_sdk/sessions/shipping_indicator.rb +9 -0
- data/lib/checkout_sdk/sessions/source/card_source.rb +30 -0
- data/lib/checkout_sdk/sessions/source/id_source.rb +15 -0
- data/lib/checkout_sdk/sessions/source/network_token_source.rb +27 -0
- data/lib/checkout_sdk/sessions/source/session_scheme.rb +14 -0
- data/lib/checkout_sdk/sessions/source/session_source.rb +37 -0
- data/lib/checkout_sdk/sessions/source/token_source.rb +18 -0
- data/lib/checkout_sdk/sessions/three_ds_method_completion_request.rb +11 -0
- data/lib/checkout_sdk/sessions/transaction_type.rb +13 -0
- data/lib/checkout_sdk/static_keys_builder.rb +35 -0
- data/lib/checkout_sdk/static_keys_sdk_credentials.rb +35 -0
- data/lib/checkout_sdk/tokens/apple_pay_token_data.rb +20 -0
- data/lib/checkout_sdk/tokens/apple_pay_token_request.rb +15 -0
- data/lib/checkout_sdk/tokens/card_token_request.rb +36 -0
- data/lib/checkout_sdk/tokens/google_pay_token_data.rb +17 -0
- data/lib/checkout_sdk/tokens/google_pay_token_request.rb +15 -0
- data/lib/checkout_sdk/tokens/token_type.rb +11 -0
- data/lib/checkout_sdk/tokens/tokens.rb +10 -0
- data/lib/checkout_sdk/tokens/tokens_client.rb +21 -0
- data/lib/checkout_sdk/tokens/wallet_token_request.rb +19 -0
- data/lib/checkout_sdk/version.rb +3 -1
- data/lib/checkout_sdk.rb +59 -21
- data/sig/checkout_sdk.rbs +4 -0
- metadata +254 -81
- data/.gitignore +0 -11
- data/.travis.yml +0 -7
- data/Gemfile.lock +0 -45
- data/LICENSE +0 -21
- data/bin/console +0 -14
- data/bin/setup +0 -8
- data/checkout_sdk.gemspec +0 -24
- data/documentation/.gitignore +0 -20
- data/documentation/docs/environment.md +0 -26
- data/documentation/docs/getting_started.md +0 -48
- data/documentation/docs/initialize.md +0 -19
- data/documentation/docs/install.md +0 -21
- data/documentation/docs/payments.md +0 -200
- data/documentation/docs/sources.md +0 -53
- data/documentation/docs/tokens.md +0 -88
- data/documentation/docusaurus.config.js +0 -60
- data/documentation/package-lock.json +0 -13511
- data/documentation/package.json +0 -32
- data/documentation/sidebars.js +0 -10
- data/documentation/src/css/custom.css +0 -103
- data/documentation/src/pages/index.js +0 -10
- data/documentation/src/pages/styles.module.css +0 -37
- data/documentation/static/img/favicon.png +0 -0
- data/documentation/static/img/logo.png +0 -0
- data/documentation/static/img/undraw_docusaurus_mountain.svg +0 -170
- data/documentation/static/img/undraw_docusaurus_react.svg +0 -169
- data/documentation/static/img/undraw_docusaurus_tree.svg +0 -1
- data/documentation/yarn.lock +0 -9369
- data/lib/checkout_sdk/api_resource.rb +0 -77
- data/lib/checkout_sdk/configuration.rb +0 -10
- data/lib/checkout_sdk/data/capture_payment.rb +0 -11
- data/lib/checkout_sdk/data/payment_request_source.rb +0 -145
- data/lib/checkout_sdk/data/payment_source.rb +0 -40
- data/lib/checkout_sdk/data/refund_payment.rb +0 -11
- data/lib/checkout_sdk/data/request_token.rb +0 -67
- data/lib/checkout_sdk/data/void_payment.rb +0 -10
- data/spec/checkout_sdk/api_resource_spec.rb +0 -126
- data/spec/checkout_sdk/data/payment_request_source_spec.rb +0 -126
- data/spec/checkout_sdk/data/request_token_spec.rb +0 -107
- data/spec/checkout_sdk_spec.rb +0 -21
- data/spec/spec_helper.rb +0 -32
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CheckoutSdk
|
4
|
+
class JsonSerializer
|
5
|
+
KEYS_TRANSFORMATIONS = { three_ds: '3ds',
|
6
|
+
account_holder_type: 'account-holder-type',
|
7
|
+
payment_network: 'payment-network',
|
8
|
+
from_: 'from' }.freeze
|
9
|
+
|
10
|
+
def self.to_custom_hash(object)
|
11
|
+
hash = {}
|
12
|
+
object.instance_variables.each do |v|
|
13
|
+
value = object.instance_variable_get(v)
|
14
|
+
value = serialize_by_type(value)
|
15
|
+
hash[keys_transformation(v)] = value
|
16
|
+
end
|
17
|
+
hash
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.keys_transformation(key_name)
|
21
|
+
key = key_name.to_s.delete('@')
|
22
|
+
return KEYS_TRANSFORMATIONS[key.to_sym] if KEYS_TRANSFORMATIONS.key?(key.to_sym)
|
23
|
+
|
24
|
+
key
|
25
|
+
end
|
26
|
+
|
27
|
+
# @param [Array] input_array
|
28
|
+
def self.serialize_array(input_array)
|
29
|
+
aux_array = []
|
30
|
+
input_array.map do |value|
|
31
|
+
value = serialize_by_type(value)
|
32
|
+
aux_array.append(value)
|
33
|
+
end
|
34
|
+
aux_array
|
35
|
+
end
|
36
|
+
|
37
|
+
# @param [Hash] input_hash
|
38
|
+
def self.serialize_hash(input_hash)
|
39
|
+
aux_hash = {}
|
40
|
+
input_hash.map do |key, value|
|
41
|
+
value = serialize_by_type(value)
|
42
|
+
aux_hash[key] = value
|
43
|
+
end
|
44
|
+
aux_hash
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.serialize_by_type(value)
|
48
|
+
value = serialize_array(value) if value.is_a?(Array)
|
49
|
+
value = serialize_hash(value) if value.is_a?(Hash)
|
50
|
+
value = to_custom_hash(value) if value.class.name.start_with? CheckoutSdk.name
|
51
|
+
value
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CheckoutSdk
|
4
|
+
# @!attribute token
|
5
|
+
# @return [String]
|
6
|
+
# @!attribute expiration_date
|
7
|
+
# @return [Time]
|
8
|
+
class OAuthAccessToken
|
9
|
+
attr_accessor :token,
|
10
|
+
:expiration_date
|
11
|
+
|
12
|
+
# @param [String] token
|
13
|
+
# @param [Time] expiration_date
|
14
|
+
# @return [OAuthAccessToken]
|
15
|
+
def initialize(token, expiration_date)
|
16
|
+
@token = token
|
17
|
+
@expiration_date = expiration_date
|
18
|
+
end
|
19
|
+
|
20
|
+
# @return [TrueClass, FalseClass]
|
21
|
+
def valid?
|
22
|
+
return false if @token.nil?
|
23
|
+
|
24
|
+
@expiration_date > Time.now
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CheckoutSdk
|
4
|
+
module OAuthScopes
|
5
|
+
VAULT = 'vault'
|
6
|
+
VAULT_INSTRUMENTS = 'vault:instruments'
|
7
|
+
VAULT_TOKENIZATION = 'vault:tokenization'
|
8
|
+
GATEWAY = 'gateway'
|
9
|
+
GATEWAY_PAYMENT = 'gateway:payment'
|
10
|
+
GATEWAY_PAYMENT_DETAILS = 'gateway:payment-details'
|
11
|
+
GATEWAY_PAYMENT_AUTHORIZATION = 'gateway:payment-authorizations'
|
12
|
+
GATEWAY_PAYMENT_VOIDS = 'gateway:payment-voids'
|
13
|
+
GATEWAY_PAYMENT_CAPTURES = 'gateway:payment-captures'
|
14
|
+
GATEWAY_PAYMENT_REFUNDS = 'gateway:payment-refunds'
|
15
|
+
FX = 'fx'
|
16
|
+
PAYOUTS_BANK_DETAILS = 'payouts:bank-details'
|
17
|
+
SESSIONS_APP = 'sessions:app'
|
18
|
+
SESSIONS_BROWSER = 'sessions:browser'
|
19
|
+
DISPUTES = 'disputes'
|
20
|
+
DISPUTES_VIEW = 'disputes:view'
|
21
|
+
DISPUTES_PROVIDE_EVIDENCE = 'disputes:provide-evidence'
|
22
|
+
DISPUTES_ACCEPT = 'disputes:accept'
|
23
|
+
MARKETPLACE = 'marketplace'
|
24
|
+
ACCOUNTS = 'accounts'
|
25
|
+
FLOW = 'flow'
|
26
|
+
FLOW_WORKFLOWS = 'flow:workflows'
|
27
|
+
FLOW_EVENTS = 'flow:events'
|
28
|
+
FILES = 'files'
|
29
|
+
FILES_RETRIEVE = 'files:retrieve'
|
30
|
+
FILES_UPLOAD = 'files:upload'
|
31
|
+
FILES_DOWNLOAD = 'files:download'
|
32
|
+
TRANSFERS = 'transfers'
|
33
|
+
TRANSFERS_CREATE = 'transfers:create'
|
34
|
+
TRANSFERS_VIEW = 'transfers:view'
|
35
|
+
BALANCES = 'balances'
|
36
|
+
BALANCES_VIEW = 'balances:view'
|
37
|
+
MIDDLEWARE = 'middleware'
|
38
|
+
MIDDLEWARE_MERCHANTS_SECRET = 'middleware:merchants-secret'
|
39
|
+
MIDDLEWARE_MERCHANTS_PUBLIC = 'middleware:merchants-public'
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,112 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CheckoutSdk
|
4
|
+
# @!attribute access_token
|
5
|
+
# @return [CheckoutSdk::OAuthAccessToken]
|
6
|
+
# @!attribute client_id
|
7
|
+
# @return [String]
|
8
|
+
# @!attribute client_secret
|
9
|
+
# @return [String]
|
10
|
+
# @!attribute scopes
|
11
|
+
# @return [Array(CheckoutSdk::OAuthScopes)]
|
12
|
+
# @!attribute http_client
|
13
|
+
# @return [Object]
|
14
|
+
# @!attribute environment
|
15
|
+
# @return [CheckoutSdk::Environment]
|
16
|
+
# @!attribute authorization_uri
|
17
|
+
# @return [String]
|
18
|
+
class OAuthSdkCredentials < SdkCredentials
|
19
|
+
attr_accessor :access_token,
|
20
|
+
:client_id,
|
21
|
+
:client_secret,
|
22
|
+
:scopes,
|
23
|
+
:http_client,
|
24
|
+
:environment,
|
25
|
+
:authorization_uri
|
26
|
+
|
27
|
+
# @param [String] client_id
|
28
|
+
# @param [String] client_secret
|
29
|
+
# @param [Array(CheckoutSdk::OAuthScopes)] scopes
|
30
|
+
# @param [Faraday] http_client
|
31
|
+
# @param [CheckoutSdk::Environment] environment
|
32
|
+
# @param [String, nil] auth_uri
|
33
|
+
def initialize(client_id, client_secret, scopes, http_client, environment, auth_uri = nil)
|
34
|
+
validate_arguments client_id, client_secret, environment, auth_uri
|
35
|
+
@client_id = client_id
|
36
|
+
@client_secret = client_secret
|
37
|
+
@scopes = scopes
|
38
|
+
@authorization_uri = auth_uri.nil? ? environment.authorization_uri : auth_uri
|
39
|
+
@http_client = http_client.nil? ? build_default_client(authorization_uri) : http_client
|
40
|
+
build_access_token
|
41
|
+
end
|
42
|
+
|
43
|
+
# @param [String] authorization_type
|
44
|
+
# @return [CheckoutSdk::SdkAuthorization]
|
45
|
+
def get_authorization(authorization_type)
|
46
|
+
case authorization_type
|
47
|
+
when AuthorizationType::SECRET_KEY_OR_OAUTH, AuthorizationType::PUBLIC_KEY_OR_OAUTH, AuthorizationType::OAUTH
|
48
|
+
SdkAuthorization.new(PlatformType::DEFAULT, build_access_token.token)
|
49
|
+
else
|
50
|
+
raise CheckoutAuthorizationException.invalid_authorization authorization_type
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
# @return [CheckoutSdk::OAuthAccessToken]
|
55
|
+
def build_access_token
|
56
|
+
return @access_token unless @access_token.nil? || @access_token.token.nil? || !@access_token.valid?
|
57
|
+
|
58
|
+
data = {
|
59
|
+
client_id: @client_id,
|
60
|
+
client_secret: @client_secret,
|
61
|
+
grant_type: 'client_credentials',
|
62
|
+
scope: @scopes.join(' ')
|
63
|
+
}
|
64
|
+
|
65
|
+
headers = { 'Content-Type': 'application/x-www-form-urlencoded' }
|
66
|
+
body = URI.encode_www_form data
|
67
|
+
|
68
|
+
begin
|
69
|
+
response = @http_client.run_request(:post, @authorization_uri, body, headers)
|
70
|
+
rescue Faraday::ClientError => e
|
71
|
+
raise CheckoutAuthorizationException, e.response
|
72
|
+
rescue Faraday::ConnectionFailed => e
|
73
|
+
raise CheckoutArgumentException, e.wrapped_exception
|
74
|
+
end
|
75
|
+
|
76
|
+
if !response.body.nil? && response.body != ''
|
77
|
+
oauth_response = JSON.parse(response.body, object_class: OpenStruct)
|
78
|
+
|
79
|
+
@access_token = OAuthAccessToken.new(oauth_response.access_token,
|
80
|
+
Time.now + oauth_response.expires_in)
|
81
|
+
end
|
82
|
+
|
83
|
+
@access_token
|
84
|
+
end
|
85
|
+
|
86
|
+
private
|
87
|
+
|
88
|
+
# TODO: refactor this into a utils method
|
89
|
+
# @param [String] authorization_uri
|
90
|
+
# @return [Faraday::Connection]
|
91
|
+
def build_default_client(authorization_uri)
|
92
|
+
Faraday.new(authorization_uri) do |f|
|
93
|
+
f.response(:raise_error)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
# @param [String] client_id
|
98
|
+
# @param [String] client_secret
|
99
|
+
# @param [Environment] environment
|
100
|
+
# @param [String] authorization_uri
|
101
|
+
def validate_arguments(client_id, client_secret, environment, authorization_uri)
|
102
|
+
if client_id.nil? || client_secret.nil?
|
103
|
+
raise CheckoutArgumentException, 'Invalid OAuth "client_id" or "client_secret"'
|
104
|
+
end
|
105
|
+
|
106
|
+
return unless environment.nil? && authorization_uri.nil?
|
107
|
+
|
108
|
+
raise CheckoutArgumentException,
|
109
|
+
'Invalid configuration. Please specify an "environment" or a specific OAuth "authorization_uri"'
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CheckoutSdk
|
4
|
+
module Payments
|
5
|
+
# @!attribute ticket
|
6
|
+
# @return [Ticket]
|
7
|
+
# @!attribute passenger
|
8
|
+
# @return [Passenger]
|
9
|
+
# @!attribute flight_leg_details
|
10
|
+
# @return [Array(FlightLegDetails)]
|
11
|
+
class AirlineData
|
12
|
+
attr_accessor :ticket,
|
13
|
+
:passenger,
|
14
|
+
:flight_leg_details
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CheckoutSdk
|
4
|
+
module Payments
|
5
|
+
# @!attribute amount
|
6
|
+
# @return [Integer]
|
7
|
+
# @!attribute reference
|
8
|
+
# @return [String]
|
9
|
+
# @!attribute metadata
|
10
|
+
# @return [Hash{String => Object}]
|
11
|
+
class AuthorizationRequest
|
12
|
+
attr_accessor :amount,
|
13
|
+
:reference,
|
14
|
+
:metadata
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CheckoutSdk
|
4
|
+
module Payments
|
5
|
+
# @!attribute name
|
6
|
+
# @return [String]
|
7
|
+
# @!attribute city
|
8
|
+
# @return [String]
|
9
|
+
# @!attribute reference
|
10
|
+
# @return [String]
|
11
|
+
class BillingDescriptor
|
12
|
+
attr_accessor :name,
|
13
|
+
:city,
|
14
|
+
:reference
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CheckoutSdk
|
4
|
+
module Payments
|
5
|
+
# @!attribute amount
|
6
|
+
# @return [Integer]
|
7
|
+
# @!attribute capture_type
|
8
|
+
# @return [String] {CaptureType}
|
9
|
+
# @!attribute reference
|
10
|
+
# @return [String]
|
11
|
+
# @!attribute customer
|
12
|
+
# @return [CheckoutSdk::Common::CustomerRequest]
|
13
|
+
# @!attribute description
|
14
|
+
# @return [String]
|
15
|
+
# @!attribute billing_descriptor
|
16
|
+
# @return [BillingDescriptor]
|
17
|
+
# @!attribute shipping
|
18
|
+
# @return [ShippingDetails]
|
19
|
+
# @!attribute items
|
20
|
+
# @return [Array(Product)]
|
21
|
+
# @!attribute amount_allocations
|
22
|
+
# @return [Array(CheckoutSdk::Common::AmountAllocations)]
|
23
|
+
# @!attribute processing
|
24
|
+
# @return [ProcessingSettings]
|
25
|
+
# @!attribute metadata
|
26
|
+
# @return [Hash{String => Object}]
|
27
|
+
class CaptureRequest
|
28
|
+
attr_accessor :amount,
|
29
|
+
:capture_type,
|
30
|
+
:reference,
|
31
|
+
:customer,
|
32
|
+
:description,
|
33
|
+
:billing_descriptor,
|
34
|
+
:shipping,
|
35
|
+
:items,
|
36
|
+
:amount_allocations,
|
37
|
+
:processing,
|
38
|
+
:metadata
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CheckoutSdk
|
4
|
+
module Payments
|
5
|
+
# @!attribute country
|
6
|
+
# @return [String] {CheckoutSdk::Common::Country}
|
7
|
+
# @!attribute payer
|
8
|
+
# @return [Payer]
|
9
|
+
# @!attribute installments
|
10
|
+
# @return [DLocalInstallments]
|
11
|
+
class DLocalProcessingSettings
|
12
|
+
attr_accessor :country,
|
13
|
+
:payer,
|
14
|
+
:installments
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CheckoutSdk
|
4
|
+
module Payments
|
5
|
+
# @!attribute account_type
|
6
|
+
# @return [String] {CheckoutSdk::Common::AccountType}
|
7
|
+
# @!attribute account_number
|
8
|
+
# @return [String]
|
9
|
+
# @!attribute bank_code
|
10
|
+
# @return [String]
|
11
|
+
# @!attribute branch_code
|
12
|
+
# @return [String]
|
13
|
+
# @!attribute iban
|
14
|
+
# @return [String]
|
15
|
+
# @!attribute bban
|
16
|
+
# @return [String]
|
17
|
+
# @!attribute swift_bic
|
18
|
+
# @return [String]
|
19
|
+
# @!attribute country
|
20
|
+
# @return [String] {CheckoutSdk::Common::Country}
|
21
|
+
# @!attribute account_holder
|
22
|
+
# @return [CheckoutSdk::Common::AccountHolder]
|
23
|
+
# @!attribute bank
|
24
|
+
# @return [CheckoutSdk::Common::BankDetails]
|
25
|
+
class BankAccountDestination < Destination
|
26
|
+
attr_accessor :account_type,
|
27
|
+
:account_number,
|
28
|
+
:bank_code,
|
29
|
+
:branch_code,
|
30
|
+
:iban,
|
31
|
+
:bban,
|
32
|
+
:swift_bic,
|
33
|
+
:country,
|
34
|
+
:account_holder,
|
35
|
+
:bank
|
36
|
+
|
37
|
+
def initialize
|
38
|
+
super CheckoutSdk::Payments::DestinationType::BANK_ACCOUNT
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CheckoutSdk
|
4
|
+
module Payments
|
5
|
+
# @!attribute number
|
6
|
+
# @return [String]
|
7
|
+
# @!attribute expiry_month
|
8
|
+
# @return [Integer]
|
9
|
+
# @!attribute expiry_year
|
10
|
+
# @return [Integer]
|
11
|
+
# @!attribute account_holder
|
12
|
+
# @return [CheckoutSdk::Common::AccountHolder]
|
13
|
+
class CardDestination < Destination
|
14
|
+
attr_accessor :number,
|
15
|
+
:expiry_month,
|
16
|
+
:expiry_year,
|
17
|
+
:account_holder
|
18
|
+
|
19
|
+
def initialize
|
20
|
+
super CheckoutSdk::Payments::DestinationType::CARD
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CheckoutSdk
|
4
|
+
module Payments
|
5
|
+
# @!attribute type
|
6
|
+
# @return [String] {DestinationType}
|
7
|
+
class Destination
|
8
|
+
attr_accessor :type
|
9
|
+
|
10
|
+
protected
|
11
|
+
|
12
|
+
# @abstract
|
13
|
+
# @param [String] type {DestinationType}
|
14
|
+
def initialize(type)
|
15
|
+
@type = type
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CheckoutSdk
|
4
|
+
module Payments
|
5
|
+
# @!attribute id
|
6
|
+
# @return [String]
|
7
|
+
# @!attribute account_holder
|
8
|
+
# @return [CheckoutSdk::Common::AccountHolder]
|
9
|
+
class IdDestination < Destination
|
10
|
+
attr_accessor :id,
|
11
|
+
:account_holder
|
12
|
+
|
13
|
+
def initialize
|
14
|
+
super CheckoutSdk::Payments::DestinationType::ID
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CheckoutSdk
|
4
|
+
module Payments
|
5
|
+
# @!attribute token
|
6
|
+
# @return [String]
|
7
|
+
# @!attribute account_holder
|
8
|
+
# @return [CheckoutSdk::Common::AccountHolder]
|
9
|
+
class TokenDestination < Destination
|
10
|
+
attr_accessor :token,
|
11
|
+
:account_holder
|
12
|
+
|
13
|
+
def initialize
|
14
|
+
super CheckoutSdk::Payments::DestinationType::TOKEN
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CheckoutSdk
|
4
|
+
module Payments
|
5
|
+
module Exemption
|
6
|
+
LOW_VALUE = 'low_value'
|
7
|
+
SECURE_CORPORATE_PAYMENT = 'secure_corporate_payment'
|
8
|
+
TRUSTED_LISTING = 'trusted_listing'
|
9
|
+
TRANSACTION_RISK_ASSESSMENT = 'transaction_risk_assessment'
|
10
|
+
THREE_DS_OUTAGE = '3ds_outage'
|
11
|
+
SCA_DELEGATION = 'sca_delegation'
|
12
|
+
OUT_OF_SCA_SCOPE = 'out_of_sca_scope'
|
13
|
+
OTHER = 'other'
|
14
|
+
LOW_RISK_PROGRAM = 'low_risk_program'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CheckoutSdk
|
4
|
+
module Payments
|
5
|
+
# @!attribute flight_number
|
6
|
+
# @return [Integer]
|
7
|
+
# @!attribute carrier_code
|
8
|
+
# @return [String]
|
9
|
+
# @!attribute service_class
|
10
|
+
# @return [String]
|
11
|
+
# @!attribute departure_date
|
12
|
+
# @return [String]
|
13
|
+
# @!attribute departure_time
|
14
|
+
# @return [String]
|
15
|
+
# @!attribute departure_airport
|
16
|
+
# @return [String]
|
17
|
+
# @!attribute arrival_airport
|
18
|
+
# @return [String]
|
19
|
+
# @!attribute stopover_code
|
20
|
+
# @return [String]
|
21
|
+
# @!attribute fare_basis_code
|
22
|
+
# @return [String]
|
23
|
+
class FlightLegDetails
|
24
|
+
attr_accessor :flight_number,
|
25
|
+
:carrier_code,
|
26
|
+
:service_class,
|
27
|
+
:departure_date,
|
28
|
+
:departure_time,
|
29
|
+
:departure_airport,
|
30
|
+
:arrival_airport,
|
31
|
+
:stopover_code,
|
32
|
+
:fare_basis_code
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CheckoutSdk
|
4
|
+
module Payments
|
5
|
+
# @!attribute name
|
6
|
+
# @return [String]
|
7
|
+
# @!attribute date_of_birth
|
8
|
+
# @return [String]
|
9
|
+
# @!attribute country_code
|
10
|
+
# @return [String] {CheckoutSdk::Common::Country}
|
11
|
+
class Passenger
|
12
|
+
attr_accessor :name,
|
13
|
+
:date_of_birth,
|
14
|
+
:country_code
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|