cgi: Allow returning to the donation form after a paypal cancel
authorWerner Koch <wk@gnupg.org>
Tue, 30 May 2017 07:14:01 +0000 (09:14 +0200)
committerWerner Koch <wk@gnupg.org>
Tue, 30 May 2017 07:14:01 +0000 (09:14 +0200)
Also added a German Cancel page.  Needs the latest payproc to work.

cgi/procdonate.cgi
web/donate/paypal-can.de.org [new file with mode: 0644]
web/donate/paypal-can.ja.org
web/donate/paypal-can.org

index 7dae23d..4f617a7 100755 (executable)
@@ -865,6 +865,47 @@ sub get_paypal_approval ()
 }
 
 
+# The is called by paypal after the user hit cancel.  We need to
+# extract the alias to get back the session data.
+sub cancel_paypal_checkout ()
+{
+    my $aliasid;
+    my $payerid;
+    my %data;
+
+    $aliasid = $q->param("aliasid");
+
+    # Get the session from the alias.
+    payproc ('SESSION sessid ' . $aliasid, \%data)
+        or fail $data{"ERR_Description"};
+    $sessid = $data{"_SESSID"};
+    payproc ('SESSION get ' . $sessid, \%data)
+        or fail $data{"ERR_Description"};
+
+    # If the session has a lang value use that.
+    if ($data{"lang"} ne '') {
+        $lang = $data{"lang"};
+    }
+
+    if ( $data{"Paytype"} ne "pp" ) {
+        fail "Invalid paytype for Paypal transaction";
+    }
+
+    # Set vars for the checkout page.
+    $amount = $data{"Amount"};
+    $currency = $data{"Currency"};
+    $paytype = $data{"Paytype"};
+    $stripeamount = $data{"Stripeamount"};
+    $euroamount = $data{"Euroamount"};
+    $recur = $data{"Recur"};
+    $name = $data{"Name"};
+    $mail = $data{"Mail"};
+    $message = $data{"Message"};
+
+    write_cancel_page ();
+}
+
+
 # The is called by paypal after approval.  We need to extract the alias
 # and the payerid and store it in the session.  Then we ask to confirm
 # the payment.
@@ -1090,8 +1131,10 @@ elsif ($mode eq 'checkout-stripe') {
     complete_stripe_checkout();
 }
 elsif ($mode eq 'cancel-paypal') {
-    # Fixme: Destroy the alias of the session.
-    write_cancel_page();
+    # Paypal transaction has been canceled by Paypal or the user.
+    # Show the cancel page which has a button to return to the
+    # main donation page.
+    cancel_paypal_checkout();
 }
 elsif ($mode eq 'confirm-paypal') {
     # We have approval from Paypal - show the confirm checkout page.
diff --git a/web/donate/paypal-can.de.org b/web/donate/paypal-can.de.org
new file mode 100644 (file)
index 0000000..b5953b3
--- /dev/null
@@ -0,0 +1,89 @@
+#                                                    -*- html -*-
+#+TITLE: GnuPG - Spenden - Appruch Paypal Zahlung
+#+STARTUP: showall
+#+SETUPFILE: "../share/setup.inc"
+
+#+BEGIN_HTML
+<!--custom-page-->  <!-- this disables all standard processing. -->
+<!--html-->
+  <!--head-->
+    <!-- bootstrap core and site css -->
+    <link href="/share/3rdparty/bootstrap/bootstrap-gnupg.css" rel="stylesheet">
+    <link href="/share/campaign/campaign.css" rel="stylesheet">
+
+    <script defer src="/share/3rdparty/jquery/jquery.min.js"></script>
+    <script defer src="/share/3rdparty/bootstrap/bootstrap.min.js"></script>
+  </head>
+  <body lang="de">
+    <!-- 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="/share/gnupg-lock-white-250x250.png">
+        </div>
+
+        <div id="navbar" class="navbar-collapse collapse">
+          <ul class="nav navbar-nav">
+            <li><a href="/">Home</a></li>
+          </ul>
+        </div><!--/.nav-collapse -->
+      </div>
+    </nav>
+
+    <div class="camp-gutter container">
+      <div class="row">
+        <div class="col-md-7 col-md-offset-2">
+          <h2>Cancelled</h2>
+          <p>
+          Sie haben den Spendenzahlung abgebrochen oder ein
+          Dauerauftrag ist mittels Ihres Paypal Kontos nicht möglich.
+          </p>
+        </div>
+      </div>
+
+      <div class="row">
+        <div class="col-sm-5 col-md-offset-2">
+          <p>
+            <form action="/cgi-bin/procdonate.cgi" method="POST"
+                  class="form-inline">
+              <input type="hidden" name="mode" value="re-main" />
+              <input type="hidden" name="sessid" value="<!--SESSID-->" />
+              <input type="hidden" name="lang" value="<!--LANG-->" />
+              <input type="submit" class="btn btn-default btn-sm"
+                     value="Zurück" />
+            </form>
+          </p>
+        </div>
+      </div>
+    </div>
+
+    <div class="camp-gutter container-fluid" id="camp-footer">
+      <div class="container">
+        <div class="row">
+          <div id="cpyright">
+            <a rel="license" href="https://creativecommons.org/licenses/by-sa/3.0/">
+              <img alt="CC-BY-SA 4.0" style="border: 0"
+                    src="/share/cc-by-sa_80x15.png"/></a>&nbsp;
+            This web page is
+            Copyright 2017 The GnuPG Project and licensed under a
+            <a rel="license" href="https://creativecommons.org/licenses/by-sa/4.0/">
+            Creative Commons Attribution-ShareAlike 4.0 International License</a>.  See
+            <a href="/copying.html">copying</a> for details.
+          </div>
+        </div>
+      </div>
+    </div>
+
+  </body>
+</html>
+#+END_HTML
index 452ff77..75be564 100644 (file)
       <div class="row">
         <div class="col-sm-5 col-md-offset-2">
           <p>
-            <a class="btn btn-default btn-sm" href="/donate">戻る</a>
+            <form action="/cgi-bin/procdonate.cgi" method="POST"
+                  class="form-inline">
+              <input type="hidden" name="mode" value="re-main" />
+              <input type="hidden" name="sessid" value="<!--SESSID-->" />
+              <input type="hidden" name="lang" value="<!--LANG-->" />
+              <input type="submit" class="btn btn-default btn-sm"
+                     value="戻る" />
+            </form>
           </p>
         </div>
       </div>
index 78d4740..c867fef 100644 (file)
@@ -45,7 +45,8 @@
         <div class="col-md-7 col-md-offset-2">
           <h2>Cancelled</h2>
           <p>
-          You cancelled the donation process.
+          You cancelled the donation process or a recurring donation
+          was not possible using your Paypal account.
           </p>
         </div>
       </div>
       <div class="row">
         <div class="col-sm-5 col-md-offset-2">
           <p>
-            <a class="btn btn-default btn-sm" href="/donate">Back</a>
+            <form action="/cgi-bin/procdonate.cgi" method="POST"
+                  class="form-inline">
+              <input type="hidden" name="mode" value="re-main" />
+              <input type="hidden" name="sessid" value="<!--SESSID-->" />
+              <input type="hidden" name="lang" value="<!--LANG-->" />
+              <input type="submit" class="btn btn-default btn-sm"
+                     value="Back" />
+            </form>
           </p>
         </div>
       </div>