[git] gnupg-doc - branch, preview, updated. 38cbd64694b904bef7dbfae71efb74a49c1c9567

by Werner Koch cvs at cvs.gnupg.org
Tue May 23 09:24:03 CEST 2017


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "The GnuPG website and other docs".

The branch, preview has been updated
       via  38cbd64694b904bef7dbfae71efb74a49c1c9567 (commit)
      from  bf5b003a4fa85770d81501620a6a48a1064eab6a (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 38cbd64694b904bef7dbfae71efb74a49c1c9567
Author: Werner Koch <wk at gnupg.org>
Date:   Tue May 23 09:20:36 2017 +0200

    cgi: Use one function to thank them all.
    
    This factors the thank-you message creation out to a separate function
    so that it can be used by Stripe and Paypal donations.  Now always
    with an "Account-id" (our local account number) where we display a "-"
    for one time donations.

diff --git a/cgi/procdonate.cgi b/cgi/procdonate.cgi
index 144848e..d5a7bfc 100755
--- a/cgi/procdonate.cgi
+++ b/cgi/procdonate.cgi
@@ -344,7 +344,7 @@ sub write_template ($) {
 
 # Call the payment processor daemon.  Takes the command and a
 # reference to a dictionary with the data as input.  On return that
-# disctionary is replaced by the response data.
+# dictionary is replaced by the response data.
 sub payproc ($$)
 {
     my $cmd = shift;
@@ -646,50 +646,32 @@ sub resend_main_page ()
 }
 
 
-# This is called by FIXME
-sub complete_stripe_checkout ()
+# Write a THANKS page.
+sub write_thanks ($)
 {
-    my %data;
-    my %stripe;
+    my $data = shift;
     my $recur;
     my $recur_text = '';
-
-    # fixme: Change the error message to note that the card has not
-    # been charged.  Somehow delete the token
-    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"};
+    my $processor;
+    my $cardno;
+    my $accountid = '-';
+
+    if ( $paytype eq 'cc' ) {
+        $processor = 'Stripe';
+        $cardno = '*' . $$data{"Last4"};
+    } elsif ( $paytype eq 'pp' ) {
+        $processor = 'Paypal';
+        $cardno = '-';
+    } else {
+        $processor = '-';
+        $cardno = '-';
     }
 
-    # Do the checkout.
-    $stripe{"Card-Token"} = $q->param("stripeToken");
-    $stripe{"Currency"} = $data{"Currency"};
-    $stripe{"Amount"} = $data{"Amount"};
-    $stripe{"Desc"} =
-        "GnuPG donation by " . $data{"Name"} . " <" . $data{"Mail"} . ">";
-    $stripe{"Stmt-Desc"} = "GnuPG donation";
-    $stripe{"Email"} = $q->param("stripeEmail");
-    $stripe{"Recur"} = $data{"Recur"};
-    $stripe{"Meta[name]"} = $data{"Name"} unless $data{"Name"} eq 'Anonymous';
-    if ($data{"Mail"} ne $q->param("stripeEmail")) {
-        $stripe{"Meta[mail]"} = $data{"Mail"};
-    }
-    if ($data{"Message"} ne '') {
-        $stripe{"Meta[message]"} = $data{"Message"};
-    }
-    if (not payproc ('CHARGECARD', \%stripe)) {
-        $errorstr =
-            '<p>Error: ' . $stripe{"failure"} . '</p><p>'
-            . $stripe{"failure-mesg"} . '</p>';
-        # Again.
-        write_checkout_page ();
-        return;
+    if ($$data{"account-id"} ne '') {
+        $accountid = $$data{"account-id"};
     }
 
-    # Print thanks
-    $recur = $stripe{"Recur"};
+    $recur = $$data{"Recur"};
     if ( $recur =~ /12/ ) {
         if ($lang eq 'de')    { $recur_text = 'monatlich'; }
         elsif ($lang eq 'fr') { $recur_text = 'Mensuelle'; }
@@ -714,67 +696,111 @@ sub complete_stripe_checkout ()
 
     if ($lang eq 'de') {
         $message = <<EOF;
-Betrag ......: $stripe{"Amount"} $stripe{"Currency"}
+Betrag ......: $$data{"Amount"} $$data{"Currency"}
 Dauerauftrag : $recur_text
-Beschreibung : $stripe{"Desc"}
-Kartennr. ...: *$stripe{"Last4"}
-Dienstleister: Stripe
-Charge-Id ...: $stripe{"Charge-Id"}
-Zeitstempel .: $stripe{"_timestamp"}
-Email .......: $stripe{"Email"}
+Beschreibung : $$data{"Desc"}
+Kartennr. ...: $cardno
+Dienstleister: $processor
+Charge-Id ...: $$data{"Charge-Id"}
+Zeitstempel .: $$data{"_timestamp"}
+Email .......: $$data{"Email"}
+Spender-ID ..: $accountid
 EOF
-        if ($stripe{"account-id"} ne '') {
-            $message = $message . "Spender-ID ..: " . $stripe{"account-id"};
-        }
     } elsif ($lang eq 'fr') {
          $message = <<EOF;
-Montant ....: $stripe{"Amount"} $stripe{"Currency"}
+Montant ....: $$data{"Amount"} $$data{"Currency"}
 Fréquence ..: $recur_text
-Description : $stripe{"Desc"}
-No. carte ..: *$stripe{"Last4"}
-Processeur .: Stripe
-Charge-Id ..: $stripe{"Charge-Id"}
-Date .......: $stripe{"_timestamp"}
-Courriel ...: $stripe{"Email"}
+Description : $$data{"Desc"}
+No. carte ..: $cardno
+Processeur .: $processor
+Charge-Id ..: $$data{"Charge-Id"}
+Date .......: $$data{"_timestamp"}
+Courriel ...: $$data{"Email"}
+Account-Id .: $accountid
 EOF
-        if ($stripe{"account-id"} ne '') {
-            $message = $message . "Account-Id : " . $stripe{"account-id"};
-        }
     } elsif ($lang eq 'ja') {
         $message = <<EOF;
-金額 ......: $stripe{"Amount"} $stripe{"Currency"}
+金額 ......: $$data{"Amount"} $$data{"Currency"}
 毎回?一回? : $recur_text
-説明 ......: $stripe{"Desc"}
-カード番号 : *$stripe{"Last4"}
-決済業者 ..: Stripe
-Charge-Id .: $stripe{"Charge-Id"}
-時刻 ......: $stripe{"_timestamp"}
-メール ....: $stripe{"Email"}
+説明 ......: $$data{"Desc"}
+カード番号 : $cardno
+決済業者 ..: $processor
+Charge-Id .: $$data{"Charge-Id"}
+時刻 ......: $$data{"_timestamp"}
+メール ....: $$data{"Email"}
+Account-Id : $accountid
 EOF
-        if ($stripe{"account-id"} ne '') {
-            $message = $message . "Account-Id : " . $stripe{"account-id"};
-        }
     } else {
          $message = <<EOF;
-Amount ....: $stripe{"Amount"} $stripe{"Currency"}
+Amount ....: $$data{"Amount"} $$data{"Currency"}
 Recurring .: $recur_text
-Desc ......: $stripe{"Desc"}
-Cardno.....: *$stripe{"Last4"}
-Processor .: Stripe
-Charge-Id .: $stripe{"Charge-Id"}
-Timestamp .: $stripe{"_timestamp"}
-Email .....: $stripe{"Email"}
+Desc ......: $$data{"Desc"}
+Cardno.....: $cardno
+Processor .: $processor
+Charge-Id .: $$data{"Charge-Id"}
+Timestamp .: $$data{"_timestamp"}
+Email .....: $$data{"Email"}
+Account-Id : $accountid
 EOF
-        if ($stripe{"account-id"} ne '') {
-            $message = $message . "Account-Id : " . $stripe{"account-id"};
-        }
     }
 
-    if ($stripe{"Live"} eq 'f') {
+    if ($$data{"Live"} eq 'f') {
         $message = $message . "\n!!! TEST TRANSACTION !!!";
     }
 
     write_thanks_page ();
+}
+
+
+# This is called by FIXME
+sub complete_stripe_checkout ()
+{
+    my %data;
+    my %stripe;
+    my $recur;
+    my $recur_text = '';
+
+    # fixme: Change the error message to note that the card has not
+    # been charged.  Somehow delete the token
+    payproc ('SESSION get ' . $sessid, \%data) or fail $data{"ERR_Description"};
+
+    if ( $data{"Paytype"} ne "cc" ) {
+        fail "Invalid paytype for Stripe transaction";
+    }
+    $paytype = $data{"Paytype"};
+
+    # If the session has a lang value use that.
+    if ($data{"lang"} ne '') {
+        $lang = $data{"lang"};
+    }
+
+    # Do the checkout.
+    $stripe{"Card-Token"} = $q->param("stripeToken");
+    $stripe{"Currency"} = $data{"Currency"};
+    $stripe{"Amount"} = $data{"Amount"};
+    $stripe{"Desc"} =
+        "GnuPG donation by " . $data{"Name"} . " <" . $data{"Mail"} . ">";
+    $stripe{"Stmt-Desc"} = "GnuPG donation";
+    $stripe{"Email"} = $q->param("stripeEmail");
+    $stripe{"Recur"} = $data{"Recur"};
+    $stripe{"Meta[name]"} = $data{"Name"} unless $data{"Name"} eq 'Anonymous';
+    if ($data{"Mail"} ne $q->param("stripeEmail")) {
+        $stripe{"Meta[mail]"} = $data{"Mail"};
+    }
+    if ($data{"Message"} ne '') {
+        $stripe{"Meta[message]"} = $data{"Message"};
+    }
+    if (not payproc ('CHARGECARD', \%stripe)) {
+        $errorstr =
+            '<p>Error: ' . $stripe{"failure"} . '</p><p>'
+            . $stripe{"failure-mesg"} . '</p>';
+        # Again.
+        write_checkout_page ();
+        return;
+    }
+
+    # Print thanks
+    write_thanks (\%stripe);
     payproc ('SESSION destroy ' . $sessid, ());
 }
 
@@ -796,9 +822,11 @@ sub get_paypal_approval ()
 
     $request{"Currency"} = $data{"Currency"};
     $request{"Amount"} = $data{"Amount"};
+    $request{"Recur"} = $data{"Recur"};
     $request{"Desc"} =
         "Donation of " . $data{"Amount"} . " " . $data{"Currency"} .
         " to the GnuPG project";
+    $request{"Email"} = $data{"Mail"};
     $request{"Meta[name]"} = $data{"Name"} unless
         $data{"Name"} eq 'Anonymous';
     $request{"Meta[mail]"} = $data{"Mail"};
@@ -914,22 +942,13 @@ sub complete_paypal_checkout ()
         return;
     }
 
-    # Print thanks
-
-    $message = <<EOF;
-Amount ..: $request{"Amount"} $request{"Currency"}
-Desc ....: $data{"Desc"}
-Cardno...: n/a
-Processor: PayPal
-Email ...: $request{"Email"}
-Charge-Id: $request{"Charge-Id"}
-Timestamp: $request{"_timestamp"}
-EOF
-    if ($request{"Live"} eq 'f') {
-        $message = $message . "\n!!! TEST TRANSACTION !!!";
-    }
+    # Copy some values for use by the thanks page.
+    $request{"Desc"} = $data{"Desc"};
+    $request{"Recur"} = $data{"Recur"};
+    $request{"Paytype"} = $data{"Paytype"};
+    $paytype = $data{"Paytype"};
 
-    write_thanks_page ();
+    write_thanks (\%request);
     payproc ('SESSION destroy ' . $sessid, ());
 }
 

-----------------------------------------------------------------------

Summary of changes:
 cgi/procdonate.cgi | 207 +++++++++++++++++++++++++++++------------------------
 1 file changed, 113 insertions(+), 94 deletions(-)


hooks/post-receive
-- 
The GnuPG website and other docs
http://git.gnupg.org




More information about the Gnupg-commits mailing list