diff options
author | mark <mark> | 2010-08-05 00:27:06 +0000 |
---|---|---|
committer | mark <mark> | 2010-08-05 00:27:06 +0000 |
commit | 06ddeb41d643967a612119732bdd67e5ea7e45a2 (patch) | |
tree | 549b9d00045fcf72bdcc04756091fe20a9f07ed2 /FS | |
parent | cf0f715a49586ee141193605e6dbf5ae6685cd58 (diff) |
error message in decline templates, RT#9507
Diffstat (limited to 'FS')
-rw-r--r-- | FS/FS/cust_main.pm | 5 | ||||
-rw-r--r-- | FS/FS/msg_template.pm | 25 |
2 files changed, 27 insertions, 3 deletions
diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm index 00016b7b8..fc7d6ae77 100644 --- a/FS/FS/cust_main.pm +++ b/FS/FS/cust_main.pm @@ -4622,8 +4622,11 @@ sub realtime_bop { my $msgnum = $conf->config('decline_msgnum', $self->agentnum); my $error = ''; if ( $msgnum ) { + # include the raw error message in the transaction state + $cust_pay_pending->setfield('error', $transaction->error_message); my $msg_template = qsearchs('msg_template', { msgnum => $msgnum }); - $error = $msg_template->send( 'cust_main' => $self ); + $error = $msg_template->send( 'cust_main' => $self, + 'object' => $cust_pay_pending ); } else { #!$msgnum diff --git a/FS/FS/msg_template.pm b/FS/FS/msg_template.pm index 1f98fa289..488d8833b 100644 --- a/FS/FS/msg_template.pm +++ b/FS/FS/msg_template.pm @@ -166,7 +166,7 @@ Customer object (required). =item object Additional context object (currently, can be a cust_main, cust_pkg, -cust_bill, svc_acct, or cust_pay object). +cust_bill, svc_acct, cust_pay, or cust_pay_pending object). =back @@ -322,6 +322,9 @@ sub substitutions { [ company_name => sub { $conf->config('company_name', shift->agentnum) } ], + [ company_address => sub { + $conf->config('company_address', shift->agentnum) + } ], ], # next_bill_date 'cust_pkg' => [qw( @@ -349,11 +352,13 @@ sub substitutions { )], #XXX not really thinking about cust_bill substitutions quite yet + # for welcome and limit warning messages 'svc_acct' => [qw( username ), [ password => sub { shift->getfield('_password') } ], - ], # for welcome messages + ], + # for payment receipts 'cust_pay' => [qw( paynum _date @@ -368,6 +373,22 @@ sub substitutions { $cust_pay->paymask : $cust_pay->decrypt($cust_pay->payinfo) } ], ], + # for payment decline messages + # try to support all cust_pay fields + # 'error' is a special case, it contains the raw error from the gateway + 'cust_pay_pending' => [qw( + _date + error + ), + [ 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) + } ], + ], }; } |