Skip to content

Commit

Permalink
Fix currency for stripe payments
Browse files Browse the repository at this point in the history
  • Loading branch information
amCap1712 committed Jul 16, 2024
1 parent 3c75a81 commit 661cc31
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions metabrainz/payments/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from flask_babel import lazy_gettext
from wtforms import StringField, BooleanField
from wtforms.fields import RadioField, DecimalField, IntegerField
from wtforms.fields.simple import HiddenField
from wtforms.validators import DataRequired
from metabrainz.payments import Currency

Expand All @@ -27,4 +28,5 @@ class DonationForm(BasePaymentForm):

class PaymentForm(BasePaymentForm):
"""Payment form for organizations."""
currency = HiddenField()
invoice_number = IntegerField(validators=[DataRequired(lazy_gettext("You need to specify invoice number!"))])
8 changes: 7 additions & 1 deletion metabrainz/payments/views.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from __future__ import division
from flask import Blueprint, request, render_template, url_for, redirect, current_app, jsonify
from flask_babel import gettext
from werkzeug.datastructures import MultiDict

from metabrainz.payments import SUPPORTED_CURRENCIES
from metabrainz.model.payment import Payment
from metabrainz.payments.forms import DonationForm, PaymentForm
Expand Down Expand Up @@ -33,7 +35,11 @@ def payment(currency):
currency = currency.lower()
if currency not in SUPPORTED_CURRENCIES:
return redirect('.payment_selector')
return render_template('payments/payment.html', form=PaymentForm(), currency=currency)
return render_template(
'payments/payment.html',
form=PaymentForm(formdata=MultiDict([("currency", currency)])),
currency=currency
)


@payments_bp.route('/donors')
Expand Down

0 comments on commit 661cc31

Please sign in to comment.