working self-service self-payments!
authorivan <ivan>
Tue, 20 May 2003 05:43:47 +0000 (05:43 +0000)
committerivan <ivan>
Tue, 20 May 2003 05:43:47 +0000 (05:43 +0000)
FS/FS/ClientAPI/MyAccount.pm
FS/FS/cust_main.pm
fs_selfservice/FS-SelfService/cgi/make_payment.html
fs_selfservice/FS-SelfService/cgi/payment_results.html [new file with mode: 0644]
fs_selfservice/FS-SelfService/cgi/process_payment.html [deleted file]
fs_selfservice/FS-SelfService/cgi/selfservice.cgi

index 6e9bf23..e12e93b 100644 (file)
@@ -193,7 +193,7 @@ sub process_payment {
     my $new = new FS::cust_main { $cust_main->hash };
     $new->set( $_ => $p->{$_} )
       foreach qw( payname address1 address2 city state zip payinfo );
     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;
     $new->set( 'payby' => $p->{'auto'} ? 'CARD' : 'DCRD' );
     my $error = $new->replace($cust_main);
     return { 'error' => $error } if $error;
@@ -201,7 +201,7 @@ sub process_payment {
   }
 
   my $error = $cust_main->realtime_bop( 'CC', $p->{'amount'}, quiet=>1,
   }
 
   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 )
   );
     map { $_ => $p->{$_} }
       qw( payname address1 address2 city state zip payinfo )
   );
index 09c5647..7e2ff38 100644 (file)
@@ -33,7 +33,7 @@ use FS::Msgcat qw(gettext);
 
 @ISA = qw( FS::Record );
 
 
 @ISA = qw( FS::Record );
 
-$Debug = 0;
+$Debug = 1;
 #$Debug = 1;
 
 $import = 0;
 #$Debug = 1;
 
 $import = 0;
@@ -761,10 +761,15 @@ sub check {
       unless $self->payby =~ /^(BILL|PREPAY|CHEK|LECB)$/;
     $self->paydate('');
   } else {
       unless $self->payby =~ /^(BILL|PREPAY|CHEK|LECB)$/;
     $self->paydate('');
   } else {
-    $self->paydate =~ /^(\d{1,2})[\/\-](\d{2}(\d{2})?)$/
-      or return "Illegal expiration date: ". $self->paydate;
-    my $y = length($2) == 4 ? $2 : "20$2";
-    $self->paydate("$y-$1-01");
+    my( $m, $y );
+    if ( $self->paydate =~ /^(\d{1,2})[\/\-](\d{2}(\d{2})?)$/ ) {
+      ( $m, $y ) = ( $1, length($2) == 4 ? $2 : "20$2" );
+    } elsif ( $self->paydate =~ /^(20)?(\d{2})[\/\-](\d{2})[\/\-]\d+$/ ) {
+      ( $m, $y ) = ( $3, "20$2" );
+    } else {
+      return "Illegal expiration date: ". $self->paydate;
+    }
+    $self->paydate("$y-$m-01");
     my($nowm,$nowy)=(localtime(time))[4,5]; $nowm++; $nowy+=1900;
     return gettext('expired_card')
       if !$import && ( $y<$nowy || ( $y==$nowy && $1<$nowm ) );
     my($nowm,$nowy)=(localtime(time))[4,5]; $nowm++; $nowy+=1900;
     return gettext('expired_card')
       if !$import && ( $y<$nowy || ( $y==$nowy && $1<$nowm ) );
@@ -1438,6 +1443,11 @@ I<quiet> can be set true to surpress email decline notices.
 
 sub realtime_bop {
   my( $self, $method, $amount, %options ) = @_;
 
 sub realtime_bop {
   my( $self, $method, $amount, %options ) = @_;
+  if ( $Debug ) {
+    warn "$self $method $amount\n";
+    warn "  $_ => $options{$_}\n" foreach keys %options;
+  }
+
   $options{'description'} ||= 'Internet services';
 
   #pre-requisites
   $options{'description'} ||= 'Internet services';
 
   #pre-requisites
index 1d860f0..a1cda6d 100644 (file)
@@ -8,7 +8,7 @@
 <FONT SIZE=4>Make a payment</FONT><BR><BR>
 <FORM NAME="OneTrueForm" METHOD="POST" ACTION="<%=$selfurl%>" onSubmit="document.OneTrueForm.process.disabled=true">
 <INPUT TYPE="hidden" NAME="session" VALUE="<%=$session_id%>">
 <FONT SIZE=4>Make a payment</FONT><BR><BR>
 <FORM NAME="OneTrueForm" METHOD="POST" ACTION="<%=$selfurl%>" onSubmit="document.OneTrueForm.process.disabled=true">
 <INPUT TYPE="hidden" NAME="session" VALUE="<%=$session_id%>">
-<INPUT TYPE="hidden" NAME="action" VALUE="do_payment">
+<INPUT TYPE="hidden" NAME="action" VALUE="payment_results">
 <TABLE BGCOLOR="#cccccc">
 <TR>
   <TD ALIGN="right">Amount&nbsp;Due</TD>
 <TABLE BGCOLOR="#cccccc">
 <TR>
   <TD ALIGN="right">Amount&nbsp;Due</TD>
diff --git a/fs_selfservice/FS-SelfService/cgi/payment_results.html b/fs_selfservice/FS-SelfService/cgi/payment_results.html
new file mode 100644 (file)
index 0000000..92c8cf5
--- /dev/null
@@ -0,0 +1,18 @@
+<HTML><HEAD><TITLE>MyAccount</TITLE></HEAD>
+<BODY BGCOLOR="#eeeeee"><FONT SIZE=5>MyAccount</FONT><BR><BR>
+<%= $url = "$selfurl?session=$session_id;action="; ''; %>
+<TABLE BORDER=0 CELLPADDING=4><TR><TD VALIGN="top" HEIGHT=384 BGCOLOR="#dddddd">
+<A HREF="<%= $url %>myaccount">MyAccount</A><BR>
+<!-- <A HREF="<%= $url %>other">SomethingElse</A><BR> -->
+</TD><TD VALIGN="top">
+<FONT SIZE=4>Payment results</FONT><BR><BR>
+<%= if ( $error ) {
+  $OUT .= qq!<FONT SIZE="+1" COLOR="#ff0000">Error processing your payment: $error</FONT>!;
+} else {
+  $OUT .= 'Your payment was processed sucessfully.  Thank you.';
+} %>
+</TD></TR></TABLE>
+<HR>
+<FONT SIZE="-2">powered by <a href="http://www.sisd.com/freeside">freeside</a></FONT>
+</BODY></HTML>
+
diff --git a/fs_selfservice/FS-SelfService/cgi/process_payment.html b/fs_selfservice/FS-SelfService/cgi/process_payment.html
deleted file mode 100644 (file)
index e4946dc..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-<HTML><HEAD><TITLE>MyAccount</TITLE></HEAD>
-<BODY BGCOLOR="#eeeeee"><FONT SIZE=5>MyAccount</FONT><BR><BR>
-<%= $url = "$selfurl?session=$session_id;action="; ''; %>
-<TABLE BORDER=0 CELLPADDING=4><TR><TD VALIGN="top" HEIGHT=384 BGCOLOR="#dddddd">
-<A HREF="<%= $url %>myaccount">MyAccount</A><BR>
-<!-- <A HREF="<%= $url %>other">SomethingElse</A><BR> -->
-</TD><TD VALIGN="top">
-<FONT SIZE=4>Payment results</FONT><BR><BR>
-<%= if ( $error ) {
-  $OUT .= qq!<FONT SIZE="+1" COLOR="#ff0000">Error processing your payment: $error</FONT!;
-} else {
-  $OUT .= 'Your payment was processed sucessfully.  Thank you.';
-} %>
-</TD></TR></TABLE>
-<HR>
-<FONT SIZE="-2">powered by <a href="http://www.sisd.com/freeside">freeside</a></FONT>
-</BODY></HTML>
-
index 456d2dd..6d6716d 100644 (file)
@@ -55,7 +55,7 @@ if ( $cgi->param('session') eq 'login' ) {
 $session_id = $cgi->param('session');
 
 $cgi->param('action') =~
 $session_id = $cgi->param('session');
 
 $cgi->param('action') =~
-    /^(myaccount|view_invoice|make_payment|do_payment)$/
+    /^(myaccount|view_invoice|make_payment|payment_results)$/
   or die "unknown action ". $cgi->param('action');
 my $action = $1;
 
   or die "unknown action ". $cgi->param('action');
 my $action = $1;
 
@@ -95,7 +95,7 @@ sub make_payment {
   payment_info( 'session_id' => $session_id );
 }
 
   payment_info( 'session_id' => $session_id );
 }
 
-sub do_payment {
+sub payment_results {
 
   use Business::CreditCard;
 
 
   use Business::CreditCard;