From: Bill Erickson Date: Wed, 14 Oct 2015 15:59:32 +0000 (-0400) Subject: LP#1474051 CRON script for clearing CC numbers X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=a8cb9b93402a140ee0b9037849cef2fae69cc72b;p=evergreen%2Fmasslnc.git LP#1474051 CRON script for clearing CC numbers Adds a new srfsh script which calls a new open-ils.storage API call which sets the cc_number value to NULL on all credit card payments older than the age specified in the srfsh script. Adds example CRON entry. Signed-off-by: Bill Erickson Signed-off-by: Kathy Lussier --- diff --git a/Open-ILS/examples/crontab.example b/Open-ILS/examples/crontab.example index 1060f77254..f68575d407 100644 --- a/Open-ILS/examples/crontab.example +++ b/Open-ILS/examples/crontab.example @@ -61,6 +61,9 @@ EG_BIN_DIR = /openils/bin # Run the hard due date updater 2 3 * * * . ~/.bashrc && $EG_BIN_DIR/update_hard_due_dates.srfsh +# Run the credit card number clearing script +#5 4 * * * . ~/.bashrc && $EG_BIN_DIR/clear_cc_number.srfsh + # Action/Trigger entries ---- # Runs all pending A/T events every half hour diff --git a/Open-ILS/src/Makefile.am b/Open-ILS/src/Makefile.am index 6c4cf07f07..00740f368b 100644 --- a/Open-ILS/src/Makefile.am +++ b/Open-ILS/src/Makefile.am @@ -69,6 +69,7 @@ core_scripts = $(examples)/oils_ctl.sh \ $(supportscr)/purge_holds.srfsh \ $(supportscr)/purge_circulations.srfsh \ $(supportscr)/purge_pending_users.srfsh \ + $(supportscr)/clear_cc_number.srfsh \ $(supportscr)/sitemap_generator \ $(srcdir)/extras/eg_config \ $(srcdir)/extras/openurl_map.pl \ @@ -271,6 +272,7 @@ ilscore-install: sed -i 's|BINDIR|@bindir@|g' '$(DESTDIR)@bindir@/long-overdue-status-update.pl' sed -i 's|SYSCONFDIR|@sysconfdir@|g' '$(DESTDIR)@bindir@/long-overdue-status-update.pl' sed -i 's|BINDIR|@bindir@|g' '$(DESTDIR)@bindir@/thaw_expired_frozen_holds.srfsh' + sed -i 's|BINDIR|@bindir@|g' '$(DESTDIR)@bindir@/clear_cc_number.srfsh' sed -i 's|LOCALSTATEDIR|@localstatedir@|g' '$(DESTDIR)@bindir@/oils_ctl.sh' sed -i 's|SYSCONFDIR|@sysconfdir@|g' '$(DESTDIR)@bindir@/oils_ctl.sh' diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/money.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/money.pm index 6507db95ba..d2db7ae8ad 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/money.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/money.pm @@ -522,4 +522,38 @@ __PACKAGE__->register_method( ); +sub clear_cc_number { + my $self = shift; + my $client = shift; + my $payment_age = shift; + + # using NOW() in the AGE() calculation lets us modify payments + # that occurred today without having to specify negative ages. + + my $sql = <<" SQL"; + UPDATE money.credit_card_payment + SET cc_number = NULL + WHERE AGE(NOW(), payment_ts) > ?::INTERVAL; + SQL + + my $sth = actor::user->db_Main->prepare_cached($sql); + $sth->execute($payment_age); + + return $sth->rows; +} + +__PACKAGE__->register_method( + api_name => 'open-ils.storage.money.clear_cc_number', + method => 'clear_cc_number', + api_level => 1, + signature => q/ + Credit card payments store the last 4 digits of the card + number. This API call set the credit card number field + to NULL to remove this data after the payment has + reached the specified age. + @param payment_age The age as a string. + / +); + + 1; diff --git a/Open-ILS/src/support-scripts/clear_cc_number.srfsh b/Open-ILS/src/support-scripts/clear_cc_number.srfsh new file mode 100755 index 0000000000..6939d7f836 --- /dev/null +++ b/Open-ILS/src/support-scripts/clear_cc_number.srfsh @@ -0,0 +1,2 @@ +#!BINDIR/srfsh +request open-ils.storage open-ils.storage.money.clear_cc_number "1 year"