cgi: Allow presetting of amount, currency and paytype.
authorWerner Koch <wk@gnupg.org>
Tue, 16 May 2017 16:16:30 +0000 (18:16 +0200)
committerWerner Koch <wk@gnupg.org>
Tue, 16 May 2017 16:16:30 +0000 (18:16 +0200)
cgi/procdonate.cgi
web/donate/donate.org

index 15d1dd9..46fc0dd 100755 (executable)
@@ -1013,6 +1013,7 @@ elsif ($mode eq 'preset') {
     $currency = 'EUR';
     $recur = '12';
     $paytype = 'cc';
+    # First dedicated payment plans.
     if ($q->param('plan') eq '12-5-eur' ) {
         $amount = '5';
     }
@@ -1025,14 +1026,18 @@ elsif ($mode eq 'preset') {
     elsif ($q->param('plan') eq '12-50-eur' ) {
         $amount = '50';
     }
-    elsif ($q->param('plan') eq '12-100-eur' ) {
-        $amount = '100';
-    }
-    elsif ($q->param('plan') eq '12-200-eur' ) {
-        $amount = '200';
-    }
-    elsif ($q->param('plan') eq '12-500-eur' ) {
-        $amount = '500';
+    else {
+        # Then look at arbitrary values
+        # No checking needed.
+        if ($q->param('s_amount') ne '') {
+            $amount = int $q->param('s_amount');
+        }
+        if ($q->param('s_currency') ne '') {
+            $currency = $q->param('s_currency');
+        }
+        if ($q->param('s_paytype') ne '') {
+            $paytype = $q->param('s_paytype');
+        }
     }
 
     write_main_page();
index 05cb3e8..67231c6 100644 (file)
@@ -1,3 +1,4 @@
+#                                                       -*- html -*-
 #+TITLE: GnuPG - Donate
 #+STARTUP: showall
 #+SETUPFILE: "../share/setup.inc"
       <!-- Predefined amounts -->
       <div class="form-group">
         <label for="inputType" class="col-md-2 control-label">
-                                       Amount <!--ERR_AMOUNT-->
-                               </label>
-                               <div class="col-md-3">
-                                       <input type="text" class="form-control"
-                                                                name="amountother" id="amountother" placeholder=""
-                                                                value=""/><!--AMOUNT-->
-                               </div>
-                               <div class="col-md-2">
-                                       <select class="form-control" name="currency" id="currency">
-                                               <option value="EUR" selected="selected"><!--SEL_EUR-->Euro</option>
-                                               <option value="USD" ><!--SEL_USD-->US Dollar</option>
-                                               <option value="GBP" ><!--SEL_GBP-->British Pound</option>
-                                               <option value="JPY" ><!--SEL_JPY-->Yen</option>
-                                       </select>
-                               </div>
-                       </div>
+          Amount <!--ERR_AMOUNT-->
+        </label>
+        <div class="col-md-3">
+          <input type="text" class="form-control"
+                 name="amountother" id="amountother" placeholder=""
+                 value=""/><!--AMOUNT-->
+        </div>
+        <div class="col-md-2">
+          <select class="form-control" name="currency" id="currency">
+            <option value="EUR" selected="selected"><!--SEL_EUR-->Euro</option>
+            <option value="USD" ><!--SEL_USD-->US Dollar</option>
+            <option value="GBP" ><!--SEL_GBP-->British Pound</option>
+            <option value="JPY" ><!--SEL_JPY-->Yen</option>
+          </select>
+        </div>
+      </div>
 
-                       <!-- Custom amounts -->
-                       <div class="form-group">
-                               <div class="col-md-offset-2 col-md-6">
-                                       <div class="btn-group" role="group" aria-label="suggested amounts">
-                                               <a href="https://preview.gnupg.org/cgi-bin/procdonate.cgi?mode=preset;plan=12-500-eur" class="btn btn-default">500&thinsp;€</a>
-                                               <a href="https://preview.gnupg.org/cgi-bin/procdonate.cgi?mode=preset;plan=12-200-eur" class="btn btn-default">200&thinsp;€</a>
-                                               <a href="https://preview.gnupg.org/cgi-bin/procdonate.cgi?mode=preset;plan=12-100-eur" class="btn btn-default">100&thinsp;€</a>
-                                               <a href="https://preview.gnupg.org/cgi-bin/procdonate.cgi?mode=preset;plan=12-50-eur" class="btn btn-default">50&thinsp;€</a>
-                                               <a href="https://preview.gnupg.org/cgi-bin/procdonate.cgi?mode=preset;plan=12-20-eur" class="btn btn-default">20&thinsp;€</a>
-                                               <a href="https://preview.gnupg.org/cgi-bin/procdonate.cgi?mode=preset;plan=12-10-eur" class="btn btn-default">10&thinsp;€</a>
-                                               <a href="https://preview.gnupg.org/cgi-bin/procdonate.cgi?mode=preset;plan=12-5-eur" class="btn btn-default">5&thinsp;€</a>
-                                       </div>
-                                       <span class="help-block">
-                                               Suggested amounts.
-                                       </span>
-                               </div>
-                       </div>
+      <!-- Custom amounts -->
+      <div class="form-group">
+        <div class="col-md-offset-2 col-md-6">
+          <div class="btn-group" role="group" aria-label="suggested amounts">
+            <a href="/cgi-bin/procdonate.cgi?mode=preset&s_amount=500"
+               class="btn btn-default">500&#x202f;€</a>
+            <a href="/cgi-bin/procdonate.cgi?mode=preset&s_amount=200"
+               class="btn btn-default">200&#x202f;€</a>
+            <a href="/cgi-bin/procdonate.cgi?mode=preset&s_amount=100"
+               class="btn btn-default">100&#x202f;€</a>
+            <a href="/cgi-bin/procdonate.cgi?mode=preset&s_amount=50"
+               class="btn btn-default">50&#x202f;€</a>
+            <a href="/cgi-bin/procdonate.cgi?mode=preset&s_amount=20"
+               class="btn btn-default">20&#x202f;€</a>
+            <a href="/cgi-bin/procdonate.cgi?mode=preset&s_amount=10"
+               class="btn btn-default">10&#x202f;€</a>
+            <a href="/cgi-bin/procdonate.cgi?mode=preset&s_amount=5"
+               class="btn btn-default">5&#x202f;€</a>
+          </div>
+          <span class="help-block">
+            Suggested amounts.
+          </span>
+        </div>
+      </div>
 
       <!-- Recurring -->
       <div class="form-group">
       <!-- Pay using -->
       <div class="form-group">
         <label for="paytype" class="col-md-2 control-label">
-                                       Pay using <!--ERR_PAYTYPE-->
-                               </label>
+          Pay using <!--ERR_PAYTYPE-->
+        </label>
         <div class="col-md-6">
           <div class="radio">
             <label>