Class: PaymentProcessService::MarkAsPaid
- Inherits:
-
BaseOperationService
- Object
- BaseOperationService
- PaymentProcessService::MarkAsPaid
- Includes:
- DefaultErrorContainer
- Defined in:
- app/services/payment_process_service/mark_as_paid.rb
Overview
typed: ignore Service to handle after transaction payment
Defined Under Namespace
Classes: DuplicateChargeError
Instance Attribute Summary collapse
-
#by_admin ⇒ Object
writeonly
Sets the attribute by_admin.
-
#charge_id ⇒ Object
readonly
Returns the value of attribute charge_id.
-
#reference_no ⇒ Object
readonly
Returns the value of attribute reference_no.
-
#transaction_id ⇒ Object
readonly
Returns the value of attribute transaction_id.
Attributes inherited from BaseOperationService
Instance Method Summary collapse
- #execute ⇒ Object
- #execute! ⇒ Object
-
#initialize(charge_id, transaction_id, reference_no = nil) ⇒ MarkAsPaid
constructor
A new instance of MarkAsPaid.
Methods included from DefaultErrorContainer
#error, #error_message_simple, #merge_errors
Methods inherited from BaseOperationService
Constructor Details
#initialize(charge_id, transaction_id, reference_no = nil) ⇒ MarkAsPaid
Returns a new instance of MarkAsPaid.
12 13 14 15 16 17 |
# File 'app/services/payment_process_service/mark_as_paid.rb', line 12 def initialize(charge_id, transaction_id, reference_no = nil) @charge_id = charge_id @transaction_id = transaction_id @by_admin = transaction_id == 'by-admin' @reference_no = reference_no end |
Instance Attribute Details
#by_admin=(value) ⇒ Object
Sets the attribute by_admin
7 8 9 |
# File 'app/services/payment_process_service/mark_as_paid.rb', line 7 def by_admin=(value) @by_admin = value end |
#charge_id ⇒ Object (readonly)
Returns the value of attribute charge_id.
6 7 8 |
# File 'app/services/payment_process_service/mark_as_paid.rb', line 6 def charge_id @charge_id end |
#reference_no ⇒ Object (readonly)
Returns the value of attribute reference_no.
6 7 8 |
# File 'app/services/payment_process_service/mark_as_paid.rb', line 6 def reference_no @reference_no end |
#transaction_id ⇒ Object (readonly)
Returns the value of attribute transaction_id.
6 7 8 |
# File 'app/services/payment_process_service/mark_as_paid.rb', line 6 def transaction_id @transaction_id end |
Instance Method Details
#execute ⇒ Object
40 41 42 43 44 45 |
# File 'app/services/payment_process_service/mark_as_paid.rb', line 40 def execute execute! rescue StandardError => e errors.add(:base, e.) false end |
#execute! ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/services/payment_process_service/mark_as_paid.rb', line 19 def execute! errors.clear raise StandardError, "Charge ID #{charge_id} is not found" if charge.blank? transaction = charge.transaction transction_type = charge.transaction_product_type update_attributes(charge) payment_process = payment_process_class(transction_type).new(transaction.id, by_admin) unless payment_process.complete! merge_errors(payment_process.errors) APMErrorHandler.report("failed updating #{transction_type} as active", charge: charge.attributes) raise StandardError, 'Failed updating trasaction data' end true rescue DuplicateChargeError true end |