Igor Gariev (gariev) wrote in changelog,
Igor Gariev
gariev
changelog

[ljcom] r10706: LJSUP-9170: Need to create ability to ch...

Committer: gariev
LJSUP-9170: Need to create ability to change status of Credit Card for recurring payments (for Dev environment)
U   trunk/bin/maint/expiring.pl
U   trunk/cgi-bin/LJ/Pay/Transaction/Dummy.pm
Modified: trunk/bin/maint/expiring.pl
===================================================================
--- trunk/bin/maint/expiring.pl	2011-06-28 06:41:50 UTC (rev 10705)
+++ trunk/bin/maint/expiring.pl	2011-06-28 08:49:13 UTC (rev 10706)
@@ -118,7 +118,6 @@
             my $rv = eval { $rec->extend_account(\$retry_flag) };
 
             unless ($rv) {
-
                 if ($@ =~ /unable to find Profile ID/){
                     ## User does not have Cybersource Profile ID.
 
@@ -131,7 +130,8 @@
                     $next->();
                 }
 
-                $rec->log_statushistory("Serious error extending user account. Aborting.");
+                warn $@;
+                $rec->log_statushistory("Serious error extending user account ($@). Aborting.");
 
                 # otherwise, a more serious error occurred, we should
                 # abort so it can be investigated.

Modified: trunk/cgi-bin/LJ/Pay/Transaction/Dummy.pm
===================================================================
--- trunk/cgi-bin/LJ/Pay/Transaction/Dummy.pm	2011-06-28 06:41:50 UTC (rev 10705)
+++ trunk/cgi-bin/LJ/Pay/Transaction/Dummy.pm	2011-06-28 08:49:13 UTC (rev 10706)
@@ -24,47 +24,77 @@
 }
 
 my %default_ok_response = (
-    req_status  => 'success',
-    auth_status => 'pass',
+    req_status      => 'success',
+    auth_status     => 'pass',
+    req_status_code => 100,
 );
 
+my %default_err_response = (
+    req_status          => 'fail',
+    auth_status         => 'fail',
+    req_status_code     => 204,
+    auth_status_reason  => 'Insufficient funds in the account',
+    req_status_str      => 'Insufficient funds in the account',
+);
+
+sub _should_retry {
+    my $self = shift;
+    my $rv = shift;
+    
+    return 0 if ( $rv->{req_status} eq 'success' );
+    return 0 if ( $rv->{req_status_code} =~ /(100|101|102|200|201|202|203|204|205|208|209|210|211|221|230|231|232|233|234|235|237|238|239|240|241|242|243|246|247)/ );
+    return 1;
+}
+
+sub _default { 
+    return ($LJ::Pay::Transaction::Dummy::FAIL) 
+        ? \%default_err_response 
+        : \%default_ok_response 
+}
+
 # transaction types
-sub authorize    { return \%default_ok_response }
+sub authorize    { _default(); }
 
-sub capture      { return \%default_ok_response }
-sub reverse      { return \%default_ok_response }
+sub capture      { _default(); }
+sub reverse      { _default(); }
 sub refund       { 
-    return {
-        %default_ok_response,
-        refund_status=>'success',
-        order_id    => 123, 
-        order_token => 123
-    };
+    return ($LJ::Pay::Transaction::Dummy::FAIL)
+        ? \%default_err_response
+        : {
+            %default_ok_response,
+            refund_status=>'success',
+            order_id    => 123, 
+            order_token => 123
+        };
 }
 
 # recurring account management
 sub create_acct  { 
-    return {
-        %default_ok_response,
-        profileID   => 123,
-        code        => 0,
-        severity    => 'Info',
-        desc        => 'Success',
-    }; 
+    return ($LJ::Pay::Transaction::Dummy::FAIL)
+        ? \%default_err_response
+        : {
+            %default_ok_response,
+            profileID   => 123,
+            code        => 0,
+            severity    => 'Info',
+            desc        => 'Success',
+        }; 
 }
 sub update_acct  { 
-    return {
-        %default_ok_response,
-        code        => 0,
-        severity    => 'Info',
-        desc        => 'Success',
-    }; 
+    return ($LJ::Pay::Transaction::Dummy::FAIL)
+        ? \%default_err_response 
+        : {
+            %default_ok_response,
+            code        => 0,
+            severity    => 'Info',
+            desc        => 'Success',
+        }; 
 }
 
 sub delete_acct  { \%default_ok_response }
 sub enable_acct  { \%default_ok_response }
 sub disable_acct { \%default_ok_response }
-sub charge_acct  { \%default_ok_response }
+sub charge_acct  { _default(); }
 
 sub account_created {
     my ($self, $u) = @_;

Tags: gariev, ljcom, pl, pm
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments