mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-02-21 15:54:22 +01:00
handle only subscription process in cart
This commit is contained in:
parent
789c6a28fe
commit
2ab7f3bdb9
@ -162,7 +162,7 @@ Application.Controllers.controller('PlansIndexController', ['$scope', '$rootScop
|
|||||||
$scope.filterDisabledPlans = function (plan) { return !plan.disabled; };
|
$scope.filterDisabledPlans = function (plan) { return !plan.disabled; };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Once the subscription is confirmed (payment process successfully completed), make the plan as subscribed,
|
* Once the subscription has been confirmed (payment process successfully completed), mark the plan as subscribed,
|
||||||
* and update the user's subscription
|
* and update the user's subscription
|
||||||
*/
|
*/
|
||||||
$scope.afterPayment = function () {
|
$scope.afterPayment = function () {
|
||||||
|
@ -778,20 +778,25 @@ Application.Directives.directive('cart', ['$rootScope', '$uibModal', 'dialogs',
|
|||||||
subscription: {
|
subscription: {
|
||||||
plan_id: selectedPlan.id,
|
plan_id: selectedPlan.id,
|
||||||
user_id: reservation.user_id,
|
user_id: reservation.user_id,
|
||||||
payment_schedule: schedule // TODO, check it is the best place to pass the param
|
payment_schedule: schedule
|
||||||
}
|
}
|
||||||
}, function () {
|
}, function (subscription) {
|
||||||
// TODO, then... and error handling
|
$uibModalInstance.close(subscription);
|
||||||
|
$scope.attempting = true;
|
||||||
|
}, function (response) {
|
||||||
|
$scope.alerts = [];
|
||||||
|
$scope.alerts.push({ msg: _t('app.shared.cart.a_problem_occurred_during_the_payment_process_please_try_again_later'), type: 'danger' });
|
||||||
|
$scope.attempting = false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// otherwise, save the reservation (may include a subscription)
|
// otherwise, save the reservation (may include a subscription)
|
||||||
Reservation.save(mkRequestParams($scope.reservation, coupon), function (reservation) {
|
Reservation.save(mkRequestParams($scope.reservation, coupon), function (reservation) {
|
||||||
$uibModalInstance.close(reservation);
|
$uibModalInstance.close(reservation);
|
||||||
return $scope.attempting = true;
|
$scope.attempting = true;
|
||||||
}, function (response) {
|
}, function (response) {
|
||||||
$scope.alerts = [];
|
$scope.alerts = [];
|
||||||
$scope.alerts.push({ msg: _t('app.shared.cart.a_problem_occurred_during_the_payment_process_please_try_again_later'), type: 'danger' });
|
$scope.alerts.push({ msg: _t('app.shared.cart.a_problem_occurred_during_the_payment_process_please_try_again_later'), type: 'danger' });
|
||||||
return $scope.attempting = false;
|
$scope.attempting = false;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
$scope.cancel = function () { $uibModalInstance.dismiss('cancel'); };
|
$scope.cancel = function () { $uibModalInstance.dismiss('cancel'); };
|
||||||
@ -802,6 +807,7 @@ Application.Directives.directive('cart', ['$rootScope', '$uibModal', 'dialogs',
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Actions to run after the payment was successful
|
* Actions to run after the payment was successful
|
||||||
|
* @param reservation {Object} may be a reservation or a subscription
|
||||||
*/
|
*/
|
||||||
const afterPayment = function (reservation) {
|
const afterPayment = function (reservation) {
|
||||||
// we set the cart content as 'paid' to display a summary of the transaction
|
// we set the cart content as 'paid' to display a summary of the transaction
|
||||||
@ -809,11 +815,11 @@ Application.Directives.directive('cart', ['$rootScope', '$uibModal', 'dialogs',
|
|||||||
$scope.amountPaid = $scope.amountTotal;
|
$scope.amountPaid = $scope.amountTotal;
|
||||||
// we call the external callback if present
|
// we call the external callback if present
|
||||||
if (typeof $scope.afterPayment === 'function') { $scope.afterPayment(reservation); }
|
if (typeof $scope.afterPayment === 'function') { $scope.afterPayment(reservation); }
|
||||||
// we reset the coupon and the cart content and we unselect the slot
|
// we reset the coupon, and the cart content, and we unselect the slot
|
||||||
$scope.events.reserved = [];
|
$scope.events.reserved = [];
|
||||||
$scope.coupon.applied = null;
|
$scope.coupon.applied = null;
|
||||||
$scope.slot = null;
|
$scope.slot = null;
|
||||||
return $scope.selectedPlan = null;
|
$scope.selectedPlan = null;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user