pass a pkgnum from self-service if applicable, RT#4339
authorivan <ivan>
Thu, 30 Jul 2009 09:19:20 +0000 (09:19 +0000)
committerivan <ivan>
Thu, 30 Jul 2009 09:19:20 +0000 (09:19 +0000)
FS/FS/ClientAPI/MyAccount.pm
FS/FS/cust_main.pm

index 02b54ff..895b11d 100644 (file)
@@ -128,6 +128,8 @@ sub login {
   if ( $cust_pkg ) {
     my $cust_main = $cust_pkg->cust_main;
     $session->{'custnum'} = $cust_main->custnum;
+    $session->{'pkgnum'} = $cust_pkg->pkgnum
+      if $conf->exists('pkg-balances');
   }
 
   my $session_id;
@@ -518,6 +520,7 @@ sub process_payment {
     'payname'  => $payname,
     'paybatch' => $paybatch, #this doesn't actually do anything
     'paycvv'   => $paycvv,
+    'pkgnum'   => $session->{'pkgnum'},
     map { $_ => $p->{$_} } @{ $payby2fields{$payby} }
   );
   return { 'error' => $error } if $error;
@@ -560,9 +563,11 @@ sub realtime_collect {
   my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } )
     or return { 'error' => "unknown custnum $custnum" };
 
-  my $error = $cust_main->realtime_collect( 'method'     => $p->{'method'},
-                                            'session_id' => $p->{'session_id'},
-                                          );
+  my $error = $cust_main->realtime_collect(
+    'method'     => $p->{'method'},
+    'pkgnum'     => $session->{'pkgnum'},
+    'session_id' => $p->{'session_id'},
+  );
   return { 'error' => $error } unless ref( $error );
 
   return { 'error' => '', amount => $cust_main->balance, %$error };
index 9c13174..becb905 100644 (file)
@@ -3961,6 +3961,7 @@ sub realtime_bop {
     'payinfo'           => $payinfo,
     'paydate'           => $paydate,
     'recurring_billing' => $content{recurring_billing},
+    'pkgnum'            => $options{'pkgnum'},
     'status'            => 'new',
     'gatewaynum'        => ( $payment_gateway ? $payment_gateway->gatewaynum : '' ),
   };
@@ -4116,6 +4117,7 @@ sub realtime_bop {
        'payinfo'  => $payinfo,
        'paybatch' => $paybatch,
        'paydate'  => $paydate,
+       'pkgnum'   => $options{'pkgnum'},
     } );
     #doesn't hurt to know, even though the dup check is in cust_pay_pending now
     $cust_pay->payunique( $options{payunique} )
@@ -4629,7 +4631,7 @@ On failure returns an error message.
 
 Returns false or a hashref upon success.  The hashref contains keys popup_url reference, and collectitems.  The first is a URL to which a browser should be redirected for completion of collection.  The second is a reference id for the transaction suitable for the end user.  The collectitems is a reference to a list of name value pairs suitable for assigning to a html form and posted to popup_url.
 
-Available options are: I<method>, I<amount>, I<description>, I<invnum>, I<quiet>, I<paynum_ref>, I<payunique>, I<session_id>
+Available options are: I<method>, I<amount>, I<description>, I<invnum>, I<quiet>, I<paynum_ref>, I<payunique>, I<session_id>, I<pkgnum>
 
 I<method> is one of: I<CC>, I<ECHECK> and I<LEC>.  If none is specified
 then it is deduced from the customer record.
@@ -5002,6 +5004,7 @@ sub _new_realtime_bop {
     'payinfo'           => $options{payinfo},
     'paydate'           => $paydate,
     'recurring_billing' => $content{recurring_billing},
+    'pkgnum'            => $options{'pkgnum'},
     'status'            => 'new',
     'gatewaynum'        => $payment_gateway->gatewaynum || '',
     'session_id'        => $options{session_id} || '',
@@ -5248,6 +5251,7 @@ sub _realtime_bop_result {
        #'payinfo'  => $payinfo,
        'paybatch' => $paybatch,
        'paydate'  => $cust_pay_pending->paydate,
+       'pkgnum'   => $cust_pay_pending->pkgnum,
     } );
     #doesn't hurt to know, even though the dup check is in cust_pay_pending now
     $cust_pay->payunique( $options{payunique} )