+ output_and_exit( $input, $cookie, $template, 'wrong_csrf_token' )
+ unless Koha::Token->new->check_csrf( {
+ session_id => $input->cookie('CGISESSID'),
+ token => scalar $input->param('csrf_token'),
+ });
+
+ my $url;
+ my $pay_result;
+ if ($pay_individual) {
+ my $line = Koha::Account::Lines->find($accountlines_id);
+ $pay_result = $account->pay(
+ {
+ lines => [$line],
+ amount => $total_paid,
+ library_id => $library_id,
+ note => $payment_note,
+ interface => C4::Context->interface,
+ payment_type => $payment_type,
+ cash_register => $cash_register_id
+ }
+ );
+ $payment_id = $pay_result->{payment_id};
+
+ my @additional_fields;
+ my $accountline_fields = Koha::AdditionalFields->search({ tablename => 'accountlines:credit' });
+ while ( my $field = $accountline_fields->next ) {
+ my $value = $input->param('additional_field_' . $field->id);
+ if (defined $value) {
+ push @additional_fields, {
+ id => $field->id,
+ value => $value,
+ };
+ }
+ }
+ if (@additional_fields) {
+ my $payment = Koha::Account::Lines->find($payment_id);
+ $payment->set_additional_fields(\@additional_fields);
+ }
+
+
+ $url = "/cgi-bin/koha/members/pay.pl";
+ } else {
+ if ($selected_accts) {
+ if ( $total_paid > $total_due ) {
+ $template->param(
+ error_over => 1,
+ total_due => $total_due
+ );
+ } else {
+ my $note = $input->param('selected_accts_notes');
+
+ $pay_result = $account->pay(
+ {
+ type => $type,
+ amount => $total_paid,
+ library_id => $library_id,
+ lines => \@selected_accountlines,
+ note => $note,
+ interface => C4::Context->interface,
+ payment_type => $payment_type,
+ cash_register => $cash_register_id
+ }
+ );
+ }
+ $payment_id = $pay_result->{payment_id};
+ }
+ else {
+ my $note = $input->param('selected_accts_notes');
+ $pay_result = $account->pay(