summaryrefslogtreecommitdiff
path: root/FS
diff options
context:
space:
mode:
authorMark Wells <mark@freeside.biz>2016-08-24 17:53:40 -0700
committerMark Wells <mark@freeside.biz>2016-08-24 17:53:40 -0700
commitca6723c5386d52f267ed3d84d58ae514e3adb683 (patch)
tree08c88215f84958c8de1a744e3c93dc0bc3f0beee /FS
parent5ed934c7206d2fc2aef1911ec29be83b9a028625 (diff)
but keep failed verification payments linked to their customers, #57135
Diffstat (limited to 'FS')
-rw-r--r--FS/FS/cust_main/Billing_Realtime.pm25
1 files changed, 18 insertions, 7 deletions
diff --git a/FS/FS/cust_main/Billing_Realtime.pm b/FS/FS/cust_main/Billing_Realtime.pm
index 3b7eea1f4..295136032 100644
--- a/FS/FS/cust_main/Billing_Realtime.pm
+++ b/FS/FS/cust_main/Billing_Realtime.pm
@@ -1870,10 +1870,19 @@ sub realtime_verify_bop {
if defined($options{payunique}) && length($options{payunique});
IMMEDIATE: {
- # open a separate handle for creating/updating the cust_pay_pending record
+ # open a separate handle for creating/updating the cust_pay_pending
+ # record
local $FS::UID::dbh = myconnect();
local $FS::UID::AutoCommit = 1;
+ # if this is an existing customer (and we can tell now because
+ # this is a fresh transaction), it's safe to assign their custnum
+ # to the cust_pay_pending record, and then the verification attempt
+ # will remain linked to them even if it fails.
+ if ( FS::cust_main->by_key($self->custnum) ) {
+ $cust_pay_pending->set('custnum', $self->custnum);
+ }
+
warn "inserting cust_pay_pending record for customer ". $self->custnum. "\n"
if $DEBUG > 1;
@@ -2100,12 +2109,14 @@ sub realtime_verify_bop {
# the cust_main)
###
- $cust_pay_pending->set('custnum', $self->custnum);
- my $set_custnum_err = $cust_pay_pending->replace;
- if ($set_custnum_err) {
- $log->error($set_custnum_err);
- $error ||= $set_custnum_err;
- # but if there was a real verification error also, return that one
+ if (!$cust_pay_pending->custnum) {
+ $cust_pay_pending->set('custnum', $self->custnum);
+ my $set_custnum_err = $cust_pay_pending->replace;
+ if ($set_custnum_err) {
+ $log->error($set_custnum_err);
+ $error ||= $set_custnum_err;
+ # but if there was a real verification error also, return that one
+ }
}
###