1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-04-10 00:53:51 +02: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 end
def i_calendar_params 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
end end

View File

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

View File

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

View File

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