JBAS-2297 Support SIP check payments
authorBill Erickson <berickxx@gmail.com>
Wed, 12 Jun 2019 15:37:56 +0000 (15:37 +0000)
committerBill Erickson <berickxx@gmail.com>
Wed, 19 Jun 2019 16:33:49 +0000 (12:33 -0400)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/perlmods/lib/OpenILS/SIP.pm
Open-ILS/src/perlmods/lib/OpenILS/SIP/Transaction.pm
Open-ILS/src/perlmods/lib/OpenILS/SIP/Transaction/FeePayment.pm

index 500efa2..fab7163 100644 (file)
@@ -463,7 +463,8 @@ sub end_patron_session {
 
 sub pay_fee {
     my ($self, $patron_id, $patron_pwd, $fee_amt, $fee_type,
-    $pay_type, $fee_id, $trans_id, $currency) = @_;
+        $pay_type, $fee_id, $trans_id, $currency, $check_number, 
+        $register_login) = @_;
 
     $self->verify_session;
 
@@ -485,6 +486,8 @@ sub pay_fee {
     $xact->sip_payment_type($pay_type);
     # We don't presently use this, but we might in the future.
     $xact->patron_password($patron_pwd);
+    $xact->check_number($check_number);
+    $xact->register_login($register_login);
 
     $xact->do_fee_payment();
 
index 729182e..9d6564e 100644 (file)
@@ -27,6 +27,8 @@ my %fields = (
       editor        => undef,
       authtoken     => '',
       fee_ack       => 0,
+      check_number  => undef,
+      register_login => undef
 );
 
 our $AUTOLOAD;
index df424dd..827572d 100644 (file)
@@ -189,20 +189,45 @@ sub do_fee_payment {
 sub pay_bills {
     my ($self, $paymentref) = @_;
     my $user = $self->patron->{user};
-    if ($self->sip_payment_type eq '02' || $self->sip_payment_type eq '01') {
+    my $ptype = $self->sip_payment_type || '';
+    my $rlogin = $self->register_login || '';
+
+    my $params = {
+        userid => $user->id,
+        note => "Via SIP2",
+        payments => $paymentref,
+        payment_type => 'cash_payment'
+    };
+
+    if ($rlogin) {
+        syslog('LOG_DEBUG', "Register login sent as '$rlogin'"); 
+
+        if ($rlogin =~ /\\.+/) { # Windows domain login
+            my @parts = split(/\\/, $rlogin);
+            $rlogin = $parts[1];
+        }
+
+        $params->{note} = "Via SIP2: Register login '$rlogin'";
+    }
+
+    if ($ptype eq '02' || $ptype eq '01') {
         # '01' is "VISA"
         # '02' is "credit card"
-        my $transaction_id = $self->transaction_id ? $self->transaction_id : 'Not provided by SIP client';
-        return $U->simplereq('open-ils.circ', 'open-ils.circ.money.payment', $self->{authtoken},
-                             { payment_type => "credit_card_payment", userid => $user->id, note => "via SIP2",
-                               cc_args => { approval_code => $transaction_id, },
-                               payments => $paymentref}, $user->last_xact_id);
-    } else {
-        # record as "cash"
-        return $U->simplereq('open-ils.circ', 'open-ils.circ.money.payment', $self->{authtoken},
-                             { payment_type => "cash_payment", userid => $user->id, note => "via SIP2",
-                               payments => $paymentref}, $user->last_xact_id);
+
+        $params->{payment_type} = 'credit_card_payment';
+        $params->{cc_args} = {
+            approval_code => 
+                $self->transaction_id || 'Not provided by SIP client'
+        };
+
+    } elsif ($ptype eq '05') {
+        $params->{payment_type} = 'check_payment';
+        $params->{check_number} = 
+            $self->check_number || 'Not Provided by SIP Client';
     }
+
+    return $U->simplereq('open-ils.circ', 'open-ils.circ.money.payment', 
+        $self->{authtoken}, $params, $user->last_xact_id);
 }