1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-11-28 09:24:24 +01:00

correct some errors due to Price.compute refactoring

This commit is contained in:
Sylvain 2020-05-11 10:56:23 +02:00
parent 06502cde33
commit 1fdea63828
4 changed files with 11 additions and 6 deletions

View File

@ -47,6 +47,6 @@ class API::ICalendarController < API::ApiController
end
def i_calendar_params
params.require(:i_calendar).permit(:name, :url, :color, :primary_text_color, :text_hidden)
params.require(:i_calendar).permit(:name, :url, :color, :text_color, :text_hidden)
end
end

View File

@ -12,7 +12,12 @@ class API::PaymentsController < API::ApiController
def confirm_payment
render(json: { error: 'Online payment is disabled' }, status: :unauthorized) and return if Rails.application.secrets.fablab_without_online_payments
amount = nil # will contains the amount and the details of each invoice lines
intent = nil # stripe's payment intent
res = nil # json of the API answer
begin
amount = card_amount
if params[:payment_method_id].present?
check_coupon
check_plan
@ -20,7 +25,7 @@ class API::PaymentsController < API::ApiController
# Create the PaymentIntent
intent = Stripe::PaymentIntent.create(
payment_method: params[:payment_method_id],
amount: card_amount,
amount: amount[:amount],
currency: Rails.application.secrets.stripe_currency,
confirmation_method: 'manual',
confirm: true,
@ -40,7 +45,7 @@ class API::PaymentsController < API::ApiController
if intent&.status == 'succeeded'
if params[:cart_items][:reservation]
res = on_reservation_success(intent)
res = on_reservation_success(intent, amount[:details])
elsif params[:cart_items][:subscription]
res = on_subscription_success(intent)
end
@ -142,7 +147,7 @@ class API::PaymentsController < API::ApiController
# Subtract wallet amount from total
total = price_details[:total]
wallet_debit = get_wallet_debit(current_user, total)
total - wallet_debit
{ amount: total - wallet_debit, details: price_details }
end
def check_coupon

View File

@ -267,7 +267,7 @@ class Reservation < ApplicationRecord
unless coupon.nil?
total = CouponService.new.apply(total, coupon, user.id)
invoice.coupon_id = cp.id
invoice.coupon_id = coupon.id
end
invoice.total = total

View File

@ -8,7 +8,7 @@ class CreateICalendars < ActiveRecord::Migration[4.2]
t.string :url
t.string :name
t.string :color
t.string :primary_text_color
t.string :text_color
t.boolean :text_hidden
t.timestamps null: false