mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-05 01:16:27 +00:00
Autorise le paiement de cotisation directement en ligne (sans passer par le solde)
This commit is contained in:
parent
fdfd562959
commit
7d0f4d34cd
2 changed files with 24 additions and 2 deletions
|
@ -25,11 +25,22 @@ def accept_payment(request, factureid):
|
|||
"""
|
||||
The view called when an online payment has been accepted.
|
||||
"""
|
||||
facture = get_object_or_404(Facture, id=factureid)
|
||||
invoice = get_object_or_404(Facture, id=factureid)
|
||||
messages.success(
|
||||
request,
|
||||
_("The payment of %(amount)s € has been accepted.") % {
|
||||
'amount': facture.prix()
|
||||
'amount': invoice.prix()
|
||||
}
|
||||
)
|
||||
# In case a cotisation was bought, inform the user, the
|
||||
# cotisation time has been extended too
|
||||
if any(purchase.type_cotisation for purchase in invoice.vente_set.all()):
|
||||
messages.success(
|
||||
request,
|
||||
_("The cotisation of %(member_name)s has been \
|
||||
extended to %(end_date)s.") % {
|
||||
'member_name': request.user.pseudo,
|
||||
'end_date': request.user.end_adhesion()
|
||||
}
|
||||
)
|
||||
return redirect(reverse(
|
||||
|
|
|
@ -141,9 +141,14 @@ def new_facture(request, user, userid):
|
|||
'users:profil',
|
||||
kwargs={'userid': userid}
|
||||
))
|
||||
is_online_payment = new_invoice_instance.paiement == (
|
||||
Paiement.objects.get_or_create(
|
||||
moyen='Rechargement en ligne')[0])
|
||||
new_invoice_instance.valid = is_online_payment
|
||||
# Saving the invoice
|
||||
new_invoice_instance.save()
|
||||
|
||||
|
||||
# Building a purchase for each article sold
|
||||
for art_item in articles:
|
||||
if art_item.cleaned_data:
|
||||
|
@ -159,6 +164,12 @@ def new_facture(request, user, userid):
|
|||
)
|
||||
new_purchase.save()
|
||||
|
||||
if is_online_payment:
|
||||
content = online_payment.PAYMENT_SYSTEM[
|
||||
AssoOption.get_cached_value('payment')
|
||||
](invoice, request)
|
||||
return render(request, 'cotisations/payment.html', content)
|
||||
|
||||
# In case a cotisation was bought, inform the user, the
|
||||
# cotisation time has been extended too
|
||||
if any(art_item.cleaned_data['article'].type_cotisation
|
||||
|
|
Loading…
Reference in a new issue