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
=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
[ company_name => sub {
$conf->config('company_name', shift->agentnum)
} ],
+ [ company_address => sub {
+ $conf->config('company_address', shift->agentnum)
+ } ],
],
# next_bill_date
'cust_pkg' => [qw(
)],
#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
$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)
+ } ],
+ ],
};
}
'$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',
'$payby' => 'Payment method',
'$date' => 'Payment date',
'$payinfo' => 'Card/account# (masked)',
+ '$error' => 'Decline reason',
],
);
my @c = @{ $substitutions{'contact'} };