Bug 21701: Have PayPal optionally return to originating OPAC url rather than OPACBaseURL

This enhancement will allow a library to choose whether to use the alias of the
current OPAC or the value of OPACBaseURL as the return url when making payments
via PayPal.

To test:
Note: you need to have PayPal enabled on your system (either Sandbox mode or
Live) and be using an alias URL for your OPAC.

1. Apply the patch.
2. With the option "PayPalReturnURL" set to "OPACBaseURL", log into a card via
the OPAC and start the process to pay in PayPal (you can either complete the
payment or cancel from the PayPal page). When you are returned to the OPAC, the
domain will be the value of OPACBaseURL.
3. With the option "PayPalReturnURL" set to "OPAC's alias", repeat the above
sequence to make a payment in PayPal. When you are returned to the OPAC, the
domain will be your current alias.

Signed-off-by: Brendan Gallagher <brendan@bywatersolutions.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
David Kuhn 2018-11-08 08:58:37 -08:00 committed by Martin Renvoize
parent 300a7a8110
commit e4c8af4f35
No known key found for this signature in database
GPG Key ID: 422B469130441A0F
4 changed files with 26 additions and 1 deletions

View File

@ -0,0 +1,14 @@
$DBversion = 'XXX'; # will be replaced by the RM
if( CheckVersion( $DBversion ) ) {
# you can use $dbh here like:
# $dbh->do("INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES ('PayPalReturnURL','BaseURL','BaseURL|OPACAlias','Specify whether PayPal will return to the url specified in the OPACBaseURL option or to the OPAC\'s alias url.','Choice')" );
# or perform some test and warn
# if( !column_exists( 'biblio', 'biblionumber' ) ) {
# warn "There is something wrong";
# }
# Always end with this (adjust the bug info)
SetVersion( $DBversion );
print "Upgrade to $DBversion done (Bug 21701 - PayPal return URL option)\n";
}

View File

@ -482,6 +482,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `
('PatronQuickAddFields', '', NULL , 'A list of fields separated by "|" to be displayed along with mandatory fields in the patron quick add form if chosen at patron entry', 'Free' ),
('PayPalChargeDescription', 'Koha fee payment', NULL , 'This preference defines what the user will see the charge listed as in PayPal', 'Free'),
('PayPalPwd', '', NULL , 'Your PayPal API password', 'Free'),
('PayPalReturnURL','BaseURL','BaseURL|OPACAlias','Specify whether PayPal will return to the url specified in the OPACBaseURL option or to the OPAC\'s alias url.','Choice'),
('PayPalSandboxMode', '1', NULL , 'If enabled, the system will use PayPal''s sandbox server for testing, rather than the production server.', 'YesNo'),
('PayPalSignature', '', NULL , 'Your PayPal API signature', 'Free'),
('PayPalUser', '', NULL , 'Your PayPal API username ( email address )', 'Free'),

View File

@ -893,3 +893,10 @@ OPAC:
- "The patron should see the charge description as "
- pref: PayPalChargeDescription
class: long
-
- "After payment or cancellation, PayPal should return to the "
- pref: PayPalReturnURL
default: BaseURL
choices:
BaseURL: "OPACBaseURL"
OPACAlias: "OPAC's alias"

View File

@ -79,7 +79,10 @@ if ( $payment_method eq 'paypal' ) {
? 'https://api-3t.sandbox.paypal.com/nvp'
: 'https://api-3t.paypal.com/nvp';
my $opac_base_url = C4::Context->preference('OPACBaseURL');
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 } );