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|;
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;