From 661cc314d82dba4846d24e744922b9615b368d1d Mon Sep 17 00:00:00 2001 From: Kartik Ohri Date: Tue, 16 Jul 2024 19:31:56 +0530 Subject: [PATCH] Fix currency for stripe payments --- metabrainz/payments/forms.py | 2 ++ metabrainz/payments/views.py | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/metabrainz/payments/forms.py b/metabrainz/payments/forms.py index d72c7a41..ff78fdc2 100644 --- a/metabrainz/payments/forms.py +++ b/metabrainz/payments/forms.py @@ -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 @@ -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!"))]) diff --git a/metabrainz/payments/views.py b/metabrainz/payments/views.py index 119bcb29..bdc9f15c 100644 --- a/metabrainz/payments/views.py +++ b/metabrainz/payments/views.py @@ -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 @@ -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')