);
}
-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 = (
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>
[% 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
<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">
[% 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 %]
[% 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>
[% 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">
//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();
+++ /dev/null
-#!/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");
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;
}
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,
- }
- );
-}
+);
});
# 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 };