KMAIN-582 : BiblioCommons E-Commerce Receipt Screen
authorBill Erickson <berickxx@gmail.com>
Wed, 29 Oct 2014 21:08:39 +0000 (17:08 -0400)
committerBill Erickson <berickxx@gmail.com>
Thu, 21 Mar 2019 19:46:23 +0000 (15:46 -0400)
    Cross-port: 5edb7ab

KCLS/openils/var/templates_kcls/opac/parts/base_fines.tt2
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm

index 2aed579..99b2565 100644 (file)
@@ -9,7 +9,7 @@
         [% END %]
         <link rel="stylesheet" type="text/css" href="[% ctx.media_prefix %]/css/skin/default/opac/semiauto.css" />
         <link rel="stylesheet" type="text/css" href="[% ctx.media_prefix %]/css/skin/default/opac/style.css" />
-        <title>[% l('Catalog - [_1]', ctx.page_title) %]</title>
+        <title>[% l('BiblioCommons E-Commerce - KCLS') %]</title>
         <link rel="unapi-server" type="application/xml" title="unAPI" href="/opac/extras/unapi" />
         [% INCLUDE 'opac/parts/goog_analytics.tt2' %]
     </head>
index 8812e1a..e93d94c 100644 (file)
@@ -214,11 +214,15 @@ sub load {
     return $self->load_myopac_payment_form if $path =~ m|opac/myopac/biblio_main_payment_form|;
     return $self->load_myopac_payments if $path =~ m|opac/myopac/biblio_main_payments|;
     return $self->load_myopac_main if $path =~ m|opac/myopac/biblio_main_fines|;
+    return $self->biblio_load_myopac_pay_init if $path =~ m|opac/myopac/biblio_main_pay_init|;
+    return $self->load_myopac_pay if $path =~ m|opac/myopac/biblio_main_pay|;
     return $self->load_myopac_pay_init if $path =~ m|opac/myopac/main_pay_init|;
     return $self->load_myopac_pay if $path =~ m|opac/myopac/main_pay|;
     return $self->load_myopac_main if $path =~ m|opac/myopac/main|;
     return $self->load_myopac_receipt_email if $path =~ m|opac/myopac/receipt_email|;
+    return $self->load_myopac_receipt_email if $path =~ m|opac/myopac/biblio_receipt_email|;
     return $self->load_myopac_receipt_print if $path =~ m|opac/myopac/receipt_print|;
+    return $self->load_myopac_receipt_print if $path =~ m|opac/myopac/biblio_receipt_print|;
     return $self->load_myopac_update_email if $path =~ m|opac/myopac/update_email|;
     return $self->load_myopac_update_password if $path =~ m|opac/myopac/update_password|;
     return $self->load_myopac_update_username if $path =~ m|opac/myopac/update_username|;
index beb5b65..7280675 100644 (file)
@@ -1895,6 +1895,63 @@ sub load_myopac_pay_init {
     return Apache2::Const::OK;
 }
 
+# 1. caches the form parameters
+# 2. loads the credit card payment "Processing..." page
+sub biblio_load_myopac_pay_init {
+    my $self = shift;
+    my $cache = OpenSRF::Utils::Cache->new('global');
+
+    my @payment_xacts = ($self->cgi->param('xact'), $self->cgi->param('xact_misc'));
+
+    if (!@payment_xacts) {
+        # for consistency with load_myopac_payment_form() and
+        # to preserve backwards compatibility, if no xacts are
+        # selected, assume all (applicable) transactions are wanted.
+        my $stat = $self->prepare_fines(undef, undef, [$self->cgi->param('xact'), $self->cgi->param('xact_misc')]);
+        return $stat if $stat;
+        @payment_xacts =
+            map { $_->{xact}->id } (
+                @{$self->ctx->{fines}->{circulation}},
+                @{$self->ctx->{fines}->{grocery}}
+        );
+    }
+
+    return $self->generic_redirect unless @payment_xacts;
+
+    my $cc_args = {"where_process" => 1};
+
+    $cc_args->{$_} = $self->cgi->param($_) for (qw/
+        number cvv2 expire_year expire_month billing_first
+        billing_last billing_address billing_city billing_state
+        billing_zip
+    /);
+
+    my $cache_args = {
+        cc_args => $cc_args,
+        user => $self->ctx->{user}->id,
+        xacts => \@payment_xacts
+    };
+
+    # generate a temporary cache token and cache the form data
+    my $token = md5_hex($$ . time() . rand());
+    $cache->put_cache($token, $cache_args, 30);
+
+    $logger->info("tpac caching payment info with token $token and xacts [@payment_xacts]");
+
+    # after we render the processing page, we quickly redirect to submit
+    # the actual payment.  The refresh url contains the payment token.
+    # It also contains the list of xact IDs, which allows us to clear the 
+    # cache at the earliest possible time while leaving a trace of which 
+    # transactions we were processing, so the UI can bring the user back
+    # to the payment form w/ the same xacts if the payment fails.
+
+    my $refresh = "1; url=biblio_main_pay/$token?xact=" . pop(@payment_xacts);
+    $refresh .= ";xact=$_" for @payment_xacts;
+    $self->ctx->{refresh} = $refresh;
+
+    return Apache2::Const::OK;
+}
+
 # retrieve the cached CC payment info and send off for processing
 sub load_myopac_pay {
     my $self = shift;