From 9607fcb5a9cdc7595633336881cc0dd8aa9fb8ca Mon Sep 17 00:00:00 2001 From: HombreLaser Date: Fri, 14 Apr 2023 20:52:50 -0600 Subject: Corrige errores de OrdersController --- app/controllers/api/orders_controller.rb | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'app/controllers/api') diff --git a/app/controllers/api/orders_controller.rb b/app/controllers/api/orders_controller.rb index 7a26d11..a57bf68 100644 --- a/app/controllers/api/orders_controller.rb +++ b/app/controllers/api/orders_controller.rb @@ -9,8 +9,16 @@ module Api render json: serialized_collection.serializable_hash, status: :ok end + def show + @order = current_user_account.orders.find_by(id: params[:id]) + + render status: :not_found and return if @order.nil? + + render json: serialized_object.serializable_hash, status: :ok + end + def create - @service = PaymentService.new(@order, permitted_params[:card_id]) + @service = PaymentServices::PaymentService.new(permitted_params[:card_id], current_user_account) @order = @service.call if @order @@ -29,5 +37,9 @@ module Api def serialized_object @serialized_object ||= OrderSerializer.new(@order) end + + def permitted_params + params.permit(:card_id) + end end end -- cgit v1.2.3