Bugzilla – Attachment 120636 Details for
Bug 23215
Remove PayPal logic from Koha
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23215: Remove traces of the PayPal feature
Bug-23215-Remove-traces-of-the-PayPal-feature.patch (text/plain), 18.11 KB, created by
Kyle M Hall (khall)
on 2021-05-06 15:22:22 UTC
(
hide
)
Description:
Bug 23215: Remove traces of the PayPal feature
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2021-05-06 15:22:22 UTC
Size:
18.11 KB
patch
obsolete
>From 346d215ccd84aab6c240342b05e3dc25d8f5bf1a Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Wed, 5 May 2021 10:16:50 -0300 >Subject: [PATCH] Bug 23215: Remove traces of the PayPal feature > >This patch removes the PayPal payments feature. It has been moved to >its' own plugin. > >To test: >1. Apply this patches >2. Run: > $ updatedatabase >=> SUCCESS: Database updates correctly >3. Run: > $ koha-mysql kohadev > > SELECT * FROM systempreferences WHERE variable LIKE 'paypal'; >=> SUCCESS: No results >4. On the sysprefs, OPAC section >=> SUCCESS: No PayPal-related sysprefs show up >5. Add some charges to your patron >6. In the OPAC, log in and see your charges >=> SUCCESS: Nothing broken >7. Install the PayPal plugin [1] or any other payment plugin >8. Restart plack (mandatory for the PayPal plugin) >9. Set some random data in the config (or better, real sandbox testing > data) >10. Go to the OPAC's account page and try to pay your debts (use the > checkbox to select lines) >=> SUCCESS: The PayPal payment method shows, you can click the button, > it fails due to bad config, but things work as expected. >11. Sign off :-D > >[1] https://gitlab.com/thekesolutions/plugins/koha-plugin-pay-via-paypal/-/releases > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > about.pl | 4 - > .../intranet-tmpl/prog/en/modules/about.tt | 9 +- > .../bootstrap/en/includes/account-table.inc | 13 -- > .../en/modules/opac-account-pay-error.tt | 8 -- > .../bootstrap/en/modules/opac-account.tt | 15 +-- > opac/opac-account-pay-paypal-return.pl | 125 ------------------ > opac/opac-account-pay.pl | 103 ++------------- > opac/opac-account.pl | 5 +- > 8 files changed, 19 insertions(+), 263 deletions(-) > delete mode 100755 opac/opac-account-pay-paypal-return.pl > >diff --git a/about.pl b/about.pl >index 90b434904c..bfe39dbd73 100755 >--- a/about.pl >+++ b/about.pl >@@ -421,10 +421,6 @@ if ( C4::Context->preference('WebBasedSelfCheck') > ); > } > >-if ( C4::Context->preference('EnablePayPalOpacPayments') ) { >- $template->param( paypal_enabled => 1 ); >-} >- > # Test YAML system preferences > # FIXME: This is list of current YAML formatted prefs, should by type of preference > my @yaml_prefs = ( >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt >index d2d4eea04e..62ce7c1602 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt >@@ -299,7 +299,7 @@ > Contact your system administrator. > [% END %] > >- [% IF warnPrefBiblioAddsAuthorities || warnPrefEasyAnalyticalRecords || warnPrefAnonymousPatronOPACPrivacy || warnPrefAnonymousPatronAnonSuggestions || warnPrefAnonymousPatronOPACPrivacy_PatronDoesNotExist || warnPrefAnonymousPatronAnonSuggestions_PatronDoesNotExist || warnPrefKohaAdminEmailAddress || warnPrefOpacHiddenItems || invalid_yesno.count || warnNoActiveCurrency || AutoSelfCheckPatronDoesNotHaveSelfCheckPerm || AutoSelfCheckPatronHasTooManyPerm || warnStatisticsFieldsError || warnNoTemplateCaching || warnILLConfiguration || oauth2_missing_deps || bad_yaml_prefs || warnIssuingRules || config_bcrypt_settings_no_set || warnHiddenBiblionumbers.size || paypal_enabled %] >+ [% IF warnPrefBiblioAddsAuthorities || warnPrefEasyAnalyticalRecords || warnPrefAnonymousPatronOPACPrivacy || warnPrefAnonymousPatronAnonSuggestions || warnPrefAnonymousPatronOPACPrivacy_PatronDoesNotExist || warnPrefAnonymousPatronAnonSuggestions_PatronDoesNotExist || warnPrefKohaAdminEmailAddress || warnPrefOpacHiddenItems || invalid_yesno.count || warnNoActiveCurrency || AutoSelfCheckPatronDoesNotHaveSelfCheckPerm || AutoSelfCheckPatronHasTooManyPerm || warnStatisticsFieldsError || warnNoTemplateCaching || warnILLConfiguration || oauth2_missing_deps || bad_yaml_prefs || warnIssuingRules || config_bcrypt_settings_no_set || warnHiddenBiblionumbers.size %] > <h2>Warnings regarding the system configuration</h2> > <table> > <caption>Preferences and parameters</caption> >@@ -403,13 +403,6 @@ > [% END %] > </td></tr> > [% END %] >- [% IF paypal_enabled %] >- <tr><th scope="row"><strong>Warning</strong> </th><td> >- You are using the PayPal functionality, which is now deprecated and replaced in favor of using payment plugins that can implement >- different payment services. Please install the plugin and follow the migration instructions in order to keep enjoying the PayPal >- integration. This feature will be removed from Koha in a short term. >- </td></tr> >- [% END %] > [% IF Koha.Preference('SearchEngine') == 'Elasticsearch' && elasticsearch_status.version.substr(0,1) < 6 %] > <tr><th scope="row"><strong>Deprecation warning</strong></th><td> > Elasticsearch version 5.x is not supported in Koha 20.11 and greater. Please upgrade your Elasticsearch cluster >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/account-table.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/account-table.inc >index 3cfc0f8877..c4f4ad5aca 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/account-table.inc >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/account-table.inc >@@ -137,19 +137,6 @@ > <legend>Pay selected fines and charges</legend> > <span class="help-block"><h2>Payment method</h2></span> > >- [% IF Koha.Preference('EnablePayPalOpacPayments') %] >- <div class="control-group"> >- <label class="radio"> >- <input type="radio" name="payment_method" id="payment_method-paypal" value="paypal" checked="checked" /> >- <!-- PayPal Logo --> >- <a href="https://www.paypal.com/webapps/mpp/paypal-popup" title="How PayPal Works" class="paypal"> >- <img src="https://www.paypalobjects.com/webstatic/mktg/logo/AM_SbyPP_mc_vs_dc_ae.jpg" alt="PayPal Acceptance Mark" /> >- </a> >- <!-- PayPal Logo --> >- </label> >- </div> >- [% END %] >- > [% FOREACH p IN plugins %] > <div class="control-group"> > <label class="radio"> >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-account-pay-error.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-account-pay-error.tt >index a2004cde32..9f360370ec 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-account-pay-error.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-account-pay-error.tt >@@ -34,14 +34,6 @@ > [% IF error %] > <div id="error" class="alert alert-warning"> > <p><strong>Error:</strong> there was a problem processing your payment</p> >- >- [% IF error == "PAYPAL_UNABLE_TO_CONNECT" %] >- <p>Unable to connect to PayPal.</p> >- <p>Please try again later.</p> >- [% ELSIF error == "PAYPAL_ERROR_PROCESSING" %] >- <p>Unable to verify payment.</p> >- <p>Please contact the library to verify your payment.</p> >- [% END %] > </div> > [% END %] > >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-account.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-account.tt >index ac97a887b0..4251f8356c 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-account.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-account.tt >@@ -4,7 +4,7 @@ > [% USE KohaDates %] > [% USE AuthorisedValues %] > [% USE Price %] >-[% SET ENABLE_OPAC_PAYMENTS = Koha.Preference('EnablePayPalOpacPayments') || plugins %] >+[% SET ENABLE_OPAC_PAYMENTS = payment_methods %] > [% SET DISPLAY_PAYMENT_BLOCK = 0 %] > [% INCLUDE 'doc-head-open.inc' %] > <title>Your charges › [% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] catalog</title> >@@ -60,14 +60,6 @@ > [% IF payment_error %] > <div id="error" class="alert alert-warning"> > <p><strong>Error:</strong> there was a problem processing your payment</p> >- >- [% IF payment_error == "PAYPAL_UNABLE_TO_CONNECT" %] >- <p>Unable to connect to PayPal.</p> >- <p>Please contact a librarian to verify your payment.</p> >- [% ELSIF payment_error == "PAYPAL_ERROR_PROCESSING" %] >- <p>Unable to verify payment.</p> >- <p>Please contact a librarian to verify your payment.</p> >- [% END %] > </div> > [% ELSIF payment %] > <div class="alert alert-info"> >@@ -119,11 +111,6 @@ $( document ).ready(function() { > //Start filtered > $('#filter_paid').click(); > >- $(".paypal").on("click", function() { >- window.open('https://www.paypal.com/webapps/mpp/paypal-popup','WIPaypal','toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=1060, height=700'); >- return false; >- }); >- > $(".pay-online").removeClass("hidden"); > > $("#amount-to-pay-label").hide(); >diff --git a/opac/opac-account-pay-paypal-return.pl b/opac/opac-account-pay-paypal-return.pl >deleted file mode 100755 >index 5fb9b8c1a3..0000000000 >--- a/opac/opac-account-pay-paypal-return.pl >+++ /dev/null >@@ -1,125 +0,0 @@ >-#!/usr/bin/perl >- >-# Copyright ByWater Solutions 2015 >-# >-# This file is part of Koha. >-# >-# Koha is free software; you can redistribute it and/or modify it >-# under the terms of the GNU General Public License as published by >-# the Free Software Foundation; either version 3 of the License, or >-# (at your option) any later version. >-# >-# Koha is distributed in the hope that it will be useful, but >-# WITHOUT ANY WARRANTY; without even the implied warranty of >-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >-# GNU General Public License for more details. >-# >-# You should have received a copy of the GNU General Public License >-# along with Koha; if not, see <http://www.gnu.org/licenses>. >- >-use Modern::Perl; >-use utf8; >- >-use CGI; >-use HTTP::Request::Common; >-use LWP::UserAgent; >-use URI; >- >-use C4::Auth; >-use C4::Output; >-use C4::Accounts; >-use Koha::Acquisition::Currencies; >-use Koha::Database; >-use Koha::Patrons; >- >-my $cgi = CGI->new; >- >-unless ( C4::Context->preference('EnablePayPalOpacPayments') ) { >- print $cgi->redirect("/cgi-bin/koha/errors/404.pl"); >- exit; >-} >- >-my ( $template, $borrowernumber, $cookie ) = get_template_and_user( >- { >- template_name => "opac-account-pay-return.tt", >- query => $cgi, >- type => "opac", >- debug => 1, >- } >-); >- >-my $active_currency = Koha::Acquisition::Currencies->get_active; >- >-my $token = $cgi->param('token'); >-my $payer_id = $cgi->param('PayerID'); >-my $amount = $cgi->param('amount'); >-my @accountlines = $cgi->multi_param('accountlines'); >- >-my $ua = LWP::UserAgent->new; >- >-my $url = >- C4::Context->preference('PayPalSandboxMode') >- ? 'https://api-3t.sandbox.paypal.com/nvp' >- : 'https://api-3t.paypal.com/nvp'; >- >-my $nvp_params = { >- 'USER' => C4::Context->preference('PayPalUser'), >- 'PWD' => C4::Context->preference('PayPalPwd'), >- 'SIGNATURE' => C4::Context->preference('PayPalSignature'), >- >- # API Version and Operation >- 'METHOD' => 'DoExpressCheckoutPayment', >- 'VERSION' => '82.0', >- >- # API specifics for DoExpressCheckout >- 'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale', >- 'PAYERID' => $payer_id, >- 'TOKEN' => $token, >- 'PAYMENTREQUEST_0_AMT' => $amount, >- 'PAYMENTREQUEST_0_CURRENCYCODE' => $active_currency->currency, >-}; >- >-my $response = $ua->request( POST $url, $nvp_params ); >- >-my $error = q{}; >-if ( $response->is_success ) { >- >- my $urlencoded = $response->content; >- my %params = URI->new( "?$urlencoded" )->query_form; >- >- >- if ( $params{ACK} eq "Success" ) { >- $amount = $params{PAYMENTINFO_0_AMT}; >- >- 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', >- interface => C4::Context->interface >- } >- ); >- } >- else { >- $error = "PAYPAL_ERROR_PROCESSING"; >- } >- >-} >-else { >- $error = "PAYPAL_UNABLE_TO_CONNECT"; >-} >- >-my $patron = Koha::Patrons->find( $borrowernumber ); >-$template->param( >- borrower => $patron->unblessed, >- accountview => 1 >-); >- >-print $cgi->redirect("/cgi-bin/koha/opac-account.pl?payment=$amount&payment-error=$error"); >diff --git a/opac/opac-account-pay.pl b/opac/opac-account-pay.pl >index 69384dbaca..cdc4d42b59 100755 >--- a/opac/opac-account-pay.pl >+++ b/opac/opac-account-pay.pl >@@ -37,18 +37,14 @@ my $cgi = CGI->new; > my $payment_method = $cgi->param('payment_method'); > my @accountlines = $cgi->multi_param('accountline'); > >-my $use_plugin; >-if ( $payment_method ne 'paypal' ) { >- $use_plugin = Koha::Plugins::Handler->run( >- { >- class => $payment_method, >- method => 'opac_online_payment', >- cgi => $cgi, >- } >- ); >-} >+my $use_plugin = Koha::Plugins::Handler->run( >+ { class => $payment_method, >+ method => 'opac_online_payment', >+ cgi => $cgi, >+ } >+); > >-unless ( C4::Context->preference('EnablePayPalOpacPayments') || $use_plugin ) { >+unless ( $use_plugin ) { > print $cgi->redirect("/cgi-bin/koha/errors/404.pl"); > exit; > } >@@ -70,84 +66,11 @@ $amount_to_pay = sprintf( "%.2f", $amount_to_pay ); > my $active_currency = Koha::Acquisition::Currencies->get_active; > > my $error = 0; >-if ( $payment_method eq 'paypal' ) { >- my $ua = LWP::UserAgent->new; >- >- my $url = >- C4::Context->preference('PayPalSandboxMode') >- ? 'https://api-3t.sandbox.paypal.com/nvp' >- : 'https://api-3t.paypal.com/nvp'; >- >- my $opac_base_url = >- C4::Context->preference('PayPalReturnURL') eq 'BaseURL' >- ? C4::Context->preference('OPACBaseURL') >- : $cgi->url(-base=>1); >- >- my $return_url = URI->new( $opac_base_url . "/cgi-bin/koha/opac-account-pay-paypal-return.pl" ); >- $return_url->query_form( { amount => $amount_to_pay, accountlines => \@accountlines } ); >- >- my $cancel_url = URI->new( $opac_base_url . "/cgi-bin/koha/opac-account.pl" ); >- >- my $nvp_params = { >- 'USER' => C4::Context->preference('PayPalUser'), >- 'PWD' => C4::Context->preference('PayPalPwd'), >- 'SIGNATURE' => C4::Context->preference('PayPalSignature'), >- >- # API Version and Operation >- 'METHOD' => 'SetExpressCheckout', >- 'VERSION' => '82.0', >- >- # API specifics for SetExpressCheckout >- 'NOSHIPPING' => 1, >- 'REQCONFIRMSHIPPING' => 0, >- 'ALLOWNOTE' => 0, >- 'BRANDNAME' => C4::Context->preference('LibraryName'), >- 'CANCELURL' => $cancel_url->as_string(), >- 'RETURNURL' => $return_url->as_string(), >- 'PAYMENTREQUEST_0_CURRENCYCODE' => $active_currency->currency, >- 'PAYMENTREQUEST_0_AMT' => $amount_to_pay, >- 'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale', >- 'PAYMENTREQUEST_0_ALLOWEDPAYMENTMETHOD' => 'InstantPaymentOnly', >- 'PAYMENTREQUEST_0_DESC' => C4::Context->preference('PayPalChargeDescription'), >- 'SOLUTIONTYPE' => 'Sole', >- }; >- >- my $response = $ua->request( POST $url, $nvp_params ); > >- if ( $response->is_success ) { >- >- my $urlencoded = $response->content; >- my %params = URI->new( "?$urlencoded" )->query_form; >- >- if ( $params{ACK} eq "Success" ) { >- my $token = $params{TOKEN}; >- >- my $redirect_url = >- C4::Context->preference('PayPalSandboxMode') >- ? "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=" >- : "https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token="; >- print $cgi->redirect( $redirect_url . $token ); >- >- } >- else { >- $template->param( error => "PAYPAL_ERROR_PROCESSING" ); >- $error = 1; >- } >- >- } >- else { >- $template->param( error => "PAYPAL_UNABLE_TO_CONNECT" ); >- $error = 1; >+Koha::Plugins::Handler->run( >+ { >+ class => $payment_method, >+ method => 'opac_online_payment_begin', >+ cgi => $cgi, > } >- >- output_html_with_http_headers( $cgi, $cookie, $template->output, undef, { force_no_caching => 1 } ) if $error; >-} >-else { >- Koha::Plugins::Handler->run( >- { >- class => $payment_method, >- method => 'opac_online_payment_begin', >- cgi => $cgi, >- } >- ); >-} >+); >diff --git a/opac/opac-account.pl b/opac/opac-account.pl >index 8442281b36..3a7b4cb1c2 100755 >--- a/opac/opac-account.pl >+++ b/opac/opac-account.pl >@@ -89,7 +89,10 @@ if ( C4::Context->config("enable_plugins") ) { > }); > # Only pass in plugins where opac online payment is enabled > @plugins = grep { $_->opac_online_payment } @plugins; >- $template->param( plugins => \@plugins ); >+ $template->param( >+ plugins => \@plugins, >+ payment_methods => scalar @plugins > 0 >+ ); > } > > output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 }; >-- >2.24.3 (Apple Git-128)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 23215
:
120519
|
120520
|
120634
|
120635
| 120636