diff options
author | Jonathan Prykop <jonathan@freeside.biz> | 2015-11-09 19:58:47 -0600 |
---|---|---|
committer | Jonathan Prykop <jonathan@freeside.biz> | 2015-11-09 20:01:47 -0600 |
commit | c6ca6b86737effb2e3475734753f3f02f2b095ed (patch) | |
tree | fd1f27eb23539f7deca8b2168ff472c5c8d57f73 /FS/FS/msg_template.pm | |
parent | 2faea9544ed6b2872ad458319ee35245e81e946a (diff) |
RT#36806: Add message template substitution to show last four digits of credit card number
Diffstat (limited to 'FS/FS/msg_template.pm')
-rw-r--r-- | FS/FS/msg_template.pm | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/FS/FS/msg_template.pm b/FS/FS/msg_template.pm index a45733a..01d4df3 100644 --- a/FS/FS/msg_template.pm +++ b/FS/FS/msg_template.pm @@ -462,6 +462,17 @@ my $usage_warning = sub { # If you add anything, be sure to add a description in # httemplate/edit/msg_template.html. sub substitutions { + my $payinfo_sub = sub { + my $obj = shift; + ($obj->payby eq 'CARD' || $obj->payby eq 'CHEK') + ? $obj->paymask + : $obj->decrypt($obj->payinfo) + }; + my $payinfo_end = sub { + my $obj = shift; + my $payinfo = &$payinfo_sub($obj); + substr($payinfo, -4); + }; { 'cust_main' => [qw( display_custnum agentnum agent_name @@ -608,11 +619,8 @@ sub substitutions { # overrides the one in cust_main in cases where a cust_pay is passed [ payby => sub { FS::payby->shortname(shift->payby) } ], [ date => sub { time2str("%a %B %o, %Y", shift->_date) } ], - [ payinfo => sub { - my $cust_pay = shift; - ($cust_pay->payby eq 'CARD' || $cust_pay->payby eq 'CHEK') ? - $cust_pay->paymask : $cust_pay->decrypt($cust_pay->payinfo) - } ], + [ 'payinfo' => $payinfo_sub ], + [ 'payinfo_end' => $payinfo_end ], ], # for refund receipts 'cust_refund' => [ @@ -620,11 +628,8 @@ sub substitutions { [ refund => sub { sprintf("%.2f", shift->refund) } ], [ payby => sub { FS::payby->shortname(shift->payby) } ], [ date => sub { time2str("%a %B %o, %Y", shift->_date) } ], - [ payinfo => sub { - my $cust_refund = shift; - ($cust_refund->payby eq 'CARD' || $cust_refund->payby eq 'CHEK') ? - $cust_refund->paymask : $cust_refund->decrypt($cust_refund->payinfo) - } ], + [ 'payinfo' => $payinfo_sub ], + [ 'payinfo_end' => $payinfo_end ], ], # for payment decline messages # try to support all cust_pay fields @@ -636,11 +641,8 @@ sub substitutions { [ paid => sub { sprintf("%.2f", shift->paid) } ], [ payby => sub { FS::payby->shortname(shift->payby) } ], [ date => sub { time2str("%a %B %o, %Y", shift->_date) } ], - [ payinfo => sub { - my $pending = shift; - ($pending->payby eq 'CARD' || $pending->payby eq 'CHEK') ? - $pending->paymask : $pending->decrypt($pending->payinfo) - } ], + [ 'payinfo' => $payinfo_sub ], + [ 'payinfo_end' => $payinfo_end ], ], }; } |