Class: Transactions::Reservation
- Inherits:
-
BaseOperationService
- Object
- BaseOperationService
- Transactions::Reservation
- Includes:
- DefaultErrorContainer
- Defined in:
- app/services/payment_process_service/transactions/reservation.rb
Defined Under Namespace
Classes: DuplicateChargeError
Instance Attribute Summary collapse
-
#reservation ⇒ Object
Returns the value of attribute reservation.
Instance Method Summary collapse
- #cancelled! ⇒ Object
- #complete! ⇒ Object
-
#initialize(ticket_transaction_id, by_admin = false) ⇒ Reservation
constructor
A new instance of Reservation.
Methods included from DefaultErrorContainer
#error, #error_message_simple, #merge_errors
Constructor Details
#initialize(ticket_transaction_id, by_admin = false) ⇒ Reservation
Returns a new instance of Reservation.
10 11 12 13 14 15 |
# File 'app/services/payment_process_service/transactions/reservation.rb', line 10 def initialize(ticket_transaction_id, by_admin = false) HH_LOGGER.debug('PaymentProcessService::Transactions::Reservation', ticket_transaction_id: ticket_transaction_id, by_admin: by_admin) @ticket_transaction = TicketTransaction.find_by(id: ticket_transaction_id) @by_admin = by_admin end |
Instance Attribute Details
#reservation ⇒ Object
Returns the value of attribute reservation.
7 8 9 |
# File 'app/services/payment_process_service/transactions/reservation.rb', line 7 def reservation @reservation end |
Instance Method Details
#cancelled! ⇒ Object
41 42 43 44 45 46 |
# File 'app/services/payment_process_service/transactions/reservation.rb', line 41 def cancelled! transaction.audit_comment = [transaction.audit_comment, 'cancel booking because didnt pay'].to_sentence transaction.mark_as_canceled! transaction.mark_voucher_as_inactive! transaction.save!(validate: false) end |
#complete! ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'app/services/payment_process_service/transactions/reservation.rb', line 17 def complete! raise StandardError, 'Failed updating reservation data' if reservation.blank? reservation.audit_comment = [reservation.audit_comment, 'Marked as paid by admin'].to_sentence if by_admin reservation.mark_as_valid_reservation! unless reservation.save APMErrorHandler.report('failed updating reservation as active', charge: charge.attributes) raise StandardError, 'Failed updating reservation data' end reservation.mark_voucher_as_active! reservation.touch # Use async sync for payment completion to avoid blocking user experience # Payment completion is critical but should not block the payment flow reservation.trigger_summary_sync send_notification MyPusher::ReservationDriver.broadcast_reservation(reservation, :update) true end |