1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-02-19 13:54:25 +01:00

fix payment on site modal in case of payment schedule

This commit is contained in:
Sylvain 2021-04-28 17:25:42 +02:00
parent 30c1c91590
commit 23e38238c8
10 changed files with 29 additions and 30 deletions

View File

@ -40,11 +40,7 @@ class API::PaymentsController < API::ApiController
end end
def check_plan def check_plan
plan_id = if params[:cart_items][:subscription] plan_id = (cart_items_params[:subscription][:plan_id] if cart_items_params[:subscription])
subscription_params[:plan_id]
elsif params[:cart_items][:reservation]
reservation_params[:plan_id]
end
return unless plan_id return unless plan_id
@ -106,7 +102,7 @@ class API::PaymentsController < API::ApiController
end end
def reservation_params def reservation_params
params[:cart_items].require(:reservation).permit(:reservable_id, :reservable_type, :plan_id, :nb_reserve_places, params[:cart_items].require(:reservation).permit(:reservable_id, :reservable_type, :nb_reserve_places,
tickets_attributes: %i[event_price_category_id booked], tickets_attributes: %i[event_price_category_id booked],
slots_attributes: %i[id start_at end_at availability_id offered]) slots_attributes: %i[id start_at end_at availability_id offered])
end end
@ -116,9 +112,12 @@ class API::PaymentsController < API::ApiController
end end
def cart_items_params def cart_items_params
params[:cart_items].require(:reservation).permit(:reservable_id, :reservable_type, :plan_id, :user_id, :nb_reserve_places, params.require(:cart_items).permit(subscription: :plan_id,
tickets_attributes: %i[event_price_category_id booked], reservation: [
slots_attributes: %i[id start_at end_at availability_id offered]) :reservable_id, :reservable_type, :nb_reserve_places,
tickets_attributes: %i[event_price_category_id booked],
slots_attributes: %i[id start_at end_at availability_id offered]
])
end end
def coupon_params def coupon_params

View File

@ -7,7 +7,7 @@ import { PaymentConfirmation } from '../../../models/payment';
import StripeAPI from '../../../api/stripe'; import StripeAPI from '../../../api/stripe';
interface StripeFormProps extends GatewayFormProps { interface StripeFormProps extends GatewayFormProps {
onSuccess: (result: SetupIntent|PaymentConfirmation|any) => void, onSuccess: (result: SetupIntent|PaymentConfirmation) => void,
} }
/** /**

View File

@ -724,7 +724,7 @@ Application.Directives.directive('cart', ['$rootScope', '$uibModal', 'dialogs',
return Price.compute(mkCartItems(items, '')).$promise; return Price.compute(mkCartItems(items, '')).$promise;
}, },
cartItems () { cartItems () {
return mkCartItems(items, 'card'); return mkCartItems(items, '');
}, },
wallet () { wallet () {
return Wallet.getWalletByUser({ user_id: $scope.user.id }).$promise; return Wallet.getWalletByUser({ user_id: $scope.user.id }).$promise;
@ -770,7 +770,7 @@ Application.Directives.directive('cart', ['$rootScope', '$uibModal', 'dialogs',
// how should we collect payments for the payment schedule // how should we collect payments for the payment schedule
$scope.method = { $scope.method = {
payment_method: settings.payment_gateway payment_method: 'card'
}; };
// "valid" Button label // "valid" Button label
@ -787,7 +787,7 @@ Application.Directives.directive('cart', ['$rootScope', '$uibModal', 'dialogs',
* Callback to process the local payment, triggered on button click * Callback to process the local payment, triggered on button click
*/ */
$scope.ok = function () { $scope.ok = function () {
if ($scope.schedule && $scope.method.payment_method === settings.payment_gateway) { if ($scope.schedule && $scope.method.payment_method === 'card') {
// check that the online payment is enabled // check that the online payment is enabled
if (settings.online_payment_module !== 'true') { if (settings.online_payment_module !== 'true') {
return growl.error(_t('app.shared.cart.online_payment_disabled')); return growl.error(_t('app.shared.cart.online_payment_disabled'));
@ -865,7 +865,7 @@ Application.Directives.directive('cart', ['$rootScope', '$uibModal', 'dialogs',
if (AuthService.isAuthorized(['admin', 'manager']) && $rootScope.currentUser.id !== cartItems.customer_id) { if (AuthService.isAuthorized(['admin', 'manager']) && $rootScope.currentUser.id !== cartItems.customer_id) {
method = $scope.method.payment_method; method = $scope.method.payment_method;
} else { } else {
method = settings.payment_gateway; method = 'card';
} }
} }
if ($scope.amount > 0) { if ($scope.amount > 0) {

View File

@ -22,10 +22,10 @@
<select id="method" <select id="method"
class="form-control m-b" class="form-control m-b"
ng-model="method.payment_method"> ng-model="method.payment_method">
<option value="stripe" translate>{{ 'app.shared.valid_reservation_modal.method_stripe' }}</option> <option value="card" translate>{{ 'app.shared.valid_reservation_modal.method_card' }}</option>
<option value="check" translate>{{ 'app.shared.valid_reservation_modal.method_check' }}</option> <option value="check" translate>{{ 'app.shared.valid_reservation_modal.method_check' }}</option>
</select> </select>
<p ng-show="method.payment_method == 'stripe'" translate>{{ 'app.shared.valid_reservation_modal.stripe_collection_info' }}</p> <p ng-show="method.payment_method == 'card'" translate>{{ 'app.shared.valid_reservation_modal.card_collection_info' }}</p>
<p ng-show="method.payment_method == 'check'" translate translate-values="{DEADLINES: schedule.items.length}">{{ 'app.shared.valid_reservation_modal.check_collection_info' }}</p> <p ng-show="method.payment_method == 'check'" translate translate-values="{DEADLINES: schedule.items.length}">{{ 'app.shared.valid_reservation_modal.check_collection_info' }}</p>
</div> </div>
</div> </div>
@ -49,8 +49,8 @@
<div class="modal-footer"> <div class="modal-footer">
<button class="btn btn-info" ng-click="ok()" ng-disabled="attempting" ng-bind-html="validButtonName"></button> <button class="btn btn-info" ng-click="ok()" ng-disabled="attempting" ng-bind-html="validButtonName"></button>
<button class="btn btn-default" ng-click="cancel()" translate>{{ 'app.shared.buttons.cancel' }}</button> <button class="btn btn-default" ng-click="cancel()" translate>{{ 'app.shared.buttons.cancel' }}</button>
<payment-modal is-open="isOpenStripeModal" <payment-modal is-open="isOpenOnlinePaymentModal"
toggle-modal="toggleStripeModal" toggle-modal="toggleOnlinePaymentModal"
after-success="afterCreatePaymentSchedule" after-success="afterCreatePaymentSchedule"
cart-items="cartItems" cart-items="cartItems"
current-user="currentUser" current-user="currentUser"

View File

@ -128,9 +128,9 @@ de:
subscription_confirmation: "Abonnementbestätigung" subscription_confirmation: "Abonnementbestätigung"
here_is_the_subscription_summary: "Here is the subscription summary:" here_is_the_subscription_summary: "Here is the subscription summary:"
payment_method: "Payment method" payment_method: "Payment method"
method_stripe: "Online by card" method_card: "Online by card"
method_check: "By check" method_check: "By check"
stripe_collection_info: "By validating, you'll be prompted for the member's card number. This card will be automatically charged at the deadlines." card_collection_info: "By validating, you'll be prompted for the member's card number. This card will be automatically charged at the deadlines."
check_collection_info: "By validating, you confirm that you have {DEADLINES} checks, allowing you to collect all the monthly payments." check_collection_info: "By validating, you confirm that you have {DEADLINES} checks, allowing you to collect all the monthly payments."
#event edition form #event edition form
event: event:

View File

@ -128,9 +128,9 @@ en:
subscription_confirmation: "Subscription confirmation" subscription_confirmation: "Subscription confirmation"
here_is_the_subscription_summary: "Here is the subscription summary:" here_is_the_subscription_summary: "Here is the subscription summary:"
payment_method: "Payment method" payment_method: "Payment method"
method_stripe: "Online by card" method_card: "Online by card"
method_check: "By check" method_check: "By check"
stripe_collection_info: "By validating, you'll be prompted for the member's card number. This card will be automatically charged at the deadlines." card_collection_info: "By validating, you'll be prompted for the member's card number. This card will be automatically charged at the deadlines."
check_collection_info: "By validating, you confirm that you have {DEADLINES} checks, allowing you to collect all the monthly payments." check_collection_info: "By validating, you confirm that you have {DEADLINES} checks, allowing you to collect all the monthly payments."
#event edition form #event edition form
event: event:

View File

@ -128,9 +128,9 @@ es:
subscription_confirmation: "Subscription confirmation" subscription_confirmation: "Subscription confirmation"
here_is_the_subscription_summary: "Here is the subscription summary:" here_is_the_subscription_summary: "Here is the subscription summary:"
payment_method: "Payment method" payment_method: "Payment method"
method_stripe: "Online by card" method_card: "Online by card"
method_check: "By check" method_check: "By check"
stripe_collection_info: "By validating, you'll be prompted for the member's card number. This card will be automatically charged at the deadlines." card_collection_info: "By validating, you'll be prompted for the member's card number. This card will be automatically charged at the deadlines."
check_collection_info: "By validating, you confirm that you have {DEADLINES} checks, allowing you to collect all the monthly payments." check_collection_info: "By validating, you confirm that you have {DEADLINES} checks, allowing you to collect all the monthly payments."
#event edition form #event edition form
event: event:

View File

@ -128,9 +128,9 @@ fr:
subscription_confirmation: "Validation de l'abonnement" subscription_confirmation: "Validation de l'abonnement"
here_is_the_subscription_summary: "Voici le récapitulatif de l'abonnement :" here_is_the_subscription_summary: "Voici le récapitulatif de l'abonnement :"
payment_method: "Moyen de paiement" payment_method: "Moyen de paiement"
method_stripe: "Carte bancaire en ligne" method_card: "Carte bancaire en ligne"
method_check: "Par chèques" method_check: "Par chèques"
stripe_collection_info: "En validant, vous serez invité à saisir les informations de carte bancaire du membre. Cette carte sera prélevée automatiquement aux échéances." card_collection_info: "En validant, vous serez invité à saisir les informations de carte bancaire du membre. Cette carte sera prélevée automatiquement aux échéances."
check_collection_info: "En validant, vous confirmez être en possession de {DEADLINES} chèques permettant d'encaisser l'ensemble des mensualité." check_collection_info: "En validant, vous confirmez être en possession de {DEADLINES} chèques permettant d'encaisser l'ensemble des mensualité."
#event edition form #event edition form
event: event:

View File

@ -128,9 +128,9 @@ pt:
subscription_confirmation: "Inscrição confirmada" subscription_confirmation: "Inscrição confirmada"
here_is_the_subscription_summary: "Here is the subscription summary:" here_is_the_subscription_summary: "Here is the subscription summary:"
payment_method: "Payment method" payment_method: "Payment method"
method_stripe: "Online by card" method_card: "Online by card"
method_check: "By check" method_check: "By check"
stripe_collection_info: "By validating, you'll be prompted for the member's card number. This card will be automatically charged at the deadlines." card_collection_info: "By validating, you'll be prompted for the member's card number. This card will be automatically charged at the deadlines."
check_collection_info: "By validating, you confirm that you have {DEADLINES} checks, allowing you to collect all the monthly payments." check_collection_info: "By validating, you confirm that you have {DEADLINES} checks, allowing you to collect all the monthly payments."
#event edition form #event edition form
event: event:

View File

@ -128,9 +128,9 @@ zu:
subscription_confirmation: "crwdns20920:0crwdne20920:0" subscription_confirmation: "crwdns20920:0crwdne20920:0"
here_is_the_subscription_summary: "crwdns20922:0crwdne20922:0" here_is_the_subscription_summary: "crwdns20922:0crwdne20922:0"
payment_method: "crwdns20924:0crwdne20924:0" payment_method: "crwdns20924:0crwdne20924:0"
method_stripe: "crwdns20926:0crwdne20926:0" method_card: "crwdns20926:0crwdne20926:0"
method_check: "crwdns20928:0crwdne20928:0" method_check: "crwdns20928:0crwdne20928:0"
stripe_collection_info: "crwdns20930:0crwdne20930:0" card_collection_info: "crwdns20930:0crwdne20930:0"
check_collection_info: "crwdns20932:0{DEADLINES}crwdne20932:0" check_collection_info: "crwdns20932:0{DEADLINES}crwdne20932:0"
#event edition form #event edition form
event: event: