1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-12-03 14:24:23 +01:00
fab-manager/app/controllers/api/local_payment_controller.rb
Sylvain c7a59c8cb7 WIP: refactoring to singularize the booking process
We need to achieve only one process for all booking, not one for subscription, one for reservations, etc.
Moreover we must store one object per invoice_item/payment_schedule_object and stop using Invoice.invoiced or PaymentSchedule.scheduled
2021-05-21 18:25:18 +02:00

27 lines
611 B
Ruby

# frozen_string_literal: true
# API Controller for handling local payments (at the reception) or when the amount = 0
class API::LocalPaymentController < API::PaymentsController
def confirm_payment
cart = shopping_cart
price = debit_amount(cart)
authorize LocalPaymentContext.new(cart, price[:amount])
if cart.reservation
res = on_reservation_success(nil, nil, cart)
elsif cart.subscription
res = on_subscription_success(nil, nil, cart)
end
render res
end
protected
def shopping_cart
cs = CartService.new(current_user)
cs.from_hash(params)
end
end