View | Details | Raw Unified | Return to bug 19173
Collapse All | Expand All

(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-account.tt (-15 / +19 lines)
Lines 1-7 Link Here
1
[% USE Koha %]
1
[% USE Koha %]
2
[% USE KohaDates %]
2
[% USE KohaDates %]
3
[% USE Price %]
3
[% USE Price %]
4
[% SET ENABLE_OPAC_PAYMENTS = Koha.Preference('EnablePayPalOpacPayments') %]
4
[% SET ENABLE_OPAC_PAYMENTS = Koha.Preference('EnablePayPalOpacPayments') || plugins %]
5
[% SET DISPLAY_PAYMENT_BLOCK = 0 %]
5
[% SET DISPLAY_PAYMENT_BLOCK = 0 %]
6
[% INCLUDE 'doc-head-open.inc' %]
6
[% INCLUDE 'doc-head-open.inc' %]
7
<title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog &rsaquo; Your fines and charges</title>
7
<title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog &rsaquo; Your fines and charges</title>
Lines 141-160 Link Here
141
                                <fieldset class="pay-online hidden">
141
                                <fieldset class="pay-online hidden">
142
                                    <legend>Pay selected fines and charges</legend>
142
                                    <legend>Pay selected fines and charges</legend>
143
                                        <span class="help-block"><h3>Payment method</h3></span>
143
                                        <span class="help-block"><h3>Payment method</h3></span>
144
                                        <div class="control-group">
144
145
                                            <label class="radio">
145
                                        [% IF Koha.Preference('EnablePayPalOpacPayments') %]
146
                                                <input type="radio" name="payment_method" id="payment_method-paypal" value="paypal" checked="checked">
146
                                            <div class="control-group">
147
                                                <!-- 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 -->
147
                                                <label class="radio">
148
                                            </label>
148
                                                    <input type="radio" name="payment_method" id="payment_method-paypal" value="paypal" checked="checked">
149
                                        </div>
149
                                                    <!-- 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 -->
150
                                        <!-- look to the future
150
                                                </label>
151
                                        <div class="control-group">
151
                                            </div>
152
                                            <label class="radio">
152
                                        [% END %]
153
                                                <input type="radio" name="payment_method" id="payment_method-paypal" value="paypal" checked="checked">
153
154
                                                PayPal
154
                                        [% FOREACH p IN plugins %]
155
                                            </label>
155
                                            <div class="control-group">
156
                                        </div>
156
                                                <label class="radio">
157
                                        -->
157
                                                    <input type="radio" name="payment_method" id="payment_method-[% p.class %]" value="[% p.class %]" checked="checked">
158
                                                    [% p.get_metadata.name %]
159
                                                </label>
160
                                            </div>
161
                                        [% END %]
158
162
159
                                        <div class="control-group">
163
                                        <div class="control-group">
160
                                            <input type="hidden" id="payment-amount" name="payment_amount" value="0" />
164
                                            <input type="hidden" id="payment-amount" name="payment_amount" value="0" />
(-)a/opac/opac-account-pay-return.pl (+53 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright ByWater Solutions 2017
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 3 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use Modern::Perl;
21
22
use CGI;
23
24
use C4::Auth;
25
use Koha::Plugins::Handler;
26
27
my $cgi = new CGI;
28
29
my ( $userid, $cookie, $sessionID, $flags ) = checkauth( $cgi, 0, {}, 'opac' );
30
31
my $payment_method = $cgi->param('payment_method');
32
33
my $can_handle_payment = Koha::Plugins::Handler->run(
34
    {
35
        class  => $payment_method,
36
        method => 'opac_online_payment',
37
        cgi    => $cgi,
38
    }
39
);
40
41
if ($can_handle_payment) {
42
    Koha::Plugins::Handler->run(
43
        {
44
            class  => $payment_method,
45
            method => 'opac_online_payment_end',
46
            cgi    => $cgi,
47
        }
48
    );
49
}
50
else {
51
    print $cgi->redirect("/cgi-bin/koha/errors/404.pl");
52
    exit;
53
}
(-)a/opac/opac-account-pay.pl (-6 / +26 lines)
Lines 31-40 use C4::Output; Link Here
31
use C4::Context;
31
use C4::Context;
32
use Koha::Acquisition::Currencies;
32
use Koha::Acquisition::Currencies;
33
use Koha::Database;
33
use Koha::Database;
34
use Koha::Plugins::Handler;
34
35
35
my $cgi = new CGI;
36
my $cgi = new CGI;
37
my $payment_method = $cgi->param('payment_method');
38
my @accountlines   = $cgi->multi_param('accountline');
39
40
my $use_plugin;
41
if ( $payment_method ne 'paypal' ) {
42
    $use_plugin = Koha::Plugins::Handler->run(
43
        {
44
            class  => $payment_method,
45
            method => 'opac_online_payment',
46
            cgi    => $cgi,
47
        }
48
    );
49
}
36
50
37
unless ( C4::Context->preference('EnablePayPalOpacPayments') ) {
51
unless ( C4::Context->preference('EnablePayPalOpacPayments') || $use_plugin ) {
38
    print $cgi->redirect("/cgi-bin/koha/errors/404.pl");
52
    print $cgi->redirect("/cgi-bin/koha/errors/404.pl");
39
    exit;
53
    exit;
40
}
54
}
Lines 49-57 my ( $template, $borrowernumber, $cookie ) = get_template_and_user( Link Here
49
    }
63
    }
50
);
64
);
51
65
52
my $payment_method = $cgi->param('payment_method');
53
my @accountlines = $cgi->multi_param('accountline');
54
55
my $amount_to_pay =
66
my $amount_to_pay =
56
  Koha::Database->new()->schema()->resultset('Accountline')->search( { accountlines_id => { -in => \@accountlines } } )
67
  Koha::Database->new()->schema()->resultset('Accountline')->search( { accountlines_id => { -in => \@accountlines } } )
57
  ->get_column('amountoutstanding')->sum();
68
  ->get_column('amountoutstanding')->sum();
Lines 125-130 if ( $payment_method eq 'paypal' ) { Link Here
125
        $template->param( error => "PAYPAL_UNABLE_TO_CONNECT" );
136
        $template->param( error => "PAYPAL_UNABLE_TO_CONNECT" );
126
        $error = 1;
137
        $error = 1;
127
    }
138
    }
128
}
129
139
130
output_html_with_http_headers( $cgi, $cookie, $template->output ) if $error;
140
    output_html_with_http_headers( $cgi, $cookie, $template->output ) if $error;
141
}
142
else {
143
    Koha::Plugins::Handler->run(
144
        {
145
            class  => $payment_method,
146
            method => 'opac_online_payment_begin',
147
            cgi    => $cgi,
148
        }
149
    );
150
}
(-)a/opac/opac-account.pl (+11 lines)
Lines 25-30 use C4::Members; Link Here
25
use C4::Auth;
25
use C4::Auth;
26
use C4::Output;
26
use C4::Output;
27
use Koha::Patrons;
27
use Koha::Patrons;
28
use Koha::Plugins;
28
29
29
my $query = new CGI;
30
my $query = new CGI;
30
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
31
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
Lines 77-80 $template->param( Link Here
77
    payment_error => scalar $query->param('payment-error') || q{},
78
    payment_error => scalar $query->param('payment-error') || q{},
78
);
79
);
79
80
81
my $plugins_enabled = C4::Context->preference('UseKohaPlugins') && C4::Context->config("enable_plugins");
82
if ( $plugins_enabled ) {
83
	my @plugins = Koha::Plugins->new()->GetPlugins({
84
		method => 'opac_online_payment',
85
	});
86
    # Only pass in plugins where opac online payment is enabled
87
    @plugins = grep { $_->opac_online_payment } @plugins;
88
	$template->param( plugins => \@plugins );
89
}
90
80
output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 };
91
output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 };
(-)a/t/Koha/Plugin/Test.pm (+15 lines)
Lines 43-48 sub to_marc { Link Here
43
    return "Koha::Plugin::Test::to_marc";
43
    return "Koha::Plugin::Test::to_marc";
44
}
44
}
45
45
46
sub opac_online_payment {
47
    my ( $self, $args ) = @_;
48
    return "Koha::Plugin::Test::opac_online_payment";
49
}
50
51
sub opac_online_payment_begin {
52
    my ( $self, $args ) = @_;
53
    return "Koha::Plugin::Test::opac_online_payment_begin";
54
}
55
56
sub opac_online_payment_end {
57
    my ( $self, $args ) = @_;
58
    return "Koha::Plugin::Test::opac_online_payment_end";
59
}
60
46
sub configure {
61
sub configure {
47
    my ( $self, $args ) = @_;
62
    my ( $self, $args ) = @_;
48
    return "Koha::Plugin::Test::configure";;
63
    return "Koha::Plugin::Test::configure";;
(-)a/t/db_dependent/Plugins.t (-2 / +4 lines)
Lines 2-8 Link Here
2
2
3
use Modern::Perl;
3
use Modern::Perl;
4
4
5
use Test::More tests => 28;
5
use Test::More tests => 31;
6
use File::Basename;
6
use File::Basename;
7
use File::Temp qw( tempdir );
7
use File::Temp qw( tempdir );
8
use FindBin qw($Bin);
8
use FindBin qw($Bin);
Lines 31-36 isa_ok( $plugin, "Koha::Plugins::Base", 'Test plugin parent class' ); Link Here
31
ok( $plugin->can('report'), 'Test plugin can report' );
31
ok( $plugin->can('report'), 'Test plugin can report' );
32
ok( $plugin->can('tool'), 'Test plugin can tool' );
32
ok( $plugin->can('tool'), 'Test plugin can tool' );
33
ok( $plugin->can('to_marc'), 'Test plugin can to_marc' );
33
ok( $plugin->can('to_marc'), 'Test plugin can to_marc' );
34
ok( $plugin->can('opac_online_payment'), 'Test plugin can opac_online_payment' );
35
ok( $plugin->can('opac_online_payment_begin'), 'Test plugin can opac_online_payment_begin' );
36
ok( $plugin->can('opac_online_payment_end'), 'Test plugin can opac_online_payment_end' );
34
ok( $plugin->can('configure'), 'Test plugin can configure' );
37
ok( $plugin->can('configure'), 'Test plugin can configure' );
35
ok( $plugin->can('install'), 'Test plugin can install' );
38
ok( $plugin->can('install'), 'Test plugin can install' );
36
ok( $plugin->can('uninstall'), 'Test plugin can install' );
39
ok( $plugin->can('uninstall'), 'Test plugin can install' );
37
- 

Return to bug 19173