checkout_sdk 1.0.0.beta.2 → 1.0.0.beta.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +5 -2
  3. data/README.md +34 -0
  4. data/lib/checkout_sdk/abstract_checkout_sdk_builder.rb +6 -1
  5. data/lib/checkout_sdk/api_client.rb +24 -4
  6. data/lib/checkout_sdk/balances/balances.rb +3 -0
  7. data/lib/checkout_sdk/balances/balances_client.rb +22 -0
  8. data/lib/checkout_sdk/checkout_api.rb +25 -1
  9. data/lib/checkout_sdk/checkout_configuration.rb +3 -2
  10. data/lib/checkout_sdk/checkout_oauth_sdk_builder.rb +9 -2
  11. data/lib/checkout_sdk/checkout_static_keys_sdk_builder.rb +2 -1
  12. data/lib/checkout_sdk/checkout_utils.rb +1 -0
  13. data/lib/checkout_sdk/common/common.rb +1 -0
  14. data/lib/checkout_sdk/common/country.rb +1 -0
  15. data/lib/checkout_sdk/common/date_range_query_filter.rb +14 -0
  16. data/lib/checkout_sdk/disputes/disputes_query_filter.rb +1 -7
  17. data/lib/checkout_sdk/events/events.rb +4 -0
  18. data/lib/checkout_sdk/events/events_client.rb +56 -0
  19. data/lib/checkout_sdk/events/events_query_filter.rb +28 -0
  20. data/lib/checkout_sdk/oauth_sdk_credentials.rb +5 -2
  21. data/lib/checkout_sdk/previous/checkout_api.rb +18 -2
  22. data/lib/checkout_sdk/previous/checkout_previous_static_keys_sdk_builder.rb +2 -1
  23. data/lib/checkout_sdk/reconciliation/reconciliation.rb +4 -0
  24. data/lib/checkout_sdk/reconciliation/reconciliation_client.rb +51 -0
  25. data/lib/checkout_sdk/reconciliation/reconciliation_query_payments_filter.rb +16 -0
  26. data/lib/checkout_sdk/reports/reports_client.rb +6 -0
  27. data/lib/checkout_sdk/risk/authentication_result.rb +26 -0
  28. data/lib/checkout_sdk/risk/authorization_result.rb +14 -0
  29. data/lib/checkout_sdk/risk/device.rb +32 -0
  30. data/lib/checkout_sdk/risk/location.rb +14 -0
  31. data/lib/checkout_sdk/risk/pre_authentication_assessment.rb +41 -0
  32. data/lib/checkout_sdk/risk/pre_capture_assessment.rb +44 -0
  33. data/lib/checkout_sdk/risk/risk.rb +17 -0
  34. data/lib/checkout_sdk/risk/risk_client.rb +27 -0
  35. data/lib/checkout_sdk/risk/risk_payment.rb +14 -0
  36. data/lib/checkout_sdk/risk/risk_shipping_details.rb +11 -0
  37. data/lib/checkout_sdk/risk/source/card_source.rb +30 -0
  38. data/lib/checkout_sdk/risk/source/customer_source.rb +15 -0
  39. data/lib/checkout_sdk/risk/source/id_source.rb +18 -0
  40. data/lib/checkout_sdk/risk/source/risk_payment_source.rb +19 -0
  41. data/lib/checkout_sdk/risk/source/token_source.rb +24 -0
  42. data/lib/checkout_sdk/simple_logger.rb +12 -0
  43. data/lib/checkout_sdk/transfers/create_transfer.rb +20 -0
  44. data/lib/checkout_sdk/transfers/transfer_destination.rb +11 -0
  45. data/lib/checkout_sdk/transfers/transfer_source.rb +14 -0
  46. data/lib/checkout_sdk/transfers/transfer_type.rb +11 -0
  47. data/lib/checkout_sdk/transfers/transfers.rb +8 -0
  48. data/lib/checkout_sdk/transfers/transfers_client.rb +27 -0
  49. data/lib/checkout_sdk/version.rb +1 -1
  50. data/lib/checkout_sdk/webhooks/webhook_request.rb +25 -0
  51. data/lib/checkout_sdk/webhooks/webhooks.rb +4 -0
  52. data/lib/checkout_sdk/webhooks/webhooks_client.rb +50 -0
  53. data/lib/checkout_sdk.rb +9 -0
  54. metadata +56 -14
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CheckoutSdk
4
+ module Risk
5
+ # @!attribute attempted
6
+ # @return [TrueClass, FalseClass]
7
+ # @!attribute challenged
8
+ # @return [TrueClass, FalseClass]
9
+ # @!attribute succeeded
10
+ # @return [TrueClass, FalseClass]
11
+ # @!attribute liability_shifted
12
+ # @return [TrueClass, FalseClass]
13
+ # @!attribute method
14
+ # @return [String]
15
+ # @!attribute version
16
+ # @return [String]
17
+ class AuthenticationResult
18
+ attr_accessor :attempted,
19
+ :challenged,
20
+ :succeeded,
21
+ :liability_shifted,
22
+ :method,
23
+ :version
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CheckoutSdk
4
+ module Risk
5
+ # @!attribute avs_code
6
+ # @return [String]
7
+ # @!attribute cvv_result
8
+ # @return [String]
9
+ class AuthorizationResult
10
+ attr_accessor :avs_code,
11
+ :cvv_result
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CheckoutSdk
4
+ module Risk
5
+ # @!attribute ip
6
+ # @return [String]
7
+ # @!attribute location
8
+ # @return [Location]
9
+ # @!attribute os
10
+ # @return [String]
11
+ # @!attribute type
12
+ # @return [String]
13
+ # @!attribute model
14
+ # @return [String]
15
+ # @!attribute date
16
+ # @return [DateTime]
17
+ # @!attribute user_agent
18
+ # @return [String]
19
+ # @!attribute fingerprint
20
+ # @return [String]
21
+ class Device
22
+ attr_accessor :ip,
23
+ :location,
24
+ :os,
25
+ :type,
26
+ :model,
27
+ :date,
28
+ :user_agent,
29
+ :fingerprint
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CheckoutSdk
4
+ module Risk
5
+ # @!attribute latitude
6
+ # @return [Integer]
7
+ # @!attribute longitude
8
+ # @return [Integer]
9
+ class Location
10
+ attr_accessor :latitude,
11
+ :longitude
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CheckoutSdk
4
+ module Risk
5
+ # @!attribute date
6
+ # @return [DateTime]
7
+ # @!attribute source
8
+ # @return [RiskPaymentSource]
9
+ # @!attribute customer
10
+ # @return [CheckoutSdk::Common::CustomerRequest]
11
+ # @!attribute payment
12
+ # @return [RiskPayment]
13
+ # @!attribute shipping
14
+ # @return [RiskShippingDetails]
15
+ # @!attribute reference
16
+ # @return [String]
17
+ # @!attribute description
18
+ # @return [String]
19
+ # @!attribute amount
20
+ # @return [Integer]
21
+ # @!attribute currency
22
+ # @return [String] {CheckoutSdk::Common::Currency}
23
+ # @!attribute device
24
+ # @return [Device]
25
+ # @!attribute metadata
26
+ # @return [Hash{String => Object}]
27
+ class PreAuthenticationAssessment
28
+ attr_accessor :date,
29
+ :source,
30
+ :customer,
31
+ :payment,
32
+ :shipping,
33
+ :reference,
34
+ :description,
35
+ :amount,
36
+ :currency,
37
+ :device,
38
+ :metadata
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CheckoutSdk
4
+ module Risk
5
+ # @!attribute assessment_id
6
+ # @return [String]
7
+ # @!attribute date
8
+ # @return [DateTime]
9
+ # @!attribute source
10
+ # @return [RiskPaymentSource]
11
+ # @!attribute customer
12
+ # @return [CheckoutSdk::Common::CustomerRequest]
13
+ # @!attribute amount
14
+ # @return [Integer]
15
+ # @!attribute currency
16
+ # @return [String] {CheckoutSdk::Common::Currency}
17
+ # @!attribute payment
18
+ # @return [RiskPayment]
19
+ # @!attribute shipping
20
+ # @return [RiskShippingDetails]
21
+ # @!attribute device
22
+ # @return [Device]
23
+ # @!attribute metadata
24
+ # @return [Hash{String => Object}]
25
+ # @!attribute authentication_result
26
+ # @return [AuthenticationResult]
27
+ # @!attribute authorization_result
28
+ # @return [AuthorizationResult]
29
+ class PreCaptureAssessment
30
+ attr_accessor :assessment_id,
31
+ :date,
32
+ :source,
33
+ :customer,
34
+ :amount,
35
+ :currency,
36
+ :payment,
37
+ :shipping,
38
+ :device,
39
+ :metadata,
40
+ :authentication_result,
41
+ :authorization_result
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'checkout_sdk/risk/authentication_result'
4
+ require 'checkout_sdk/risk/risk_payment'
5
+ require 'checkout_sdk/risk/authorization_result'
6
+ require 'checkout_sdk/risk/pre_capture_assessment'
7
+ require 'checkout_sdk/risk/risk_client'
8
+ require 'checkout_sdk/risk/source/risk_payment_source'
9
+ require 'checkout_sdk/risk/source/customer_source'
10
+ require 'checkout_sdk/risk/source/token_source'
11
+ require 'checkout_sdk/risk/source/id_source'
12
+ require 'checkout_sdk/risk/source/card_source'
13
+ require 'checkout_sdk/risk/risk'
14
+ require 'checkout_sdk/risk/location'
15
+ require 'checkout_sdk/risk/risk_shipping_details'
16
+ require 'checkout_sdk/risk/device'
17
+ require 'checkout_sdk/risk/pre_authentication_assessment'
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CheckoutSdk
4
+ module Risk
5
+ class RiskClient < Client
6
+ PRE_AUTHENTICATION = 'risk/assessments/pre-authentication'
7
+ PRE_CAPTURE = 'risk/assessments/pre-capture'
8
+ private_constant :PRE_AUTHENTICATION, :PRE_CAPTURE
9
+
10
+ # @param [ApiClient] api_client
11
+ # @param [CheckoutConfiguration] configuration
12
+ def initialize(api_client, configuration)
13
+ super(api_client, configuration, CheckoutSdk::AuthorizationType::SECRET_KEY)
14
+ end
15
+
16
+ # @param [PreAuthenticationAssessment] pre_authentication_request
17
+ def pre_authentication_scan(pre_authentication_request)
18
+ api_client.invoke_post(PRE_AUTHENTICATION, sdk_authorization, pre_authentication_request)
19
+ end
20
+
21
+ # @param [PreCaptureAssessment] pre_capture_request
22
+ def pre_capture_scan(pre_capture_request)
23
+ api_client.invoke_post(PRE_CAPTURE, sdk_authorization, pre_capture_request)
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CheckoutSdk
4
+ module Risk
5
+ # @!attribute psp
6
+ # @return [String]
7
+ # @!attribute id
8
+ # @return [String]
9
+ class RiskPayment
10
+ attr_accessor :psp,
11
+ :id
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CheckoutSdk
4
+ module Risk
5
+ # @!attribute address
6
+ # @return [CheckoutSdk::Common::Address]
7
+ class RiskShippingDetails
8
+ attr_accessor :address
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CheckoutSdk
4
+ module Risk
5
+ # @!attribute number
6
+ # @return [String]
7
+ # @!attribute expiry_month
8
+ # @return [Integer]
9
+ # @!attribute expiry_year
10
+ # @return [Integer]
11
+ # @!attribute name
12
+ # @return [String]
13
+ # @!attribute billing_address
14
+ # @return [CheckoutSdk::Common::Address]
15
+ # @!attribute phone
16
+ # @return [CheckoutSdk::Common::Phone]
17
+ class CardSource < RiskPaymentSource
18
+ attr_accessor :number,
19
+ :expiry_month,
20
+ :expiry_year,
21
+ :name,
22
+ :billing_address,
23
+ :phone
24
+
25
+ def initialize
26
+ super CheckoutSdk::Common::PaymentSourceType::CARD
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CheckoutSdk
4
+ module Risk
5
+ # @!attribute id
6
+ # @return [String]
7
+ class CustomerSource < RiskPaymentSource
8
+ attr_accessor :id
9
+
10
+ def initialize
11
+ super CheckoutSdk::Common::PaymentSourceType::CUSTOMER
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CheckoutSdk
4
+ module Risk
5
+ # @!attribute id
6
+ # @return [String]
7
+ # @!attribute cvv
8
+ # @return [String]
9
+ class IdSource < RiskPaymentSource
10
+ attr_accessor :id,
11
+ :cvv
12
+
13
+ def initialize
14
+ super CheckoutSdk::Common::PaymentSourceType::ID
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CheckoutSdk
4
+ module Risk
5
+ # @!attribute type
6
+ # @return [String] {CheckoutSdk::Common::PaymentSourceType}
7
+ class RiskPaymentSource
8
+ attr_reader :type
9
+
10
+ protected
11
+
12
+ # @abstract
13
+ # @param [String] {CheckoutSdk::Common::PaymentSourceType}
14
+ def initialize(type)
15
+ @type = type
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CheckoutSdk
4
+ module Risk
5
+ # @!attribute token
6
+ # @return [String]
7
+ # @!attribute billing_address
8
+ # @return [CheckoutSdk::Common::Address]
9
+ # @!attribute phone
10
+ # @return [CheckoutSdk::Common::Phone]
11
+ # @!attribute store_for_future_use
12
+ # @return [TrueClass, FalseClass]
13
+ class TokenSource < RiskPaymentSource
14
+ attr_accessor :token,
15
+ :billing_address,
16
+ :phone,
17
+ :store_for_future_use
18
+
19
+ def initialize
20
+ super CheckoutSdk::Common::PaymentSourceType::TOKEN
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CheckoutSdk
4
+ class SimpleLogger
5
+ attr_reader :logger
6
+
7
+ def initialize(min_level = Logger::INFO)
8
+ @logger = Logger.new($stdout)
9
+ @logger.level = min_level
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CheckoutSdk
4
+ module Transfers
5
+ # @!attribute reference
6
+ # @return [String]
7
+ # @!attribute transfer_type
8
+ # @return [String] {TransferType}
9
+ # @!attribute source
10
+ # @return [TransferSource]
11
+ # @!attribute destination
12
+ # @return [TransferDestination]
13
+ class CreateTransfer
14
+ attr_accessor :reference,
15
+ :transfer_type,
16
+ :source,
17
+ :destination
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CheckoutSdk
4
+ module Transfers
5
+ # @!attribute id
6
+ # @return [String]
7
+ class TransferDestination
8
+ attr_accessor :id
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CheckoutSdk
4
+ module Transfers
5
+ # @!attribute id
6
+ # @return [String]
7
+ # @!attribute amount
8
+ # @return [Integer]
9
+ class TransferSource
10
+ attr_accessor :id,
11
+ :amount
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CheckoutSdk
4
+ module Transfers
5
+ module TransferType
6
+ COMMISSION = 'commission'
7
+ PROMOTION = 'promotion'
8
+ REFUND = 'refund'
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'checkout_sdk/transfers/create_transfer'
4
+ require 'checkout_sdk/transfers/transfers_client'
5
+ require 'checkout_sdk/transfers/transfer_type'
6
+ require 'checkout_sdk/transfers/transfers'
7
+ require 'checkout_sdk/transfers/transfer_source'
8
+ require 'checkout_sdk/transfers/transfer_destination'
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CheckoutSdk
4
+ module Transfers
5
+ class TransfersClient < Client
6
+ TRANSFERS = 'transfers'
7
+ private_constant :TRANSFERS
8
+
9
+ # @param [ApiClient] api_client
10
+ # @param [CheckoutConfiguration] configuration
11
+ def initialize(api_client, configuration)
12
+ super(api_client, configuration, CheckoutSdk::AuthorizationType::OAUTH)
13
+ end
14
+
15
+ # @param [CreateTransfer] create_transfer
16
+ # @param [String, nil] idempotency_key
17
+ def initiate_transfer_of_funds(create_transfer, idempotency_key = nil)
18
+ api_client.invoke_post(TRANSFERS, sdk_authorization, create_transfer, idempotency_key)
19
+ end
20
+
21
+ # @param [String] transfer_id
22
+ def retrieve_transfer(transfer_id)
23
+ api_client.invoke_get(build_path(TRANSFERS, transfer_id), sdk_authorization)
24
+ end
25
+ end
26
+ end
27
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CheckoutSdk
4
- VERSION = '1.0.0.beta.2'
4
+ VERSION = '1.0.0.beta.3'
5
5
  end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CheckoutSdk
4
+ module Previous
5
+ module Webhooks
6
+ # @!attribute url
7
+ # @return [String]
8
+ # @!attribute active
9
+ # @return [TrueClass, FalseClass]
10
+ # @!attribute headers
11
+ # @return [Hash(String=>String)]
12
+ # @!attribute content_type
13
+ # @return [String]
14
+ # @!attribute event_types
15
+ # @return [Array(String)]
16
+ class WebhookRequest
17
+ attr_accessor :url,
18
+ :active,
19
+ :headers,
20
+ :content_type,
21
+ :event_types
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'checkout_sdk/webhooks/webhook_request'
4
+ require 'checkout_sdk/webhooks/webhooks_client'
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CheckoutSdk
4
+ module Previous
5
+ module Webhooks
6
+ class WebhooksClient < Client
7
+ WEBHOOKS = 'webhooks'
8
+ private_constant :WEBHOOKS
9
+
10
+ # @param [ApiClient] api_client
11
+ # @param [CheckoutConfiguration] configuration
12
+ def initialize(api_client, configuration)
13
+ super(api_client, configuration, CheckoutSdk::AuthorizationType::SECRET_KEY)
14
+ end
15
+
16
+ def retrieve_webhooks
17
+ api_client.invoke_get(WEBHOOKS, sdk_authorization)
18
+ end
19
+
20
+ # @param [WebhookRequest] webhook_request
21
+ # @param [String,nil] idempotency_key
22
+ def register_webhook(webhook_request, idempotency_key = nil)
23
+ api_client.invoke_post(WEBHOOKS, sdk_authorization, webhook_request, idempotency_key)
24
+ end
25
+
26
+ # @param [String] webhook_id
27
+ def retrieve_webhook(webhook_id)
28
+ api_client.invoke_get(build_path(WEBHOOKS, webhook_id), sdk_authorization)
29
+ end
30
+
31
+ # @param [String] webhook_id
32
+ # @param [WebhookRequest] webhook_request
33
+ def update_webhook(webhook_id, webhook_request)
34
+ api_client.invoke_put(build_path(WEBHOOKS, webhook_id), sdk_authorization, webhook_request)
35
+ end
36
+
37
+ # @param [String] webhook_id
38
+ # @param [WebhookRequest] webhook_request
39
+ def patch_webhook(webhook_id, webhook_request)
40
+ api_client.invoke_patch(build_path(WEBHOOKS, webhook_id), sdk_authorization, webhook_request)
41
+ end
42
+
43
+ # @param [String] webhook_id
44
+ def remove_webhook(webhook_id)
45
+ api_client.invoke_delete(build_path(WEBHOOKS, webhook_id), sdk_authorization)
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
data/lib/checkout_sdk.rb CHANGED
@@ -6,7 +6,9 @@ require 'json'
6
6
  require 'faraday'
7
7
  require 'faraday/multipart'
8
8
  require 'faraday/net_http'
9
+ require 'faraday/follow_redirects'
9
10
  require 'mime/types'
11
+ require 'logger'
10
12
 
11
13
  # Version
12
14
  require 'checkout_sdk/version'
@@ -30,6 +32,7 @@ require 'checkout_sdk/static_keys_builder'
30
32
  require 'checkout_sdk/checkout_static_keys_sdk_builder'
31
33
  require 'checkout_sdk/checkout_sdk_builder'
32
34
  require 'checkout_sdk/checkout_api'
35
+ require 'checkout_sdk/simple_logger'
33
36
 
34
37
  # Configuration(Previous)
35
38
  require 'checkout_sdk/previous/checkout_previous_static_keys_sdk_builder'
@@ -56,9 +59,15 @@ require 'checkout_sdk/tokens/tokens'
56
59
  require 'checkout_sdk/apm/apm'
57
60
  require 'checkout_sdk/accounts/accounts'
58
61
  require 'checkout_sdk/workflows/workflows'
62
+ require 'checkout_sdk/risk/risk'
63
+ require 'checkout_sdk/balances/balances'
64
+ require 'checkout_sdk/transfers/transfers'
59
65
 
60
66
  # Checkout modules (previous)
61
67
  require 'checkout_sdk/sources/sources'
68
+ require 'checkout_sdk/reconciliation/reconciliation'
69
+ require 'checkout_sdk/webhooks/webhooks'
70
+ require 'checkout_sdk/events/events'
62
71
 
63
72
  module CheckoutSdk
64
73
  include PlatformType