mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-01-18 07:52:23 +01:00
process the schedule to the stripe subscription
- only for subscriptions for now - TODO: reservations (see app/services/reservations/reserv.rb:13)
This commit is contained in:
parent
a20be8ecb2
commit
c3c881d2a8
@ -97,7 +97,12 @@ class API::PaymentsController < API::ApiController
|
||||
|
||||
def on_reservation_success(intent, details)
|
||||
@reservation = Reservation.new(reservation_params)
|
||||
is_reserve = Reservations::Reserve.new(current_user.id, current_user.invoicing_profile.id)
|
||||
user_id = if current_user.admin? || current_user.manager?
|
||||
params[:cart_items][:reservation][:user_id]
|
||||
else
|
||||
current_user.id
|
||||
end
|
||||
is_reserve = Reservations::Reserve.new(user_id, current_user.invoicing_profile.id)
|
||||
.pay_and_save(@reservation, payment_details: details, payment_intent_id: intent.id)
|
||||
if intent.class == Stripe::PaymentIntent
|
||||
Stripe::PaymentIntent.update(
|
||||
@ -118,11 +123,17 @@ class API::PaymentsController < API::ApiController
|
||||
|
||||
def on_subscription_success(intent)
|
||||
@subscription = Subscription.new(subscription_params)
|
||||
is_subscribe = Subscriptions::Subscribe.new(current_user.invoicing_profile.id, current_user.id)
|
||||
user_id = if current_user.admin? || current_user.manager?
|
||||
params[:cart_items][:subscription][:user_id]
|
||||
else
|
||||
current_user.id
|
||||
end
|
||||
is_subscribe = Subscriptions::Subscribe.new(current_user.invoicing_profile.id, user_id)
|
||||
.pay_and_save(@subscription,
|
||||
coupon: coupon_params[:coupon_code],
|
||||
invoice: true,
|
||||
payment_intent_id: intent.id,
|
||||
schedule: params[:cart_items][:subscription][:payment_schedule],
|
||||
payment_method: 'stripe')
|
||||
if intent.class == Stripe::PaymentIntent
|
||||
Stripe::PaymentIntent.update(
|
||||
|
@ -185,6 +185,9 @@ const StripeModal: React.FC<StripeModalProps> = ({ isOpen, toggleModal, afterSuc
|
||||
{hasErrors() && <div className="stripe-errors">
|
||||
{errors}
|
||||
</div>}
|
||||
{isPaymentSchedule() && <div className="payment-schedule-info">
|
||||
<HtmlTranslate trKey="app.shared.stripe.payment_schedule_html" options={{ DEADLINES: schedule.items.length }} />
|
||||
</div>}
|
||||
{hasCgv() && <div className="terms-of-sales">
|
||||
<input type="checkbox" id="acceptToS" name="acceptCondition" checked={tos} onChange={toggleTos} required />
|
||||
<label htmlFor="acceptToS">{ t('app.shared.stripe.i_have_read_and_accept_') }
|
||||
@ -193,9 +196,6 @@ const StripeModal: React.FC<StripeModalProps> = ({ isOpen, toggleModal, afterSuc
|
||||
</a>
|
||||
</label>
|
||||
</div>}
|
||||
{isPaymentSchedule() && <div className="payment-schedule-info">
|
||||
<HtmlTranslate trKey="app.shared.stripe.payment_schedule_html" options={{ DEADLINES: schedule.items.length }} />
|
||||
</div>}
|
||||
</StripeForm>
|
||||
{!submitState && <button type="submit"
|
||||
disabled={!canSubmit()}
|
||||
|
@ -845,7 +845,8 @@ Application.Directives.directive('cart', ['$rootScope', '$uibModal', 'dialogs',
|
||||
* @param result {*} Reservation or Subscription
|
||||
*/
|
||||
$scope.afterCreatePaymentSchedule = function (result) {
|
||||
console.log('TODO', result);
|
||||
$scope.toggleStripeModal();
|
||||
$uibModalInstance.close(result);
|
||||
};
|
||||
|
||||
/* PRIVATE SCOPE */
|
||||
|
@ -47,6 +47,7 @@
|
||||
padding: 15px;
|
||||
background-color: #fcf8e3;
|
||||
color: #8a6d3b;
|
||||
margin-top: 1em;
|
||||
|
||||
p {
|
||||
font-size: small;
|
||||
|
@ -9,7 +9,8 @@ class Reservations::Reserve
|
||||
@operator_profile_id = operator_profile_id
|
||||
end
|
||||
|
||||
def pay_and_save(reservation, payment_details: nil, payment_intent_id: nil)
|
||||
def pay_and_save(reservation, payment_details: nil, payment_intent_id: nil, schedule: false)
|
||||
# TODO, pass the schedule payment up to subscription.save_with_payment(... schedule: schedule)
|
||||
reservation.statistic_profile_id = StatisticProfile.find_by(user_id: user_id).id
|
||||
reservation.save_with_payment(operator_profile_id, payment_details, payment_intent_id)
|
||||
end
|
||||
|
@ -121,7 +121,7 @@ en:
|
||||
_the_general_terms_and_conditions: "the general terms and conditions."
|
||||
credit_amount_for_pay_reservation: "{amount} {currency} remains to be paid to confirm your reservation"
|
||||
client_credit_amount_for_pay_reservation: "{amount} {currency} remains to be paid to confirm reservation of client"
|
||||
payment_schedule: "You're about to subscribe to a payment schedule of {DEADLINES} months. By paying this bill, you agree to pay all payment deadlines."
|
||||
payment_schedule_html: "<p>You're about to subscribe to a payment schedule of {DEADLINES} months.</p><p>By paying this bill, you agree to send instructions to the financial institution that issue your card, to take payments from your card account, for the whole duration of this subscription. This imply that your card data are saved by Stripe and a series of payments will be initiated on your behalf, conforming to the payment schedule previously shown.</p>"
|
||||
confirm_payment_of_: "Pay: {AMOUNT}"
|
||||
#dialog of on site payment for reservations
|
||||
valid_reservation_modal:
|
||||
|
@ -121,7 +121,7 @@ fr:
|
||||
_the_general_terms_and_conditions: "les conditions générales de vente."
|
||||
credit_amount_for_pay_reservation: "Il vous reste {amount} {currency} à payer pour valider votre réservation"
|
||||
client_credit_amount_for_pay_reservation: "Il reste {amount} {currency} à payer pour valider la réservation"
|
||||
payment_schedule: "Vous êtes sur le point de souscrire à un échéancier de paiement de {DEADLINES} mois. En payant cette facture, vous vous engagez à payer l'ensemble des échéances."
|
||||
payment_schedule_html: "<p>Vous êtes sur le point de souscrire à un échéancier de paiement de {DEADLINES} mois.</p><p>En payant cette facture, vous vous engagez à l'envoi d'instructions vers l'institution financière émettrice de votre carte, afin de prélever des paiements sur votre compte, pendant toute la durée de cet abonnement. Cela implique que les données de votre carte soient enregistrées par Stripe et qu'une série de paiements sera initiée en votre nom, conformément à l'échéancier de paiement précédemment affiché.</p>"
|
||||
confirm_payment_of_: "Payer : {AMOUNT}"
|
||||
#dialog of on site payment for reservations
|
||||
valid_reservation_modal:
|
||||
|
Loading…
x
Reference in New Issue
Block a user