[% USE Koha %]
[% USE KohaDates %]
[% USE Price %]
-[% SET ENABLE_OPAC_PAYMENTS = Koha.Preference('EnablePayPalOpacPayments') %]
+[% SET ENABLE_OPAC_PAYMENTS = Koha.Preference('EnablePayPalOpacPayments') || plugins %]
[% SET DISPLAY_PAYMENT_BLOCK = 0 %]
[% INCLUDE 'doc-head-open.inc' %]
<title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog › Your fines and charges</title>
<fieldset class="pay-online hidden">
<legend>Pay selected fines and charges</legend>
<span class="help-block"><h3>Payment method</h3></span>
- <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" border="0" alt="PayPal Acceptance Mark"></a><!-- PayPal Logo -->
- </label>
- </div>
- <!-- look to the future
- <div class="control-group">
- <label class="radio">
- <input type="radio" name="payment_method" id="payment_method-paypal" value="paypal" checked="checked">
- PayPal
- </label>
- </div>
- -->
+
+ [% 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" border="0" alt="PayPal Acceptance Mark"></a><!-- PayPal Logo -->
+ </label>
+ </div>
+ [% END %]
+
+ [% FOREACH p IN plugins %]
+ <div class="control-group">
+ <label class="radio">
+ <input type="radio" name="payment_method" id="payment_method-[% p.class %]" value="[% p.class %]" checked="checked">
+ [% p.get_metadata.name %]
+ </label>
+ </div>
+ [% END %]
<div class="control-group">
<input type="hidden" id="payment-amount" name="payment_amount" value="0" />
--- /dev/null
+#!/usr/bin/perl
+
+# Copyright ByWater Solutions 2017
+#
+# 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, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+use Modern::Perl;
+
+use CGI;
+
+use C4::Auth;
+use Koha::Plugins::Handler;
+
+my $cgi = new CGI;
+
+my ( $userid, $cookie, $sessionID, $flags ) = checkauth( $cgi, 0, {}, 'opac' );
+
+# Check for payment method in both POST and GET vars
+my $payment_method = $cgi->param('payment_method') || $cgi->url_param('payment_method');
+
+my $can_handle_payment = Koha::Plugins::Handler->run(
+ {
+ class => $payment_method,
+ method => 'opac_online_payment',
+ cgi => $cgi,
+ }
+);
+
+if ($can_handle_payment) {
+ Koha::Plugins::Handler->run(
+ {
+ class => $payment_method,
+ method => 'opac_online_payment_end',
+ cgi => $cgi,
+ }
+ );
+}
+else {
+ print $cgi->redirect("/cgi-bin/koha/errors/404.pl");
+ exit;
+}
use C4::Context;
use Koha::Acquisition::Currencies;
use Koha::Database;
+use Koha::Plugins::Handler;
my $cgi = new CGI;
+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,
+ }
+ );
+}
-unless ( C4::Context->preference('EnablePayPalOpacPayments') ) {
+unless ( C4::Context->preference('EnablePayPalOpacPayments') || $use_plugin ) {
print $cgi->redirect("/cgi-bin/koha/errors/404.pl");
exit;
}
}
);
-my $payment_method = $cgi->param('payment_method');
-my @accountlines = $cgi->multi_param('accountline');
-
my $amount_to_pay =
Koha::Database->new()->schema()->resultset('Accountline')->search( { accountlines_id => { -in => \@accountlines } } )
->get_column('amountoutstanding')->sum();
$template->param( error => "PAYPAL_UNABLE_TO_CONNECT" );
$error = 1;
}
-}
-output_html_with_http_headers( $cgi, $cookie, $template->output ) if $error;
+ output_html_with_http_headers( $cgi, $cookie, $template->output ) if $error;
+}
+else {
+ Koha::Plugins::Handler->run(
+ {
+ class => $payment_method,
+ method => 'opac_online_payment_begin',
+ cgi => $cgi,
+ }
+ );
+}
use C4::Auth;
use C4::Output;
use Koha::Patrons;
+use Koha::Plugins;
my $query = new CGI;
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
payment_error => scalar $query->param('payment-error') || q{},
);
+my $plugins_enabled = C4::Context->preference('UseKohaPlugins') && C4::Context->config("enable_plugins");
+if ( $plugins_enabled ) {
+ my @plugins = Koha::Plugins->new()->GetPlugins({
+ method => 'opac_online_payment',
+ });
+ # Only pass in plugins where opac online payment is enabled
+ @plugins = grep { $_->opac_online_payment } @plugins;
+ $template->param( plugins => \@plugins );
+}
+
output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 };
return "Koha::Plugin::Test::to_marc";
}
+sub opac_online_payment {
+ my ( $self, $args ) = @_;
+ return "Koha::Plugin::Test::opac_online_payment";
+}
+
+sub opac_online_payment_begin {
+ my ( $self, $args ) = @_;
+ return "Koha::Plugin::Test::opac_online_payment_begin";
+}
+
+sub opac_online_payment_end {
+ my ( $self, $args ) = @_;
+ return "Koha::Plugin::Test::opac_online_payment_end";
+}
+
sub configure {
my ( $self, $args ) = @_;
return "Koha::Plugin::Test::configure";;
use Modern::Perl;
-use Test::More tests => 28;
+use Test::More tests => 31;
use File::Basename;
use File::Temp qw( tempdir );
use FindBin qw($Bin);
ok( $plugin->can('report'), 'Test plugin can report' );
ok( $plugin->can('tool'), 'Test plugin can tool' );
ok( $plugin->can('to_marc'), 'Test plugin can to_marc' );
+ok( $plugin->can('opac_online_payment'), 'Test plugin can opac_online_payment' );
+ok( $plugin->can('opac_online_payment_begin'), 'Test plugin can opac_online_payment_begin' );
+ok( $plugin->can('opac_online_payment_end'), 'Test plugin can opac_online_payment_end' );
ok( $plugin->can('configure'), 'Test plugin can configure' );
ok( $plugin->can('install'), 'Test plugin can install' );
ok( $plugin->can('uninstall'), 'Test plugin can install' );