Class: Api::Testing::V1::ReservationsController
- Inherits:
-
BaseController
- Object
- ActionController::Base
- ApplicationController
- BaseController
- Api::Testing::V1::ReservationsController
- Defined in:
- app/controllers/api/testing/v1/reservations_controller.rb
Instance Method Summary collapse
-
#mark_as_paid ⇒ Object
Mark a reservation as paid - replicates admin functionality for testing POST /api/testing/v1/reservations/:id/mark_as_paid.
Methods inherited from ApplicationController
#after_sign_in_path_for, #after_sign_out_path_for, #default_url_options, #identity_cache_memoization, #render_not_found, #routing_error, search_params_key=
Methods included from LogrageCustomLogger
Methods included from ControllerHelpers
#check_boolean_param, #get_banners, #inventory_params, #reservation_params
Instance Method Details
#mark_as_paid ⇒ Object
Mark a reservation as paid - replicates admin functionality for testing POST /api/testing/v1/reservations/:id/mark_as_paid
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/controllers/api/testing/v1/reservations_controller.rb', line 10 def mark_as_paid reservation = Reservation.find_by(id: params.require(:id)) if reservation.blank? return render json: { success: false, message: 'Reservation not found' }, status: :not_found end charge = reservation.charges.pending_scope.last if charge.blank? return render json: { success: false, message: 'Omise Charge ID not found' }, status: :not_found end charge_id = charge.omise_charge_id service = MarkReservationAsPaidService.new(charge_id, 'by-admin') if service.execute render json: { success: true } else render json: { success: false, message: service. }, status: :unprocessable_entity end end |