summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormark <mark>2010-08-05 00:24:57 +0000
committermark <mark>2010-08-05 00:24:57 +0000
commit824b97e97e4e5ee914a4c936815a4413def71a4f (patch)
tree3ee04ed2a17ea95ba46e0c77236f6d2367d6ec62
parent42a1267af992831cb8069835a18b8672a5f9afcb (diff)
error message in decline templates, RT#9507
-rw-r--r--FS/FS/cust_main.pm5
-rw-r--r--FS/FS/msg_template.pm25
-rw-r--r--httemplate/edit/msg_template.html2
3 files changed, 29 insertions, 3 deletions
diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm
index b1bf1791c..5898a6a07 100644
--- a/FS/FS/cust_main.pm
+++ b/FS/FS/cust_main.pm
@@ -5116,8 +5116,11 @@ sub _realtime_bop_result {
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 7d507f4fb..d1db17dbc 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
@@ -324,6 +324,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(
@@ -351,11 +354,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
@@ -370,6 +375,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)
+ } ],
+ ],
};
}
diff --git a/httemplate/edit/msg_template.html b/httemplate/edit/msg_template.html
index 67eae185d..c38c40e4a 100644
--- a/httemplate/edit/msg_template.html
+++ b/httemplate/edit/msg_template.html
@@ -51,6 +51,7 @@ my %substitutions = (
'$ucfirst_cust_status' => 'Status, capitalized',
'$cust_statuscolor' => 'Status color code',
'$company_name' => 'Our company name',
+ '$company_address'=> 'Our company address',
],
'contact' => [ # duplicate this for shipping
'$name' => 'Company and contact name',
@@ -101,6 +102,7 @@ my %substitutions = (
'$payby' => 'Payment method',
'$date' => 'Payment date',
'$payinfo' => 'Card/account# (masked)',
+ '$error' => 'Decline reason',
],
);
my @c = @{ $substitutions{'contact'} };