cgi: Make the donation page work with the CGI.
authorWerner Koch <wk@gnupg.org>
Wed, 10 May 2017 13:56:13 +0000 (15:56 +0200)
committerWerner Koch <wk@gnupg.org>
Wed, 10 May 2017 13:56:13 +0000 (15:56 +0200)
cgi/procdonate.cgi
web/donate/donate.org

index c0894af..9a54627 100755 (executable)
@@ -64,7 +64,7 @@ sub complete_sepa ();
 #   <input value="foo"/>
 # assuming that the value of FOO is foo. Note that this substitution
 # rules work for all tags and thus you better take care to add an
-# extra space if if do not want this to happen.
+# extra space if you do not want this to happen.
 sub write_template ($) {
     my $fname = shift;
 
@@ -82,9 +82,11 @@ sub write_template ($) {
     my $recur_month = '';
     my $recur_quarter = '';
     my $recur_year = '';
+    my $recur_text = '';
     my $message_fmt;
     my $publishname;
     my $check_paytype = 'none';
+    my $stripe_data_email = '';
 
     # Avoid broken HTML attributes.
     $amount =~ s/\x22/\x27/g;
@@ -123,16 +125,28 @@ sub write_template ($) {
         $sel_jpy = ' selected="selected"';
     }
 
+    # For non-recurring Stripe donations we do not want to send a
+    #     data-email="$mail"
+    # line to Stripe so to enable the user to use a a different mail
+    # address for use with them.  This is implemented using a
+    # STRIPE_DATA_EMAIL template variable.
+    $stripe_data_email = 'data-email="' . $mail . '"';
     if ( $recur =~ /0/ ) {
+        $stripe_data_email = '';
         $recur_none    = ' selected="selected"';
+        $recur_text    = '';
     } elsif ( $recur =~ /12/ ) {
         $recur_month   = ' selected="selected"';
+        $recur_text    = 'monthly';
     } elsif ( $recur =~ /4/ ) {
         $recur_quarter = ' selected="selected"';
+        $recur_text    = 'quarterly';
     } elsif ( $recur =~ /1/ ) {
         $recur_year    = ' selected="selected"';
+        $recur_text    = 'yearly';
     }
 
+
     if ( $paytype eq "cc" ) {
         $check_paytype = "CC";
     } elsif ( $paytype eq "pp" ) {
@@ -192,6 +206,8 @@ sub write_template ($) {
             || s/(<selected=\x22selected\x22)?><!--RECUR_MONTH-->/$recur_month>/
             || s/(<selected=\x22selected\x22)?><!--RECUR_QUARTER-->/$recur_quarter>/
             || s/(<selected=\x22selected\x22)?><!--RECUR_YEAR-->/$recur_year>/
+            || s/<!--RECUR_TEXT-->/$recur_text/
+            || s/<!--STRIPE_DATA_EMAIL-->/$stripe_data_email/
             || s/<!--PUBLISH_NAME-->/$publishname/
             || s/<!--SEPA_REF-->/$separef/
             || s/<!--ERRORSTR-->/$errorstr/
@@ -430,6 +446,7 @@ sub check_donation ()
     # Now create a session.
     $data{"Stripeamount"} = $stripeamount;
     $data{"Euroamount"} = $euroamount;
+    $data{"Recur"} = $recur;
     $data{"Name"} = $name;
     $data{"Mail"} = $mail;
     $data{"Message"} = $message;
@@ -487,6 +504,7 @@ sub complete_stripe_checkout ()
         "GnuPG donation by " . $data{"Name"} . " <" . $data{"Mail"} . ">";
     $stripe{"Stmt-Desc"} = "GnuPG donation";
     $stripe{"Email"} = $q->param("stripeEmail");
+    $stripe{"Recur"} = $q->param("Recur");
     $stripe{"Meta[name]"} = $data{"Name"} unless $data{"Name"} eq 'Anonymous';
     if ($data{"Mail"} ne $q->param("stripeEmail")) {
         $stripe{"Meta[mail]"} = $data{"Mail"};
@@ -507,6 +525,7 @@ sub complete_stripe_checkout ()
 
     $message = <<EOF;
 Amount ..: $stripe{"Amount"} $stripe{"Currency"}
+Recurring: $stripe{"Recur"}
 Desc ....: $stripe{"Desc"}
 Cardno...: *$stripe{"Last4"}
 Processor: Stripe
@@ -610,6 +629,7 @@ sub confirm_paypal_checkout ()
     $paytype = $data{"Paytype"};
     $stripeamount = $data{"Stripeamount"};
     $euroamount = $data{"Euroamount"};
+    $recur = $data{"Recur"};
     $name = $data{"Name"};
     $mail = $data{"Mail"};
     $message = $data{"Message"};
@@ -698,6 +718,7 @@ sub complete_sepa ()
     $paytype = $data{"Paytype"};
     $stripeamount = $data{"Stripeamount"};
     $euroamount = $data{"Euroamount"};
+    $recur = $data{"Recur"};
     $name = $data{"Name"};
     $mail = $data{"Mail"};
     $message = $data{"Message"};
index 1222b08..754e9e5 100644 (file)
 <link rel="stylesheet" href="/share/site.css" type="text/css" />
 </head>
 <body lang="en">
-       <!-- Fixed navbar -->
-       <nav class="navbar navbar-default navbar-fixed-top">
-               <div class="container">
-
-                       <div class="navbar-header">
-                               <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
-                                       <span class="sr-only">Toggle navigation</span>
-                                       <span class="icon-bar"></span>
-                                       <span class="icon-bar"></span>
-                                       <span class="icon-bar"></span>
-                               </button>
-                               <img class="navbar-brand" alt="GnuPG" src="gnupg-white-plain.png">
-                       </div>
-
-                       <div id="navbar" class="navbar-collapse collapse">
-                               <ul class="nav navbar-nav">
-                                       <li><a href="/">Back</a></li>
-                               </ul>
-                       </div><!--/.nav-collapse -->
-               </div>
-       </nav>
-
-       <div class="camp-gutter container">
-               <div class="row">
-                       <div class="col-md-8 col-md-offset-2">
-                               <h1>Support GnuPG</h1>
-                               <p>To process your donation we need to collect some information. This information is only used for the purpose of the donation and no data will ever be send to any entity not directly involved in the donation process. Not giving a name makes the donation “anonymous” in that the name won’t be listed on the public thank you page.</p>
-                               <p>You can also send us <b>Bitcoin<span class="glyphicon glyphicon-btc" aria-hidden="true"></span></b>. Our address is <a href="bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W"><small><tt>175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W</tt></small></a>.</p>
-                       </div>
-               </div>
-               <form class="form-horizontal" role="form" action="https://preview.gnupg.org/cgi-bin/procdonate.cgi" method="POST">
-                       <input type="hidden" name="mode" value="main">
-
-                       <!-- Predefined amounts -->
-                       <div class="form-group">
-                               <label for="inputType" class="col-md-2 control-label">Amount</label>
-                               <div class="col-md-6">
-                                       <label class="radio-inline">
-                                               <input type="radio" name="amount" id="amount500" value="500"> 500€
-                                       </label>
-
-                                       <label class="radio-inline">
-                                               <input type="radio" name="amount" id="amount200" value="200"> 200€
-                                       </label>
-
-                                       <label class="radio-inline">
-                                               <input type="radio" name="amount" id="amount100" value="100"> 100€
-                                       </label>
-
-                                       <label class="radio-inline">
-                                               <input type="radio" name="amount" id="amount50" value="50"> 50€
-                                       </label>
-
-                                       <label class="radio-inline">
-                                               <input type="radio" name="amount" id="amount20" value="20"> 20€
-                                       </label>
-
-                                       <label class="radio-inline">
-                                               <input type="radio" name="amount" id="amount10" value="10"> 10€
-                                       </label>
-
-                                       <label class="radio-inline">
-                                               <input type="radio" name="amount" id="amount5" value="5"> 5€
-                                       </label>
-                               </div>
-                       </div>
-
-                       <!-- Custom amounts -->
-                       <div class="form-group">
-                               <div class="col-md-offset-2 col-md-6">
-                                       <div class="form-group row">
-                                               <div class="col-md-2">
-                                                       <div class="radio">
-                                                               <label for="amount_radio_other">
-                                                                       <input type="radio" id="amount_radio_other" name="amount" value="other" checked="checked">
-                                                                       other
-                                                               </label>
-                                                       </div>
-                                               </div>
-                                               <div class="col-md-4">
-                                                       <input type="text" class="form-control" name="amountother" id="amountother" placeholder="">
-                                               </div>
-                                               <div class="col-md-4">
-                                                       <select class="form-control" name="currency" id="currency">
-                                                               <option value="EUR">Euro</option>
-                                                               <option value="USD">US Dollar</option>
-                                                               <option value="GBP">British Pound</option>
-                                                               <option value="JPY">Yen</option>
-                                                       </select>
-                                               </div>
-                                       </div>
-                                       <span class="help-block">Choosing “other” allows to donate in other currencies.</span>
-                               </div>
-                       </div>
-
-                       <!-- Recurring -->
-                       <div class="form-group">
-                               <label for="inputType" class="col-md-2 control-label">Recurring</label>
-                               <div class="col-md-2">
-                                       <select class="form-control">
-                                               <option>Just once</option>
-                                               <option>Monthly</option>
-                                               <option>Quaterly</option>
-                                               <option>Yearly</option>
-                                       </select>
-                               </div>
-                       </div>
-
-                       <!-- Pay using -->
-                       <div class="form-group">
-                               <label for="inputType" class="col-md-2 control-label">Pay using</label>
-                               <div class="col-md-6">
-                                       <div class="radio">
-                                               <label>
-                                                       <input type="radio" name="paytype" id="cc" value="cc" checked>
-                                                       Credit Card
-                                               </label>
-                                       </div>
-                                       <div class="radio">
-                                               <label>
-                                                       <input type="radio" name="paytype" id="pp" value="pp">
-                                                       PayPal
-                                               </label>
-                                       </div>
-                                       <div class="radio">
-                                               <label>
-                                                       <input type="radio" name="paytype" id="se" value="se">
-                                                       SEPA (European bank transfer)
-                                               </label>
-                                       </div>
-                               </div>
-                       </div>
-
-                       <!-- Name -->
-                       <div class="form-group">
-                               <label for="inputType" class="col-md-2 control-label">
-                                       Name
-                                       <p class="text-muted"><small>(optional)</small></p>
-                               </label>
-                               <div class="col-md-6">
-                                       <input type="text" class="form-control" name="name" id="f_name" placeholder="Name (optional)">
-                                       <span class="help-block">
-                                               If you want to be listed on the <a href="https://gnupg.org/donate/kudos.html">list of donors</a>, please enter your name as it shall appear there.
-                                       </span>
-                               </div>
-                       </div>
-
-                       <!-- Email -->
-                       <div class="form-group">
-                               <label for="inputType" class="col-md-2 control-label">
-                                       Email
-                                       <p class="text-muted"><small>(optional)</small></p>
-                               </label>
-                               <div class="col-md-6">
-                                       <input type="email" class="form-control" name="mail" id="f_mail" placeholder="Email (optional)">
-                                       <span class="help-block">
-                                               In case of payment problems we may want to contact you, thus please enter your e-mail address.
-                                       </span>
-                               </div>
-                       </div>
-
-                       <!-- Message -->
-                       <div class="form-group">
-                               <label for="inputType" class="col-md-2 control-label">
-                                       Message
-                                       <p class="text-muted"><small>(optional)</small></p>
-                               </label>
-                               <div class="col-md-6">
-                                       <textarea class="form-control" name="message" id="f_message" rows="4"></textarea>
-                                       <span class="help-block">
-                                               If you want to leave a message for us, please enter it here.
-                                       </span>
-                               </div>
-                       </div>
-                       <div class="row">
-                               <div class="col-md-offset-2">
-                                       <button type="submit" class="btn btn-primary btn-large">Proceed to checkout</button>
-                               </div>
-                       </div>
-               </form>
-       </div>
+  <!-- Fixed navbar -->
+  <nav class="navbar navbar-default navbar-fixed-top">
+    <div class="container">
+
+      <div class="navbar-header">
+        <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
+          <span class="sr-only">Toggle navigation</span>
+          <span class="icon-bar"></span>
+          <span class="icon-bar"></span>
+          <span class="icon-bar"></span>
+        </button>
+        <img class="navbar-brand" alt="GnuPG" src="gnupg-white-plain.png">
+      </div>
+
+      <div id="navbar" class="navbar-collapse collapse">
+        <ul class="nav navbar-nav">
+          <li><a href="/">Back</a></li>
+        </ul>
+      </div><!--/.nav-collapse -->
+    </div>
+  </nav>
+
+  <div class="camp-gutter container">
+    <div class="row">
+      <div class="col-md-8 col-md-offset-2">
+        <h1>Support GnuPG</h1>
+        <p>To process your donation we need to collect some information. This information is only used for the purpose of the donation and no data will ever be send to any entity not directly involved in the donation process. Not giving a name makes the donation “anonymous” in that the name won’t be listed on the public thank you page.</p>
+        <p>You can also send us <b>Bitcoin<span class="glyphicon glyphicon-btc" aria-hidden="true"></span></b>. Our address is <a href="bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W"><small><tt>175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W</tt></small></a>.</p>
+      </div>
+    </div>
+
+    <!--ERRORPANEL-->
+
+    <form class="form-horizontal" role="form"
+          action="/cgi-bin/procdonate.cgi" method="POST">
+      <input type="hidden" name="mode" value="main">
+
+      <!-- Predefined amounts -->
+      <div class="form-group">
+        <label for="inputType" class="col-md-2 control-label">Amount</label>
+        <div class="col-md-6">
+          <label class="radio-inline">
+            <input type="radio" name="amount" id="amount500" value="500"> 500€
+          </label>
+
+          <label class="radio-inline">
+            <input type="radio" name="amount" id="amount200" value="200"> 200€
+          </label>
+
+          <label class="radio-inline">
+            <input type="radio" name="amount" id="amount100" value="100"> 100€
+          </label>
+
+          <label class="radio-inline">
+            <input type="radio" name="amount" id="amount50" value="50"> 50€
+          </label>
+
+          <label class="radio-inline">
+            <input type="radio" name="amount" id="amount20" value="20"> 20€
+          </label>
+
+          <label class="radio-inline">
+            <input type="radio" name="amount" id="amount10" value="10"> 10€
+          </label>
+
+          <label class="radio-inline">
+            <input type="radio" name="amount" id="amount5" value="5"> 5€
+          </label>
+        </div>
+      </div>
+
+      <!-- Custom amounts -->
+      <div class="form-group">
+        <div class="col-md-offset-2 col-md-6">
+          <div class="form-group row">
+            <div class="col-md-2">
+              <div class="radio">
+                <label for="amount_radio_other">
+                  <input type="radio" id="amount_radio_other" name="amount"
+                         value="other" /><!--CHECKOTHER-->
+                  other
+                </label>
+              </div>
+            </div>
+            <div class="col-md-4">
+              <input type="text" class="form-control"
+                     name="amountother" id="amountother" placeholder=""
+                     value=""/><!--AMOUNT-->
+            </div>
+            <div class="col-md-4">
+              <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>
+              <!--ERR_AMOUNT-->
+            </div>
+          </div>
+          <span class="help-block">Choosing “other” allows to donate
+                in other currencies.</span>
+        </div>
+      </div>
+
+      <!-- Recurring -->
+      <div class="form-group">
+        <label for="inputType" class="col-md-2 control-label">Recurring</label>
+        <div class="col-md-2">
+          <select class="form-control">
+            <option value="0"
+            selected="selected"><!--RECUR_NONE-->Just once</option>
+            <option value="12" ><!--RECUR_MONTH-->Monthly</option>
+            <option value="4" ><!--RECUR_QUARTER-->Quarterly</option>
+            <option value="1" ><!--RECUR_YEAR-->Yearly</option>
+          </select>
+        </div>
+      </div>
+
+      <!-- Pay using -->
+      <div class="form-group">
+        <label for="inputType" class="col-md-2 control-label">Pay using</label>
+        <div class="col-md-6">
+          <div class="radio">
+            <label>
+              <input type="radio" name="paytype" id="cc"
+                     value="cc" /><!--CHECK_CC-->
+              Credit Card
+            </label>
+            <!--ERR_PAYTYPE-->
+          </div>
+          <div class="radio">
+            <label>
+              <input type="radio" name="paytype" id="pp"
+                     value="pp" /><!--CHECK_PP-->
+              PayPal
+            </label>
+          </div>
+          <div class="radio">
+            <label>
+              <input type="radio" name="paytype" id="se"
+                     value="se" /><!--CHECK_SE-->
+              SEPA (European bank transfer)
+            </label>
+          </div>
+        </div>
+      </div>
+
+      <!-- Name -->
+      <div class="form-group">
+        <label for="inputType" class="col-md-2 control-label">
+          Name
+          <p class="text-muted"><small>(optional)</small></p>
+        </label>
+        <div class="col-md-6">
+          <input type="text" class="form-control" name="name"
+                 id="f_name" placeholder="Name (optional)"
+                 value=""/><!--NAME-->
+          <!--ERR_NAME-->
+          <span class="help-block">
+            If you want to be listed on the
+             <a href="https://www.gnupg.org/donate/kudos.html"
+                >list of donors</a>, please enter your name as
+             it shall appear there.
+          </span>
+        </div>
+      </div>
+
+      <!-- Email -->
+      <div class="form-group">
+        <label for="inputType" class="col-md-2 control-label">
+          Email
+          <p class="text-muted"><small>(optional)</small></p>
+        </label>
+        <div class="col-md-6">
+          <input type="email" class="form-control" name="mail"
+                 id="f_mail" placeholder="Email (optional)"
+                 value=""/><!--MAIL-->
+           <!--ERR_MAIL-->
+          <span class="help-block">
+            In case of payment problems we may want to contact you,
+            thus please enter your e-mail address.
+          </span>
+        </div>
+      </div>
+
+      <!-- Message -->
+      <div class="form-group">
+        <label for="inputType" class="col-md-2 control-label">
+          Message
+          <p class="text-muted"><small>(optional)</small></p>
+        </label>
+        <div class="col-md-6">
+          <textarea class="form-control" name="message" id="f_message"
+                    rows="4"
+                    ></textarea><!--MESSAGE-->
+          <span class="help-block">
+            If you want to leave a message for us, please enter it here.
+          </span>
+        </div>
+      </div>
+      <div class="row">
+        <div class="col-md-offset-2">
+          <button type="submit" class="btn btn-primary btn-large"
+                  >Proceed to checkout</button>
+        </div>
+      </div>
+    </form>
+  </div>
 </body>
 #+END_HTML
-#  <!--ERRORPANEL-->
-#
-#  <form action="/cgi-bin/procdonate.cgi" method="post" class="inputpanel">
-#   <input type="hidden" name="mode" value="main">
-#   <p class="ii">Keep this field clear:
-#                 <input type="text" size="40" name="url"></p>
-#   <table border="0" cellpadding="0" cellspacing="4">
-#    <tr>
-#      <td></td>
-#      <td>How much do you want to donate?<br/>
-#          <span class="smallnote">(choosing “other” allows
-#          to donate in other currencies)</span></td>
-#    </tr>
-#    <tr>
-#      <td align="right">Amount:</td>
-#      <td>
-#          <label><input type="radio" name="amount" value="500"/>500 EUR</label>
-#          <label><input type="radio" name="amount" value="200"/>200 EUR</label>
-#          <label><input type="radio" name="amount" value="100"/>100 EUR</label>
-#          <label><input type="radio" name="amount" value="50"/>50 EUR</label>
-#          <label><input type="radio" name="amount" value="20"/>20 EUR</label>
-#          <label><input type="radio" name="amount" value="5"/>5 EUR</label>
-#      </td>
-#    </tr>
-#    <tr>
-#      <td></td>
-#      <td>
-#          <input type="radio" name="amount"
-#                              value="other"/><!--CHECKOTHER-->other:
-#          <input type="text"  size="6" name="amountother"
-#                              value=""/><!--AMOUNT-->
-#          <select name="currency" size="1">
-#            <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>
-#          <!--ERR_AMOUNT-->
-#      </td>
-#    </tr>
-#    <tr>
-#      <td align="right">Recurring:</td>
-#      <td>
-#          <select name="recur" size="1">
-#            <option value="0"
-#            selected="selected"><!--RECUR_NONE-->Just once</option>
-#            <option value="12" ><!--RECUR_MONTH-->Monthly</option>
-#            <option value="4" ><!--RECUR_QUARTER-->Quarterly</option>
-#            <option value="1" ><!--RECUR_YEAR-->Yearly</option>
-#          </select>
-#      </td>
-#    </tr>
-#   <tr><td>&nbsp;</td></tr>
-#    <tr>
-#      <td align="right">Pay&nbsp;using:</td>
-#      <td>
-#        <label><input type="radio" name="paytype"
-#                      value="cc" /><!--CHECK_CC-->Credit Card</label>
-#        <!--ERR_PAYTYPE-->
-#      </td>
-#   </tr>
-#   <tr>
-#     <td></td>
-#     <td>
-#       <label><input type="radio" name="paytype"
-#                     value="pp" /><!--CHECK_PP-->PayPal</label>
-#     </td>
-#   </tr>
-#   <tr>
-#     <td></td>
-#     <td>
-#       <label><input type="radio" name="paytype"
-#                     value="se" /><!--CHECK_SE-->SEPA (European bank transfer)</label>
-#     </td>
-#   </tr>
-#   <tr><td>&nbsp;</td></tr>
-#   <tr>
-#      <td></td>
-#      <td>
-#          If you want to be listed on the
-#          <a href="/donate/kudos.html">list of donors</a>,
-#          please enter your name as it shall appear there.
-#      </td>
-#    </tr>
-#    <tr>
-#      <td align="right"><label for="f_name">Name:</label></td>
-#      <td>
-#          <input id="f_name" type="text"
-#                 size="40" style="width:200px" name="name"
-#                 value=""/><!--NAME--> (optional)
-#          <!--ERR_NAME-->
-#      </td>
-#    </tr>
-#    <tr>
-#      <td></td>
-#      <td>
-#          In case of payment problems we may want to contact you, thus please
-#          enter your e-mail address.
-#      </td>
-#    </tr>
-#    <tr>
-#      <td align="right"><label for="f_mail">E-mail:</label></td>
-#      <td>
-#          <input id="f_mail" type="text" size="40" style="width:200px"
-#                 name="mail"
-#                 value=""/><!--MAIL--> (optional)
-#           <!--ERR_MAIL-->
-#      </td>
-#    </tr>
-#    <tr>
-#      <td></td>
-#      <td>
-#          If you want to leave a message for us, please enter it here:
-#      </td>
-#    </tr>
-#    <tr>
-#      <td></td>
-#      <td>
-#          <textarea cols="40" rows="4" style="width:500px" name="message"
-#                    ></textarea><!--MESSAGE-->
-#      </td>
-#    </tr>
-#    <tr>
-#      <td></td>
-#      <td>
-#        <div class="buttonbox">
-#          <input type="submit" class="donate-button-low"
-#                 value="Proceed to checkout" />
-#         </div>
-#      </td>
-#    </tr>
-#   </table>
-#  </form>
-#
-#
-#</body>
-#</html>
-# eof #