cache initial signup_info for performance
[freeside.git] / FS / FS / ClientAPI / MyAccount.pm
index 2ce55a8..e12e93b 100644 (file)
@@ -17,11 +17,12 @@ use FS::cust_main_county;
 
 use FS::ClientAPI; #hmm
 FS::ClientAPI->register_handlers(
-  'MyAccount/login'         => \&login,
-  'MyAccount/customer_info' => \&customer_info,
-  'MyAccount/invoice'       => \&invoice,
-  'MyAccount/cancel'        => \&cancel,
-  'MyAccount/payment_info'  => \&payment_info,
+  'MyAccount/login'            => \&login,
+  'MyAccount/customer_info'    => \&customer_info,
+  'MyAccount/invoice'          => \&invoice,
+  'MyAccount/cancel'           => \&cancel,
+  'MyAccount/payment_info'     => \&payment_info,
+  'MyAccount/process_payment'  => \&process_payment,
 );
 
 #store in db?
@@ -175,7 +176,7 @@ sub payment_info {
 
 };
 
-sub make_payment{
+sub process_payment {
   my $p = shift;
 
   my $session = $cache->get($p->{'session_id'})
@@ -192,7 +193,7 @@ sub make_payment{
     my $new = new FS::cust_main { $cust_main->hash };
     $new->set( $_ => $p->{$_} )
       foreach qw( payname address1 address2 city state zip payinfo );
-    $new->set( 'paydate' => $p->{'month'}. '-'. $p->{'year'} );
+    $new->set( 'paydate' => $p->{'year'}. '-'. $p->{'month'}. '-01' );
     $new->set( 'payby' => $p->{'auto'} ? 'CARD' : 'DCRD' );
     my $error = $new->replace($cust_main);
     return { 'error' => $error } if $error;
@@ -200,7 +201,7 @@ sub make_payment{
   }
 
   my $error = $cust_main->realtime_bop( 'CC', $p->{'amount'}, quiet=>1,
-    'paydate' => $p->{'month'}. '-'. $p->{'year'},
+    'paydate' => $p->{'year'}. '-'. $p->{'month'}. '-01',
     map { $_ => $p->{$_} }
       qw( payname address1 address2 city state zip payinfo )
   );