From a05515e6dedf4b9c228f10142f68d0fa41586527 Mon Sep 17 00:00:00 2001
From: Kyle M Hall
Date: Thu, 23 Jan 2014 15:18:29 -0500
Subject: [PATCH] Bug 11622 - Add ability to pay fees and fines from OPAC via PayPal
This patch adds the ability for a logged in user to pay fines and
fees from the OPAC via PayPal.
Test Plan:
1) Apply the patches for bug 6427
2) Apply this patch
3) Create a paypal developer account
4) Create two test accounts, a Personal account and a Business account
5) Enable PayPal in Sandbox mode via the system preferences.
6) Enter the business account API credentials into the new system
preferences.
7) Create a new patron, add some fines/fees
8) Log in as that patron in the OPAC
9) Choose to pay via PayPal, log in as the sandbox Personal account
10) Complete the transaction
11) Note the fee is now paid
---
Koha/Accounts/CreditTypes.pm | 10 +
.../prog/en/modules/admin/preferences/opac.pref | 30 ++
.../en/modules/opac-account-pay-return.tt | 392 +++++++++++++++++++
.../opac-tmpl/bootstrap/en/modules/opac-account.tt | 161 ++++++---
.../opac-tmpl/prog/en/includes/browser-strings.inc | 1 +
.../prog/en/modules/opac-account-pay-return.tt | 396 ++++++++++++++++++++
.../opac-tmpl/prog/en/modules/opac-account.tt | 179 +++++++---
opac/opac-account-pay-paypal-return.pl | 121 ++++++
opac/opac-account-pay.pl | 127 +++++++
opac/opac-account.pl | 1 -
10 files changed, 1325 insertions(+), 93 deletions(-)
create mode 100644 koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-account-pay-return.tt
create mode 100644 koha-tmpl/opac-tmpl/prog/en/modules/opac-account-pay-return.tt
create mode 100755 opac/opac-account-pay-paypal-return.pl
create mode 100755 opac/opac-account-pay.pl
diff --git a/Koha/Accounts/CreditTypes.pm b/Koha/Accounts/CreditTypes.pm
index 3916c72..0a888f9 100644
--- a/Koha/Accounts/CreditTypes.pm
+++ b/Koha/Accounts/CreditTypes.pm
@@ -58,6 +58,8 @@ sub IsValid {
|| $string eq Koha::Accounts::CreditTypes::Credit()
|| $string eq Koha::Accounts::CreditTypes::Forgiven() );
+ $is_valid ||= $string eq Koha::Accounts::CreditTypes::PayPal();
+
unless ($is_valid) {
$is_valid =
Koha::Database->new()->schema->resultset('AuthorisedValue')
@@ -108,6 +110,14 @@ sub Forgiven {
return 'FORGIVEN';
}
+=head2 PayPal
+
+=cut
+
+sub PayPal {
+ return 'PAYPAL';
+}
+
1;
=head1 AUTHOR
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref
index a75c7ef..027d8e6 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref
@@ -619,3 +619,33 @@ OPAC:
- pref: PatronSelfRegistrationAdditionalInstructions
type: textarea
class: html
+ Payments:
+ -
+ - pref: EnablePayPalOpacPayments
+ default: 1
+ choices:
+ yes: Allow
+ no: "Don't allow"
+ - "patrons to make payments from the OPAC via PayPal in"
+ - pref: PayPalSandboxMode
+ default: 1
+ choices:
+ yes: "Sandbox"
+ no: "Production"
+ - "mode."
+ -
+ - "The email address to recieve PayPal payments is "
+ - pref: PayPalUser
+ class: long
+ -
+ - "The password for the PayPal account to recieve payments is "
+ - pref: PayPalPwd
+ class: long
+ -
+ - "The signature for the PayPal account to recieve payments is "
+ - pref: PayPalSignature
+ class: long
+ -
+ - "The patron should see the charge description as "
+ - pref: PayPalChargeDescription
+ class: long
diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-account-pay-return.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-account-pay-return.tt
new file mode 100644
index 0000000..c61a591
--- /dev/null
+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-account-pay-return.tt
@@ -0,0 +1,392 @@
+[% USE Koha %]
+[% USE KohaDates %]
+[% USE Currency %]
+
+[% INCLUDE 'doc-head-open.inc' %][% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog › Your fines and charges
+[% INCLUDE 'doc-head-close.inc' %]
+[% BLOCK cssinclude %][% END %]
+
+
+
+
+[% INCLUDE 'masthead.inc' %]
+
+