Class: PaymentProcessService::Cancelled
- Inherits:
-
BaseOperationService
- Object
- BaseOperationService
- PaymentProcessService::Cancelled
- Includes:
- DefaultErrorContainer
- Defined in:
- app/services/payment_process_service/cancelled.rb
Overview
typed: ignore Service to handle after transaction payment
Defined Under Namespace
Classes: DuplicateChargeError
Instance Attribute Summary collapse
-
#reason ⇒ Object
Returns the value of attribute reason.
-
#transaction ⇒ Object
Returns the value of attribute transaction.
-
#transaction_type ⇒ Object
Returns the value of attribute transaction_type.
Attributes inherited from BaseOperationService
Instance Method Summary collapse
- #execute ⇒ Object
- #execute! ⇒ Object
-
#initialize(transaction_type, transaction_id, reason = nil) ⇒ Cancelled
constructor
A new instance of Cancelled.
Methods included from DefaultErrorContainer
#error, #error_message_simple, #merge_errors
Methods inherited from BaseOperationService
Constructor Details
#initialize(transaction_type, transaction_id, reason = nil) ⇒ Cancelled
Returns a new instance of Cancelled.
7 8 9 10 11 |
# File 'app/services/payment_process_service/cancelled.rb', line 7 def initialize(transaction_type, transaction_id, reason = nil) @transaction_type = transaction_type.to_s.camelize @transaction = @transaction_type.constantize.find_by(id: transaction_id) @reason = reason end |
Instance Attribute Details
#reason ⇒ Object
Returns the value of attribute reason.
5 6 7 |
# File 'app/services/payment_process_service/cancelled.rb', line 5 def reason @reason end |
#transaction ⇒ Object
Returns the value of attribute transaction.
5 6 7 |
# File 'app/services/payment_process_service/cancelled.rb', line 5 def transaction @transaction end |
#transaction_type ⇒ Object
Returns the value of attribute transaction_type.
5 6 7 |
# File 'app/services/payment_process_service/cancelled.rb', line 5 def transaction_type @transaction_type end |
Instance Method Details
#execute ⇒ Object
24 25 26 27 28 29 |
# File 'app/services/payment_process_service/cancelled.rb', line 24 def execute execute! rescue StandardError => e errors.add(:base, e.) false end |
#execute! ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'app/services/payment_process_service/cancelled.rb', line 13 def execute! errors.clear raise StandardError, "#{transaction_type} ID #{transaction.id} is not found" if transaction.blank? service = payment_process_class.new(transaction.id) service.cancelled!(reason) rescue DuplicateChargeError true end |