Browse Source

Bug 16129: Remove URL::Encode dependency

This patch makes the PayPal integration feature independent from the
URL::Encode library, which is absent in some supported distributions.

It uses the URI package which is already a Koha dependency.

To test:
- Apply the patch
- Notice there are no deps for URL::Encode
- Follow the steps from the original patch
=> SUCCESS: It works as expected
- Sign-off :-D

Note: I deleted the line in which $amount_to_pay was url-encoded, because that's
one of the things query_form does (and the variable is only used as a parameter to it).

Sponsored-by: ByWater Solutions

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Brendan A Gallagher <brendan@bywatersolutions.com>
new_12478_elasticsearch
Tomas Cohen Arazi 6 years ago
committed by Brendan A Gallagher
parent
commit
da052b3d10
  1. 5
      C4/Installer/PerlDependencies.pm
  2. 11
      opac/opac-account-pay-paypal-return.pl
  3. 13
      opac/opac-account-pay.pl

5
C4/Installer/PerlDependencies.pm

@ -777,11 +777,6 @@ our $PERL_DEPS = {
'required' => '1',
'min_ver' => '1.10',
},
'URL::Encode' => {
'usage' => 'PayPal',
'required' => '0',
'min_ver' => '0.03',
},
'WWW::YouTube::Download' => {
'usage' => 'HTML5Media streaming from YouTube',
'required' => '0',

11
opac/opac-account-pay-paypal-return.pl

@ -24,7 +24,7 @@ use utf8;
use CGI;
use HTTP::Request::Common;
use LWP::UserAgent;
use URL::Encode qw(url_params_mixed);
use URI;
use C4::Auth;
use C4::Output;
@ -85,10 +85,13 @@ my $response = $ua->request( POST $url, $nvp_params );
my $error = q{};
if ( $response->is_success ) {
my $params = url_params_mixed( $response->decoded_content );
if ( $params->{ACK} eq "Success" ) {
$amount = $params->{PAYMENTINFO_0_AMT};
my $urlencoded = $response->content;
my %params = URI->new( "?$urlencoded" )->query_form;
if ( $params{ACK} eq "Success" ) {
$amount = $params{PAYMENTINFO_0_AMT};
my $accountlines_rs = Koha::Database->new()->schema()->resultset('Accountline');
foreach my $accountlines_id ( @accountlines ) {

13
opac/opac-account-pay.pl

@ -24,7 +24,6 @@ use Modern::Perl;
use CGI;
use HTTP::Request::Common;
use LWP::UserAgent;
use URL::Encode qw(url_encode url_params_mixed);
use URI;
use C4::Auth;
@ -64,8 +63,6 @@ my $error = 0;
if ( $payment_method eq 'paypal' ) {
my $ua = LWP::UserAgent->new;
my $amount = url_encode($amount_to_pay);
my $url =
C4::Context->preference('PayPalSandboxMode')
? 'https://api-3t.sandbox.paypal.com/nvp'
@ -74,7 +71,7 @@ if ( $payment_method eq 'paypal' ) {
my $opac_base_url = C4::Context->preference('OPACBaseURL');
my $return_url = URI->new( $opac_base_url . "/cgi-bin/koha/opac-account-pay-paypal-return.pl" );
$return_url->query_form( { amount => $amount, accountlines => \@accountlines } );
$return_url->query_form( { amount => $amount_to_pay, accountlines => \@accountlines } );
my $cancel_url = URI->new( $opac_base_url . "/cgi-bin/koha/opac-account.pl" );
@ -104,10 +101,12 @@ if ( $payment_method eq 'paypal' ) {
my $response = $ua->request( POST $url, $nvp_params );
if ( $response->is_success ) {
my $params = url_params_mixed( $response->decoded_content );
if ( $params->{ACK} eq "Success" ) {
my $token = $params->{TOKEN};
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')

Loading…
Cancel
Save