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

(-)a/about.pl (-4 lines)
Lines 421-430 if ( C4::Context->preference('WebBasedSelfCheck') Link Here
421
    );
421
    );
422
}
422
}
423
423
424
if ( C4::Context->preference('EnablePayPalOpacPayments') ) {
425
    $template->param( paypal_enabled => 1 );
426
}
427
428
# Test YAML system preferences
424
# Test YAML system preferences
429
# FIXME: This is list of current YAML formatted prefs, should by type of preference
425
# FIXME: This is list of current YAML formatted prefs, should by type of preference
430
my @yaml_prefs = (
426
my @yaml_prefs = (
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt (-8 / +1 lines)
Lines 299-305 Link Here
299
            Contact your system administrator.
299
            Contact your system administrator.
300
        [% END %]
300
        [% END %]
301
301
302
        [% 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 %]
302
        [% 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 %]
303
            <h2>Warnings regarding the system configuration</h2>
303
            <h2>Warnings regarding the system configuration</h2>
304
            <table>
304
            <table>
305
                <caption>Preferences and parameters</caption>
305
                <caption>Preferences and parameters</caption>
Lines 403-415 Link Here
403
                    [% END %]
403
                    [% END %]
404
                    </td></tr>
404
                    </td></tr>
405
                [% END %]
405
                [% END %]
406
                [% IF paypal_enabled %]
407
                    <tr><th scope="row"><strong>Warning</strong> </th><td>
408
                    You are using the PayPal functionality, which is now deprecated and replaced in favor of using payment plugins that can implement
409
                    different payment services. Please install the plugin and follow the migration instructions in order to keep enjoying the PayPal
410
                    integration. This feature will be removed from Koha in a short term.
411
                    </td></tr>
412
                [% END %]
413
                [% IF Koha.Preference('SearchEngine') == 'Elasticsearch' && elasticsearch_status.version.substr(0,1) < 6 %]
406
                [% IF Koha.Preference('SearchEngine') == 'Elasticsearch' && elasticsearch_status.version.substr(0,1) < 6 %]
414
                    <tr><th scope="row"><strong>Deprecation warning</strong></th><td>
407
                    <tr><th scope="row"><strong>Deprecation warning</strong></th><td>
415
                            Elasticsearch version 5.x is not supported in Koha 20.11 and greater. Please upgrade your Elasticsearch cluster
408
                            Elasticsearch version 5.x is not supported in Koha 20.11 and greater. Please upgrade your Elasticsearch cluster
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/account-table.inc (-13 lines)
Lines 137-155 Link Here
137
            <legend>Pay selected fines and charges</legend>
137
            <legend>Pay selected fines and charges</legend>
138
            <span class="help-block"><h2>Payment method</h2></span>
138
            <span class="help-block"><h2>Payment method</h2></span>
139
139
140
            [% IF Koha.Preference('EnablePayPalOpacPayments') %]
141
                <div class="control-group">
142
                    <label class="radio">
143
                        <input type="radio" name="payment_method" id="payment_method-paypal" value="paypal" checked="checked" />
144
                        <!-- PayPal Logo -->
145
                        <a href="https://www.paypal.com/webapps/mpp/paypal-popup" title="How PayPal Works" class="paypal">
146
                            <img src="https://www.paypalobjects.com/webstatic/mktg/logo/AM_SbyPP_mc_vs_dc_ae.jpg" alt="PayPal Acceptance Mark" />
147
                        </a>
148
                        <!-- PayPal Logo -->
149
                    </label>
150
                </div>
151
            [% END %]
152
153
            [% FOREACH p IN plugins %]
140
            [% FOREACH p IN plugins %]
154
                <div class="control-group">
141
                <div class="control-group">
155
                    <label class="radio">
142
                    <label class="radio">
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-account-pay-error.tt (-8 lines)
Lines 34-47 Link Here
34
                    [% IF error %]
34
                    [% IF error %]
35
                        <div id="error" class="alert alert-warning">
35
                        <div id="error" class="alert alert-warning">
36
                            <p><strong>Error:</strong> there was a problem processing your payment</p>
36
                            <p><strong>Error:</strong> there was a problem processing your payment</p>
37
38
                            [% IF error == "PAYPAL_UNABLE_TO_CONNECT" %]
39
                                <p>Unable to connect to PayPal.</p>
40
                                <p>Please try again later.</p>
41
                            [% ELSIF error == "PAYPAL_ERROR_PROCESSING" %]
42
                                <p>Unable to verify payment.</p>
43
                                <p>Please contact the library to verify your payment.</p>
44
                            [% END %]
45
                        </div>
37
                        </div>
46
                    [% END %]
38
                    [% END %]
47
39
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-account.tt (-14 / +1 lines)
Lines 4-10 Link Here
4
[% USE KohaDates %]
4
[% USE KohaDates %]
5
[% USE AuthorisedValues %]
5
[% USE AuthorisedValues %]
6
[% USE Price %]
6
[% USE Price %]
7
[% SET ENABLE_OPAC_PAYMENTS = Koha.Preference('EnablePayPalOpacPayments') || plugins %]
7
[% SET ENABLE_OPAC_PAYMENTS = payment_methods %]
8
[% SET DISPLAY_PAYMENT_BLOCK = 0 %]
8
[% SET DISPLAY_PAYMENT_BLOCK = 0 %]
9
[% INCLUDE 'doc-head-open.inc' %]
9
[% INCLUDE 'doc-head-open.inc' %]
10
<title>Your charges &rsaquo; [% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] catalog</title>
10
<title>Your charges &rsaquo; [% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] catalog</title>
Lines 60-73 Link Here
60
                    [% IF payment_error %]
60
                    [% IF payment_error %]
61
                        <div id="error" class="alert alert-warning">
61
                        <div id="error" class="alert alert-warning">
62
                            <p><strong>Error:</strong> there was a problem processing your payment</p>
62
                            <p><strong>Error:</strong> there was a problem processing your payment</p>
63
64
                            [% IF payment_error == "PAYPAL_UNABLE_TO_CONNECT" %]
65
                                <p>Unable to connect to PayPal.</p>
66
                                <p>Please contact a librarian to verify your payment.</p>
67
                            [% ELSIF payment_error == "PAYPAL_ERROR_PROCESSING" %]
68
                                <p>Unable to verify payment.</p>
69
                                <p>Please contact a librarian to verify your payment.</p>
70
                            [% END %]
71
                        </div>
63
                        </div>
72
                    [% ELSIF payment %]
64
                    [% ELSIF payment %]
73
                        <div class="alert alert-info">
65
                        <div class="alert alert-info">
Lines 119-129 $( document ).ready(function() { Link Here
119
    //Start filtered
111
    //Start filtered
120
    $('#filter_paid').click();
112
    $('#filter_paid').click();
121
113
122
    $(".paypal").on("click", function() {
123
        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');
124
        return false;
125
    });
126
127
    $(".pay-online").removeClass("hidden");
114
    $(".pay-online").removeClass("hidden");
128
115
129
    $("#amount-to-pay-label").hide();
116
    $("#amount-to-pay-label").hide();
(-)a/opac/opac-account-pay-paypal-return.pl (-125 lines)
Lines 1-125 Link Here
1
#!/usr/bin/perl
2
3
# Copyright ByWater Solutions 2015
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20
use Modern::Perl;
21
use utf8;
22
23
use CGI;
24
use HTTP::Request::Common;
25
use LWP::UserAgent;
26
use URI;
27
28
use C4::Auth;
29
use C4::Output;
30
use C4::Accounts;
31
use Koha::Acquisition::Currencies;
32
use Koha::Database;
33
use Koha::Patrons;
34
35
my $cgi = CGI->new;
36
37
unless ( C4::Context->preference('EnablePayPalOpacPayments') ) {
38
    print $cgi->redirect("/cgi-bin/koha/errors/404.pl");
39
    exit;
40
}
41
42
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
43
    {
44
        template_name   => "opac-account-pay-return.tt",
45
        query           => $cgi,
46
        type            => "opac",
47
        debug           => 1,
48
    }
49
);
50
51
my $active_currency = Koha::Acquisition::Currencies->get_active;
52
53
my $token    = $cgi->param('token');
54
my $payer_id = $cgi->param('PayerID');
55
my $amount   = $cgi->param('amount');
56
my @accountlines = $cgi->multi_param('accountlines');
57
58
my $ua = LWP::UserAgent->new;
59
60
my $url =
61
  C4::Context->preference('PayPalSandboxMode')
62
  ? 'https://api-3t.sandbox.paypal.com/nvp'
63
  : 'https://api-3t.paypal.com/nvp';
64
65
my $nvp_params = {
66
    'USER'      => C4::Context->preference('PayPalUser'),
67
    'PWD'       => C4::Context->preference('PayPalPwd'),
68
    'SIGNATURE' => C4::Context->preference('PayPalSignature'),
69
70
    # API Version and Operation
71
    'METHOD'  => 'DoExpressCheckoutPayment',
72
    'VERSION' => '82.0',
73
74
    # API specifics for DoExpressCheckout
75
    'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale',
76
    'PAYERID'                        => $payer_id,
77
    'TOKEN'                          => $token,
78
    'PAYMENTREQUEST_0_AMT'           => $amount,
79
    'PAYMENTREQUEST_0_CURRENCYCODE'  => $active_currency->currency,
80
};
81
82
my $response = $ua->request( POST $url, $nvp_params );
83
84
my $error = q{};
85
if ( $response->is_success ) {
86
87
    my $urlencoded = $response->content;
88
    my %params = URI->new( "?$urlencoded" )->query_form;
89
90
91
    if ( $params{ACK} eq "Success" ) {
92
        $amount = $params{PAYMENTINFO_0_AMT};
93
94
        my $account = Koha::Account->new( { patron_id => $borrowernumber } );
95
        my @lines = Koha::Account::Lines->search(
96
            {
97
                accountlines_id => { -in => \@accountlines }
98
            }
99
        );
100
101
        $account->pay(
102
            {
103
                amount => $amount,
104
                lines  => \@lines,
105
                note   => 'PayPal',
106
                interface => C4::Context->interface
107
            }
108
        );
109
    }
110
    else {
111
       $error = "PAYPAL_ERROR_PROCESSING";
112
    }
113
114
}
115
else {
116
    $error = "PAYPAL_UNABLE_TO_CONNECT";
117
}
118
119
my $patron = Koha::Patrons->find( $borrowernumber );
120
$template->param(
121
    borrower    => $patron->unblessed,
122
    accountview => 1
123
);
124
125
print $cgi->redirect("/cgi-bin/koha/opac-account.pl?payment=$amount&payment-error=$error");
(-)a/opac/opac-account-pay.pl (-90 / +13 lines)
Lines 37-54 my $cgi = CGI->new; Link Here
37
my $payment_method = $cgi->param('payment_method');
37
my $payment_method = $cgi->param('payment_method');
38
my @accountlines   = $cgi->multi_param('accountline');
38
my @accountlines   = $cgi->multi_param('accountline');
39
39
40
my $use_plugin;
40
my $use_plugin = Koha::Plugins::Handler->run(
41
if ( $payment_method ne 'paypal' ) {
41
    {   class  => $payment_method,
42
    $use_plugin = Koha::Plugins::Handler->run(
42
        method => 'opac_online_payment',
43
        {
43
        cgi    => $cgi,
44
            class  => $payment_method,
44
    }
45
            method => 'opac_online_payment',
45
);
46
            cgi    => $cgi,
47
        }
48
    );
49
}
50
46
51
unless ( C4::Context->preference('EnablePayPalOpacPayments') || $use_plugin ) {
47
unless ( $use_plugin ) {
52
    print $cgi->redirect("/cgi-bin/koha/errors/404.pl");
48
    print $cgi->redirect("/cgi-bin/koha/errors/404.pl");
53
    exit;
49
    exit;
54
}
50
}
Lines 70-153 $amount_to_pay = sprintf( "%.2f", $amount_to_pay ); Link Here
70
my $active_currency = Koha::Acquisition::Currencies->get_active;
66
my $active_currency = Koha::Acquisition::Currencies->get_active;
71
67
72
my $error = 0;
68
my $error = 0;
73
if ( $payment_method eq 'paypal' ) {
74
    my $ua = LWP::UserAgent->new;
75
76
    my $url =
77
      C4::Context->preference('PayPalSandboxMode')
78
      ? 'https://api-3t.sandbox.paypal.com/nvp'
79
      : 'https://api-3t.paypal.com/nvp';
80
81
    my $opac_base_url =
82
      C4::Context->preference('PayPalReturnURL') eq 'BaseURL'
83
      ? C4::Context->preference('OPACBaseURL')
84
      : $cgi->url(-base=>1);
85
86
    my $return_url = URI->new( $opac_base_url . "/cgi-bin/koha/opac-account-pay-paypal-return.pl" );
87
    $return_url->query_form( { amount => $amount_to_pay, accountlines => \@accountlines } );
88
89
    my $cancel_url = URI->new( $opac_base_url . "/cgi-bin/koha/opac-account.pl" );
90
91
    my $nvp_params = {
92
        'USER'      => C4::Context->preference('PayPalUser'),
93
        'PWD'       => C4::Context->preference('PayPalPwd'),
94
        'SIGNATURE' => C4::Context->preference('PayPalSignature'),
95
96
        # API Version and Operation
97
        'METHOD'  => 'SetExpressCheckout',
98
        'VERSION' => '82.0',
99
100
        # API specifics for SetExpressCheckout
101
        'NOSHIPPING'                            => 1,
102
        'REQCONFIRMSHIPPING'                    => 0,
103
        'ALLOWNOTE'                             => 0,
104
        'BRANDNAME'                             => C4::Context->preference('LibraryName'),
105
        'CANCELURL'                             => $cancel_url->as_string(),
106
        'RETURNURL'                             => $return_url->as_string(),
107
        'PAYMENTREQUEST_0_CURRENCYCODE'         => $active_currency->currency,
108
        'PAYMENTREQUEST_0_AMT'                  => $amount_to_pay,
109
        'PAYMENTREQUEST_0_PAYMENTACTION'        => 'Sale',
110
        'PAYMENTREQUEST_0_ALLOWEDPAYMENTMETHOD' => 'InstantPaymentOnly',
111
        'PAYMENTREQUEST_0_DESC'                 => C4::Context->preference('PayPalChargeDescription'),
112
        'SOLUTIONTYPE'                          => 'Sole',
113
    };
114
115
    my $response = $ua->request( POST $url, $nvp_params );
116
69
117
    if ( $response->is_success ) {
70
Koha::Plugins::Handler->run(
118
71
    {
119
        my $urlencoded = $response->content;
72
        class  => $payment_method,
120
        my %params = URI->new( "?$urlencoded" )->query_form;
73
        method => 'opac_online_payment_begin',
121
74
        cgi    => $cgi,
122
        if ( $params{ACK} eq "Success" ) {
123
            my $token = $params{TOKEN};
124
125
            my $redirect_url =
126
              C4::Context->preference('PayPalSandboxMode')
127
              ? "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token="
128
              : "https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=";
129
            print $cgi->redirect( $redirect_url . $token );
130
131
        }
132
        else {
133
            $template->param( error => "PAYPAL_ERROR_PROCESSING" );
134
            $error = 1;
135
        }
136
137
    }
138
    else {
139
        $template->param( error => "PAYPAL_UNABLE_TO_CONNECT" );
140
        $error = 1;
141
    }
75
    }
142
76
);
143
    output_html_with_http_headers( $cgi, $cookie, $template->output, undef, { force_no_caching => 1 } ) if $error;
144
}
145
else {
146
    Koha::Plugins::Handler->run(
147
        {
148
            class  => $payment_method,
149
            method => 'opac_online_payment_begin',
150
            cgi    => $cgi,
151
        }
152
    );
153
}
(-)a/opac/opac-account.pl (-2 / +4 lines)
Lines 89-95 if ( C4::Context->config("enable_plugins") ) { Link Here
89
    });
89
    });
90
    # Only pass in plugins where opac online payment is enabled
90
    # Only pass in plugins where opac online payment is enabled
91
    @plugins = grep { $_->opac_online_payment } @plugins;
91
    @plugins = grep { $_->opac_online_payment } @plugins;
92
    $template->param( plugins => \@plugins );
92
    $template->param(
93
        plugins => \@plugins,
94
        payment_methods => scalar @plugins > 0
95
    );
93
}
96
}
94
97
95
output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 };
98
output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 };
96
- 

Return to bug 23215