[% PROCESS "opac/parts/header.tt2"; PROCESS "opac/parts/misc_util.tt2"; WRAPPER "opac/parts/myopac/base.tt2"; myopac_page = "main"; myopac_main_page = "pay" %]
[% IF ctx.payment_response.textcode %]
[% ctx.payment_response.desc || ctx.payment_response.textcode %]
[% ctx.payment_response.note %] [% ctx.payment_response.payload.error_message %]

[% url_args = {xact => [], xact_misc => []}; FOR k IN ['xact', 'xact_misc']; FOR val IN CGI.param(k); url_args.$k.push(val); END; END; retry_url = mkurl(ctx.opac_root _ '/myopac/main_payment_form', url_args, 1); %]
[% l('Go back to try again or to cancel this payment attempt.') %]

[% ELSE %]

[% l('Your payment has been approved.') %]

[% IF ctx.printable_receipt.template_output; print_args = []; FOR p IN ctx.payment_response.payments; print_args.push('payment=' _ p); END %]

[ [% l('Print receipt') %] ]

[% ctx.printable_receipt.template_output.data %] [% ELSE %]
[% l( 'Error creating receipt: [_1]', (ctx.printable_receipt.textcode ? ctx.printable_receipt.textcode _ ' / ' _ ctx.printable_receipt.desc : 0) || ctx.printable_receipt.error_output.data || l('No receipt data returned from server') ) | html %]
[% END %]

[ [% l("Back to Account Summary") %] ]

[% END %]
[% END %]