return $self->load_place_hold if $path =~ m|opac/place_hold|;
return $self->load_myopac_holds if $path =~ m|opac/myopac/holds|;
return $self->load_myopac_circs if $path =~ m|opac/myopac/circs|;
- return $self->load_myopac_pay if $path =~ m|opac/myopac/pay|;
return $self->load_myopac_payment_form if $path =~ m|opac/myopac/main_payment_form|;
return $self->load_myopac_payments if $path =~ m|opac/myopac/main_payments|;
+ 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_update_email if $path =~ m|opac/myopac/update_email|;
return $self->load_myopac_update_password if $path =~ m|opac/myopac/update_password|;
use OpenILS::Utils::Fieldmapper;
use OpenILS::Application::AppUtils;
use OpenSRF::Utils::JSON;
+#use Data::Dumper;
+#$Data::Dumper::Indent = 0;
my $U = 'OpenILS::Application::AppUtils';
sub prepare_extended_user_info {
my $self = shift;
my $r;
- $r = $self->prepare_fines and return $r;
+ $r = $self->prepare_fines(undef, undef, [$self->cgi->param('xact')]) and
+ return $r;
# balance_owed is computed specifically from the fines we're trying
# to pay in this case.
- return Apache2::Const::HTTP_INTERNAL_SERVER_ERROR if
- $self->ctx->{fines}->{balance_owed} <= 0;
+ if ($self->ctx->{fines}->{balance_owed} <= 0) {
+ $self->apache->log->info(
+ sprintf("Can't pay non-positive balance. xacts selected: (%s)",
+ join(", ", map(int, $self->cgi->param("xact"))))
+ );
+ return Apache2::Const::HTTP_INTERNAL_SERVER_ERROR;
+ }
+
+ my $cc_args = {"where_process" => 1};
- 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
my $args = {
"cc_args" => $cc_args,
"userid" => $self->ctx->{user}->id,
- "payment_type": "credit_card_payment",
- "payments" => [$self->cgi->param('xact')] # should be safe after self->prepare_fines
+ "payment_type" => "credit_card_payment",
+ "payments" => $self->prepare_fines_for_payment # should be safe after self->prepare_fines
};
- $U->simplereq("open-ils.circ", "open-ils.circ.money.payment",
+ my $resp = $U->simplereq("open-ils.circ", "open-ils.circ.money.payment",
$self->editor->authtoken, $args, $self->ctx->{user}->last_xact_id
);
- # XXX FINISH ME: indicate success/fail, redirect to page with layout
+ $self->ctx->{"payment_response"} = $resp;
+
+ unless ($resp->{"textcode"}) {
+ $self->ctx->{printable_receipt} = $U->simplereq(
+ "open-ils.circ", "open-ils.circ.money.payment_receipt.print",
+ $self->editor->authtoken, $resp->{payments}
+ );
+ }
+
+ return Apache2::Const::OK;
}
sub prepare_fines {
# XXX TODO: check for failure after various network calls
+ # It may be unclear, but this result structure lumps circulation and
+ # reservation fines together, and keeps grocery fines separate.
$self->ctx->{"fines"} = {
"circulation" => [],
"grocery" => [],
return;
}
+sub prepare_fines_for_payment {
+ # This assumes $self->prepare_fines has already been run
+ my ($self) = @_;
+
+ my @results = ();
+ if ($self->ctx->{fines}) {
+ push @results, [$_->{xact}->id, $_->{xact}->balance_owed] foreach (
+ @{$self->ctx->{fines}->{circulation}},
+ @{$self->ctx->{fines}->{grocery}}
+ );
+ }
+
+ return \@results;
+}
+
sub load_myopac_main {
my $self = shift;
my $limit = $self->cgi->param('limit') || 0;
}
#myopac_payments_table th { text-align: left; }
+.payment-error {
+ font-weight: bold; color: red;
+ padding: 10px; border: 1px solid #888;
+}
#adv_search_parent {
margin-bottom:0px;
$("adv_global_addrow")
);
}
+function print_node(node_id) {
+ var iframe = document.createElement("iframe");
+ var source_node = document.getElementById(node_id);
+ source_node.parentNode.appendChild(iframe);
+
+ var iwin = iframe.contentWindow;
+
+ /* These next three statements are only needed by IE, but they don't
+ * hurt FF/Chrome. */
+ iwin.document.open();
+ iwin.document.write( /* XXX make better/customizable? */
+ "<html><head><title>Recipt</title></head><body></body></html>"
+ );
+ iwin.document.close();
+
+ iwin.document.body.innerHTML = source_node.innerHTML;
+ iframe.focus();
+
+ try { iframe.print(); } catch (e) { iwin.print(); }
+ setTimeout(function() { iframe.style.display = "none"; }, 3500);
+}
myopac_page = "main";
myopac_main_page = "main";
%]
-<form action="[% ctx.opac_root %]/myopac/main_payment_form" method="POST">
+<form action="[% ctx.opac_root %]/myopac/main_payment_form" method="GET">
[% IF ctx.fines.circulation.size > 0 %]
<div id='myopac_circ_trans_div'>
<table width='100%' class='data_grid'>
--- /dev/null
+[% PROCESS "default/opac/parts/header.tt2";
+ PROCESS "default/opac/parts/misc_util.tt2";
+ WRAPPER "default/opac/parts/myopac/base.tt2";
+ myopac_page = "main";
+ myopac_main_page = "pay" %]
+<div id="myopac_summary_div">
+ [% IF ctx.payment_response.textcode %]
+ <div class="payment-error">
+ <span title="[% ctx.payment_response.textcode %]">
+ [% ctx.payment_response.desc %]
+ </span><br />
+ [% ctx.payment_response.payload.error_message %]
+ </div>
+ <p>
+ <a href="[% ctx.opac_root %]/myopac/main"
+ onclick="history.go(-1); return false;">[% l('Go back') %]</a>
+ [% l('to try again or to cancel this payment attempt.') %]
+ </p>
+ [% ELSE %]
+ <p><big>[% l('Your payment has been approved.') %]</big></p>
+ [% IF ctx.printable_receipt.template_output %]
+ <p>[ <a href="javascript:void(0);"
+ onclick="try { print_node('printable-receipt'); } catch (e) { window.print(); } return false;">[% l('Print receipt') %]</a> ]</p>
+ <tt id="printable-receipt">
+ [% ctx.printable_receipt.template_output.data %]
+ </tt>
+ [% ELSE %]
+ <div class="payment-error">
+ [% l(
+ 'Error creating receipt: [_1]',
+ ctx.printable_receipt.error_output.data ||
+ l('No receipt data returned from server')
+ ) %]
+ </div>
+ [% END %]
+ [% END %]
+</div>
+[% END %]
</div>
[% ELSE %]
<div id="pay_fines_now">
- <form action="[% ctx.opac_root %]/myopac/pay" method="POST"
+ <form action="[% ctx.opac_root %]/myopac/main_pay" method="POST"
onsubmit="return confirm('[% l("Are you sure you are ready to charge [_1] to your credit card?", money(ctx.fines.balance_owed)) %]');">
[% FOR xact IN CGI.param('xact') %]
<input type="hidden" name="xact" value="[% xact | html %]" />
[% money(ctx.user_stats.fines.balance_owed) %]
</span><br />
- <form action="[% ctx.opac_root %]/myopac/main_payment_form" method="POST"><input
+ <form action="[% ctx.opac_root %]/myopac/main_payment_form" method="GET"><input
type="image" title="[% l('Pay Fines') %]" alt="[% l('Pay Fines') %]"
onmouseover="this.src='[% ctx.media_prefix %]/images/pay-fines-btn-hover.png';"
onmouseout="this.src='[% ctx.media_prefix %]/images/pay-fines-btn.png';"