## get default cust_payby and change it. For old v3 selfservice that upgraded to v4. this is for v4 only
my ($cust_payby) = $cust_main->cust_payby();
- $p->{'custpaybynum'} = $cust_payby->custpaybynum;
- update_payby($p);
+ if ($cust_payby) {
+ $p->{'custpaybynum'} = $cust_payby->custpaybynum;
+ update_payby($p);
+ }
+ else {
+ insert_payby($p);
+ }
}
my $new = new FS::cust_main { $cust_main->hash };
$return{credit_card_surcharge_percentage} = $conf->config('credit-card-surcharge-percentage', $cust_main->agentnum);
$return{credit_card_surcharge_flatfee} = $conf->config('credit-card-surcharge-flatfee', $cust_main->agentnum);
+ # A value for 'payby' must be defined in %return
+ $return{payby} = $return{paybys}->[0]
+ if !$return{payby}
+ && ref $return{paybys}
+ && scalar @{ $return{paybys} };
+
return { 'error' => '',
%return,
};
my $payinfo2 = $1;
$p->{'payinfo'} = $payinfo1. '@'. $payinfo2;
}
+ elsif ($p->{'payby'} eq 'CARD') {
+ $p->{paydate} = $p->{year} . '-' . $p->{month} . '-01' unless $p->{paydate};
+ }
my $cust_payby = new FS::cust_payby {
'custnum' => $custnum,