Bug 17705

Summary: Payments with cards through payment terminal
Product: Koha Reporter: Radek Šiman (R-Bit Technology, s.r.o.) <rbit>
Component: Fines and feesAssignee: Radek Šiman (R-Bit Technology, s.r.o.) <rbit>
Status: Failed QA --- QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: black23, gmcharlt, josef.moravec, kyle.m.hall, marjorie.barry-vila
Version: Main   
Hardware: All   
OS: All   
GIT URL: Change sponsored?: ---
Patch complexity: --- Documentation contact:
Documentation submission: Text to go in the release notes:
Version(s) released in:
Circulation function:
Attachments: Bug 17705: Database structure update
Bug 17705: Database schema objects updated
Bug 17705: Database structure update
Bug 17705: Database schema objects updated
Bug 17705: payments using payment terminal
Bug 17705: Fixed forbidden patterns
Bug 17705: Fixed web installer problems
Bug 17705: Database structure update
Bug 17705: payments using payment terminal
Bug 17705: Update Schema

Description Radek Šiman (R-Bit Technology, s.r.o.) 2016-12-01 14:07:12 UTC
Allow patrons to pay their fees cashlessly using cards in payment terminals.
Comment 1 Radek Šiman (R-Bit Technology, s.r.o.) 2016-12-01 20:45:49 UTC
Currently working on a solution for terminals Ingenico iCT220 provided by GPE (Global Payments Europe)
Comment 2 Radek Šiman (R-Bit Technology, s.r.o.) 2017-05-17 13:52:17 UTC
Created attachment 63499 [details] [review]
Bug 17705: Database structure update

This patch creates neccessary table and updates systempreferences.

Test plan:
1) Apply the patch
2) Check the presence of pos_terminal_transactions table
3) Observe new systempreferences' values
   - PosTerminalIP
   - PosTerminalPort
   - PosTerminalCurrencyCode
Comment 3 Radek Šiman (R-Bit Technology, s.r.o.) 2017-05-17 14:04:55 UTC
Created attachment 63500 [details] [review]
Bug 17705: Database schema objects updated

Brings neccessary changes in the database schema.

Test plan:
1) Apply the patch
2) Open Koha/Schema/Result
3) Observe new relation in Accountline.pm
4) Check presence of PosTerminalTransaction.pm
Comment 4 Radek Šiman (R-Bit Technology, s.r.o.) 2017-06-22 08:23:32 UTC
Created attachment 64526 [details] [review]
Bug 17705: Database structure update

This patch creates neccessary table and updates systempreferences.

Test plan:
For the test plan please see commits above.
Comment 5 Radek Šiman (R-Bit Technology, s.r.o.) 2017-06-22 08:24:02 UTC
Created attachment 64527 [details] [review]
Bug 17705: Database schema objects updated

Brings neccessary changes in the database schema.

Test plan:
1) Apply the patch
2) Open Koha/Schema/Result
3) Observe new relation in Accountline.pm
4) Check presence of PosTerminalTransaction.pm
Comment 6 Radek Šiman (R-Bit Technology, s.r.o.) 2017-06-22 08:24:14 UTC
Created attachment 64528 [details] [review]
Bug 17705: payments using payment terminal

This patch expects already installed and configured payment terminal,
e.g Ingenico, provided by GPE (Global Payments Europe). This piece of
code already acquired an official certification in GPE Headquarter,
Prague, Czech Republic. Bank accounts connected to banks KB or CSOB
should work perfectly. Other banks will probably require additional
certifications and changes in the code.

Test plan
1) Appy this patch
2) Connect and/or start terminal device
3) Go to administration setting and look for "PosTerminal" items
4) Setup desired values (IP and port)
5) Make patron to pay a single fine (eg. lost book)
6) Tick the box "Pay by card" and confirm the payment
7) Popup window will raise displaying transaction status
8) Let the patron pay his amount using the terminal
9) When transaction finishes, close popup window
10) Optional: try to refund an amount by clicking "Refund to card"
button within fines overview (members/boraccount.pl). Steps 7-9 will
repeat accordingly.
Comment 7 Radek Šiman (R-Bit Technology, s.r.o.) 2017-06-22 08:24:27 UTC
Created attachment 64529 [details] [review]
Bug 17705: Fixed forbidden patterns

This patch only removes trailing space chars in
Koha/PosTerminal/Message/Header.pm
Comment 8 Michal Denar 2017-06-22 09:29:16 UTC
Anybody in other country need to pay in Koha via credit card? Please review code, maybe together we'll make solution universal for other terminals and payment providers. Feedback welcome.

Thanks to Radek for great work.
Comment 9 Radek Šiman (R-Bit Technology, s.r.o.) 2017-06-25 13:42:18 UTC
Created attachment 64613 [details] [review]
Bug 17705: Fixed web installer problems

This patch only fixes problems during web installation procedure

Test plan:
1) Apply the patch
2) Go through all webinstaller's steps
3) No SQL errors should occur
Comment 10 Josef Moravec 2018-06-25 09:03:04 UTC
Created attachment 76366 [details] [review]
Bug 17705: Database structure update

This patch creates neccessary table and updates systempreferences.

Test plan:
1) Apply the patch
2) Check the presence of pos_terminal_transactions table
3) Observe new systempreferences' values
   - PosTerminalIP
   - PosTerminalPort
   - PosTerminalCurrencyCode
Comment 11 Josef Moravec 2018-06-25 09:03:08 UTC
Created attachment 76367 [details] [review]
Bug 17705: payments using payment terminal

This patch expects already installed and configured payment terminal,
e.g Ingenico, provided by GPE (Global Payments Europe). This piece of
code already acquired an official certification in GPE Headquarter,
Prague, Czech Republic. Bank accounts connected to banks KB or CSOB
should work perfectly. Other banks will probably require additional
certifications and changes in the code.

Test plan
1) Appy this patch
2) Connect and/or start terminal device
3) Go to administration setting and look for "PosTerminal" items
4) Setup desired values (IP and port)
5) Make patron to pay a single fine (eg. lost book)
6) Tick the box "Pay by card" and confirm the payment
7) Popup window will raise displaying transaction status
8) Let the patron pay his amount using the terminal
9) When transaction finishes, close popup window
10) Optional: try to refund an amount by clicking "Refund to card"
button within fines overview (members/boraccount.pl). Steps 7-9 will
repeat accordingly.
Comment 12 Josef Moravec 2018-06-25 09:03:12 UTC
Created attachment 76368 [details] [review]
Bug 17705: Update Schema
Comment 13 Josef Moravec 2018-06-25 09:15:31 UTC
Comment on attachment 76367 [details] [review]
Bug 17705: payments using payment terminal

Review of attachment 76367 [details] [review]:
-----------------------------------------------------------------

Radek, I just rebased your patches and have some comments on this patch:

::: Koha/PosTerminal/Client.pm
@@ +15,5 @@
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with Koha; if not, see <http://www.gnu.org/licenses>.
> +

use Modern::Perl;

@@ +19,5 @@
> +
> +use IO::Socket::INET;
> +use IO::Socket::Timeout;
> +use Koha::PosTerminal::Message;
> +use Errno qw(ETIMEDOUT EWOULDBLOCK);

You are adding some new dependencies here, you should add them to C4/Installer/PerlDependecies.pm, are they all available also for Debian in needed versions?

::: Koha/PosTerminal/Message.pm
@@ +17,5 @@
> +# You should have received a copy of the GNU General Public License
> +# along with Koha; if not, see <http://www.gnu.org/licenses>.
> +
> +use strict;
> +use warnings;

use Modern::Perl;

@@ +22,5 @@
> +
> +use Digest::CRC;
> +use Koha::PosTerminal::Message::Header;
> +use Koha::PosTerminal::Message::Field;
> +use Data::Dumper qw( Dumper );

Don't forget to remove debug printing;

@@ +178,5 @@
> +        else {
> +            $self->setValid(0);
> +        }
> +    }
> +#    print Dumper($self);

Don't forget to remove debug printing;

@@ +221,5 @@
> +    my $msg = $self->getHeader()->dumpObject();
> +
> +    $msg .= "data:\n";
> +#    print Dumper($self);
> +#die();

Don't forget to remove debug printing;

::: Koha/PosTerminal/Message/Field.pm
@@ +17,5 @@
> +# You should have received a copy of the GNU General Public License
> +# along with Koha; if not, see <http://www.gnu.org/licenses>.
> +
> +use strict;
> +use warnings;

use Modern::Perl;

::: Koha/PosTerminal/Message/Header.pm
@@ +17,5 @@
> +# You should have received a copy of the GNU General Public License
> +# along with Koha; if not, see <http://www.gnu.org/licenses>.
> +
> +use strict;
> +use warnings;

use Modern::Perl;

::: koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt
@@ +75,5 @@
>            [% IF ( account.payment ) %]
>              <a href="boraccount.pl?action=reverse&amp;accountlines_id=[% account.accountlines_id %]&amp;borrowernumber=[% account.borrowernumber %]" class="btn btn-default btn-xs"><i class="fa fa-undo"></i> Reverse</a>
>              <a href="boraccount.pl?action=void&amp;accountlines_id=[% account.accountlines_id %]&amp;borrowernumber=[% account.borrowernumber %]" class="btn btn-default btn-xs"><i class="fa fa-ban"></i> Void</a>
> +            [% IF (account.amountoutstanding+0 + account.amount+0 != 0 ) %]
> +            <a href="boraccount.pl?action=reverse&amp;accountlines_id=[% account.accountlines_id %]&amp;borrowernumber=[% account.borrowernumber %]" class="btn btn-default btn-xs" onclick="refundPayment(this.href, [% account.accountlines_id %], [% -1*account.amount %]);return false;"><i class="fa fa-undo"></i> Refund to card</a>

Do not use onclick parameter

::: koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt
@@ +46,4 @@
>  [% END %]
>  
>  [% IF ( pay_individual ) %]
> +    <form name="payindivfine" id="payindivfine" method="post" onsubmit="return makePayment(this);" action="/cgi-bin/koha/members/paycollect.pl">

Do not use onsubmit parameter

@@ +105,5 @@
> +    <li>
> +        <label for="bycard">Pay by card: </label>
> +        <input type="checkbox" name="bycard" id="bycard" value="1"/>
> +    </li>
> +[% END %]

Consider using PAYMENT_TYPE authorised value

::: svc/pos_terminal
@@ +160,5 @@
> +
> +    # send abort message
> +    my $abort = new Koha::PosTerminal::Message(Koha::PosTerminal::Message::DIR_SENT);
> +    my $hdrAbort = $abort->getHeader();
> +die(Dumper($transaction ? $transaction->getHeader() : "BUBU"));

What does "BUBU" mean? :D
Comment 14 Katrin Fischer 2023-06-25 20:17:34 UTC
I wonder if this would be better achieved with a payment type plugin nowadays (like PayPal)