Changeset - bcd9fd777f07
[Not reviewed]
default
0 3 0
Dennis Fink - 3 years ago 2022-02-25 22:44:52
dennis.fink@c3l.lu
Add satispay
3 files changed with 11 insertions and 1 deletions:
0 comments (0 inline, 0 general)
c3l_membership/__init__.py
Show inline comments
 
@@ -31,24 +31,25 @@ def create_app():
 

	
 
    qrcode.init_app(app)
 
    babel.init_app(app)
 

	
 
    _default_secret_key = base64.b64encode(secrets.token_bytes()).decode("utf-8")
 
    app.config["SECRET_KEY"] = os.environ.get("SECRET_KEY", _default_secret_key)
 
    app.config["LANGUAGES"] = ["en", "de", "fr", "lb"]
 

	
 
    app.config.setdefault("SUPPORTING_FEE", 40)
 
    app.config.setdefault("REGULAR_FEE", 120)
 

	
 
    app.config.setdefault("DIGICASH_ENABLED", True)
 
    app.config.setdefault("SATISPAY_ENABLED", True)
 
    app.config.setdefault("CRYPTOCURRENCIES", dict())
 

	
 
    @babel.localeselector
 
    def get_locale():
 
        if not g.get("lang_code", None):
 
            g.lang_code = request.accept_languages.best_match(app.config["LANGUAGES"])
 
        return g.lang_code
 

	
 
    from .views import root_page
 

	
 
    app.register_blueprint(root_page)
 

	
c3l_membership/templates/member.html
Show inline comments
 
@@ -102,24 +102,30 @@
 
          </ul>
 
        </div>
 
        {% set address = config["CRYPTOCURRENCIES"][form.payment.data]["ADDRESS"] %}
 
        {% set crypto_url=config["CRYPTOCURRENCIES"][form.payment.data]["URL"].format(address=address, amount=price, year=year, username=form.username.data) %}
 
        <div><img class="cryptoqrcode" src="{{ qrcode(crypto_url) }}" /></div>
 
      </div>
 
    {% elif form.payment.data == 'digicash' %}
 
      <div class="digicash">
 
        {% set payconiq_url='https://payconiq.com/t/1/62068d4d71445b0006dfbd5d?A={amount}&R=Membership&D={username}'.format(amount=price, username=form.username.data) %}
 
        <div><p>{% trans %}Pay with DigiCash/Payconiq!{% endtrans %}</p></div>
 
        <div><img class="cryptoqrcode" src="{{ qrcode(payconiq_url) }}" /></div>
 
      </div>
 
    {% elif form.payment.data == 'satispay' %}
 
      <div class="digicash">
 
        {% set satispay_url='https://www.satispay.com/app/pay/shops/e5ca1df1-1f72-457e-88a2-7691ab630947?amount={amount}'.format(amount=price) %}
 
        <div><p>{% trans %}Pay with Satispay{% endtrans %}</p></div>
 
        <div><img class="crpytoqrcode" src="{{ qrcode(satispay_url) }}" /></div>
 
      </div>
 
    {% endif %}
 
    <div class="signature">
 
      <p class="membersignature">{% trans %}Luxembourg, the{% endtrans %}</p>
 
      <p class="adminsignature">
 
        {{ _("Signature of your legal representative") if form.minor_member.data else _("Your signature") }}
 
      </p>
 
    </div>
 
    <footer>
 
      <hr />
 
      <b>C</b>haos <b>C</b>omputer <b>C</b>lub <b>L</b>ëtzebuerg A.S.B.L.<br />
 
      Halle Victor Hugo - 60 Avenue Victor Hugo L-1750 Luxembourg (Europe)<br />
 
      info@c3l.lu - <a href="https://c3l.lu">http://c3l.lu</a>
c3l_membership/views.py
Show inline comments
 
@@ -29,24 +29,27 @@ def pull_lang_code(endpoint, values):
 
@root_page.route("/", methods=("GET", "POST"))
 
def index():
 
    form = MembershipForm()
 

	
 
    choices = [
 
        ("cash", gettext("by cash")),
 
        ("wire transfer", gettext("by wire transfer")),
 
    ]
 

	
 
    if current_app.config["DIGICASH_ENABLED"]:
 
        choices.append(("digicash", gettext("by DigiCash/Payconiq")))
 

	
 
    if current_app.config["SATISPAY_ENABLED"]:
 
        choices.append(("satispay", gettext("by Satispay")))
 

	
 
    choices.extend(
 
        (cryptocurrency_label, " ".join((gettext("by"), cryptocurrency_label.title())))
 
        for cryptocurrency_label, options in current_app.config[
 
            "CRYPTOCURRENCIES"
 
        ].items()
 
        if options["ENABLED"]
 
    )
 

	
 
    form.payment.choices = choices
 

	
 
    if form.validate_on_submit():
 

	
 
@@ -75,25 +78,25 @@ def index():
 
                current_conversion_r = requests.get(
 
                    current_app.config["CONVERSION_URL"], timeout=30
 
                )
 
                current_conversion_r.raise_for_status()
 
            except:
 
                return render_template("index.html", form=form, crypto_error=True), 503
 
            else:
 
                current_conversion = current_conversion_r.json()
 
                commodity = current_app.config["CRYPTOCURRENCIES"][form.payment.data][
 
                    "COMMODITY"
 
                ]
 
                price = current_conversion[commodity][status.upper()]
 
        elif form.payment.data == "digicash":
 
        elif form.payment.data in ("digicash", "satispay"):
 
            price = price * 100
 

	
 
        now = date.today()
 
        xml_data = {
 
            "status": status,
 
            "name": form.fullname.data,
 
            "birthday": form.birthday.data
 
            if form.birthday.data is not None
 
            else date(9999, 12, 12),
 
            "username": form.username.data,
 
            "email": form.email.data,
 
            "address": re.sub(
0 comments (0 inline, 0 general)