$svc_x = $svc_phone;
- } elsif ( $p->{'domain'} eq 'ip_mac' ) {
-
- my $svc_broadband = qsearchs( 'svc_broadband', { 'mac_addr' => $p->{'username'} } );
- return { error => 'IP address not found' }
- unless $svc_broadband;
- $svc_x = $svc_broadband;
-
} elsif ( $p->{email}
&& (my $contact = FS::contact->by_selfservice_email($p->{email}))
)
$return{$_} = $cust_main->bill_location->get($_)
for qw(address1 address2 city state zip);
+ $p->{'payment_payby'} = $payment_info->{paybys} if !$p->{'payment_payby'};
+
# look for stored cust_payby info
# only if we've been given a clear payment_payby (to avoid payname conflicts)
- if ($p->{'payment_payby'} =~ /^(CARD|CHEK)$/) {
- my @search_payby = ($p->{'payment_payby'} eq 'CARD') ? ('CARD','DCRD') : ('CHEK','DCHK');
+ if ($p->{'payment_payby'} =~ /^(CARD|CHEK)$/ || (ref($p->{'payment_payby'}))) {
+ my @search_payby = ();
+ if ($p->{'payment_payby'} eq 'CARD') { @search_payby = ('CARD','DCRD'); }
+ elsif ($p->{'payment_payby'} eq 'CHEK') { @search_payby = ('CHEK','DCHK'); }
+ elsif (ref($p->{'payment_payby'}) eq 'ARRAY') { @search_payby = @{$payment_info->{paybys}}; }
my ($cust_payby) = $cust_main->cust_payby(@search_payby);
if ($cust_payby) {
+ $return{payby} = $cust_payby->payby;
$return{payname} = $cust_payby->payname
|| ( $cust_main->first. ' '. $cust_main->get('last') );
$return{custpaybynum} = $cust_payby->custpaybynum;
$p->{'payinfo'} = $payinfo1. '@'. $payinfo2;
}
- # Perform update within a transaction
- local $FS::UID::AutoCommit = 0;
-
my $cust_payby = qsearchs('cust_payby', {
'custnum' => $custnum,
'custpaybynum' => $p->{'custpaybynum'},
next unless exists($p->{$field});
$cust_payby->set($field,$p->{$field});
}
+ $cust_payby->set( 'paymask' => $cust_payby->mask_payinfo );
- my $error = $cust_payby->replace;
+ # Update column if given a value, and the given value wasn't
+ # the value generated by $cust_main->masked($column);
+ $cust_main->set( $_, $p->{$_} )
+ for grep{ $p->{$_} !~ /^x/i; }
+ grep{ exists $p->{$_} }
+ qw/ss stateid/;
- if (!$error) {
- my $is_changed = 0;
- for my $field ( qw/ss stateid/ ) {
- next if !exists $p->{$field} || $p->{$field} =~ /^x/i;
- $cust_main->set( $field, $p->{$field} );
- $is_changed = 1;
- }
- $error = $cust_main->replace if $is_changed;
- }
+ # Perform updates within a transaction
+ local $FS::UID::AutoCommit = 0;
- if ( $error ) {
+ if ( my $error = $cust_payby->replace || $cust_main->replace ) {
dbh->rollback;
- return { 'error' => $error };
- } else {
- dbh->commit;
- return { 'custpaybynum' => $cust_payby->custpaybynum };
+ return { error => $error };
}
-
+
+ dbh->commit;
+ return { custpaybynum => $cust_payby->custpaybynum };
}
sub verify_payby {