fix new_customer_minimal, RT#34084
[freeside.git] / FS / FS / ClientAPI / Signup.pm
index 9d0bcf3..abfcac8 100644 (file)
@@ -2,6 +2,7 @@ package FS::ClientAPI::Signup;
 
 use strict;
 use vars qw( $DEBUG $me );
+use subs qw( _myaccount_cache );
 use Data::Dumper;
 use Tie::RefHash;
 use Digest::SHA qw(sha512_hex);
@@ -931,7 +932,6 @@ sub new_customer_minimal {
       'refnum'   => $packet->{refnum}
                     || $conf->config('signup_server-default_refnum'),
       'tagnum'   => [ FS::part_tag->default_tags ],
-      'payby'    => 'BILL',
 
       map { $_ => $packet->{$_} } qw(
         salesnum
@@ -941,6 +941,16 @@ sub new_customer_minimal {
 
   } );
 
+  if ( grep length($packet->{$_}), FS::cust_main->location_fields ) {
+    my $bill_hash;
+    foreach my $f (FS::cust_main->location_fields) {
+      $bill_hash->{$f} =  $packet->{$f};
+    }
+    my $bill_location = FS::cust_location->new($bill_hash);
+    $cust_main->set('bill_location' => $bill_location);
+    $cust_main->set('ship_location' => $bill_location);
+  }
+
   my @invoicing_list = $packet->{'invoicing_list'}
                          ? split( /\s*\,\s*/, $packet->{'invoicing_list'} )
                          : ();
@@ -1033,10 +1043,10 @@ sub new_customer_minimal {
 
   my $session_id;
   do {
-    $session_id = sha1_hex(time(). {}. rand(). $$)
+    $session_id = sha512_hex(time(). {}. rand(). $$)
   } until ( ! defined _myaccount_cache->get($session_id) ); #just in case
 
-  _cache->set( $session_id, $session, '1 hour' ); # 1 hour?
+  _myaccount_cache->set( $session_id, $session, '1 hour' ); # 1 hour?
 
   my %return = ( 'error'          => '',
                  'signup_service' => $svc_x,