From 9657cf133b5fb858262b93394bae069a3a8bc90b Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Wed, 24 Feb 2016 15:56:52 +0000 Subject: [PATCH] Bug 15907 - Remove use of makepayment in opac/opac-account-pay-paypal-return.pl Test Plan: 1) Apply this patch 2) Make a payment via PayPal in sandbox mode 3) Note the payment succeeds Signed-off-by: Josef Moravec Bug 15907 [QA Followup] - Simplify code and call pay() only once Signed-off-by: Josef Moravec --- opac/opac-account-pay-paypal-return.pl | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/opac/opac-account-pay-paypal-return.pl b/opac/opac-account-pay-paypal-return.pl index 77b50d8..eb870cc 100755 --- a/opac/opac-account-pay-paypal-return.pl +++ b/opac/opac-account-pay-paypal-return.pl @@ -93,11 +93,20 @@ if ( $response->is_success ) { if ( $params{ACK} eq "Success" ) { $amount = $params{PAYMENTINFO_0_AMT}; - my $accountlines_rs = Koha::Database->new()->schema()->resultset('Accountline'); - foreach my $accountlines_id ( @accountlines ) { - my $accountline = $accountlines_rs->find( $accountlines_id ); - makepayment( $accountlines_id, $borrowernumber, undef, $accountline->amountoutstanding, undef, undef, 'PayPal' ); - } + my $account = Koha::Account->new( { patron_id => $borrowernumber } ); + my @lines = Koha::Account::Lines->search( + { + accountlines_id => { -in => \@accountlines } + } + ); + + $account->pay( + { + amount => $amount, + lines => \@lines, + note => 'PayPal' + } + ); } else { $error = "PAYPAL_ERROR_PROCESSING"; -- 2.9.3