ssafronova (ssafronova) wrote in changelog,
ssafronova
ssafronova
changelog

[ljcom] r10140: LJSUP-8014: Credit card payment process ...

Committer: ssafronova
LJSUP-8014: Credit card payment process refactoring - one-time shop page
U   trunk/ssldocs/pay/cc.bml
Modified: trunk/ssldocs/pay/cc.bml
===================================================================
--- trunk/ssldocs/pay/cc.bml	2011-02-28 10:30:11 UTC (rev 10139)
+++ trunk/ssldocs/pay/cc.bml	2011-02-28 11:12:09 UTC (rev 10140)
@@ -107,7 +107,20 @@
         return $ret;
     }
 
+    my $ccform;
+    $ccform = "<?h1 $ML{'.ccinfo.header'} h1?>";
+    if ($has_coppa && $cartobj->{amount} <= 0) {
+        $ccform .= "<?p " . BML::ml('.ccinfo.nocharge2', {'aopts' => "href='$LJ::SITEROOT/legal/coppa.bml'", 'amount' => $amt_pretty}) . " p?>";
+    } else {
+        $ccform .= "<?p " . BML::ml('.ccinfo.charge', {'legalname' => "<b>LiveJournal, Inc.</b>", 'sitename' => $LJ::SITENAME}) . " p?>";
+    }
+    $ccform .= "<?p " . BML::ml('.security.text', {'sitename' => $LJ::SITENAMESHORT}) . " p?>";
+    $ccform .= LJ::html_hidden("cart", $cart);
+    $ccform .= LJ::html_hidden("amt_charge", $amt_charge);
 
+    my $email = $remote ? $remote->email_raw : " ";
+    $email = $POST{email} || $email;
+
     ### POST: authorize/capture
 
     my $err;
@@ -496,8 +509,22 @@
         }
 
         # process credit card form fields
-        my $formerr; return $error->($formerr) 
-            unless LJ::Widget::CreditCard::validate(\%POST, \$formerr) || $LJ::DEBUG{'no_cc_needed'};
+        my ($formerr, $err_field);
+        unless (LJ::Widget::CreditCard::validate(\%POST, \$formerr, \$err_field) || $LJ::DEBUG{'no_cc_needed'}) {
+
+            $ccform .= "<?errorbar $formerr (field: $err_field) errorbar?>";
+            $ccform .= LJ::Widget::CreditCard::render( LJ::Pay::RecBill->valid_countries, $formerr, \%POST, undef,
+                              {
+                                  'cvv2' => 1,
+                                  'has_coppa' => $has_coppa,
+                              }
+                            );
+
+            $ccform .= "</form>";
+
+            $ret .= $ccform;
+            return $ret;
+        }
  
         # send fraud watch emails if necessary
         LJ::Pay::send_fraud_email($cartobj, $u);
@@ -668,28 +695,17 @@
         return $success->();
     }
 
-    $ret .= "<?h1 $ML{'.ccinfo.header'} h1?>";
-    if ($has_coppa && $cartobj->{amount} <= 0) {
-        $ret .= "<?p " . BML::ml('.ccinfo.nocharge2', {'aopts' => "href='$LJ::SITEROOT/legal/coppa.bml'", 'amount' => $amt_pretty}) . " p?>";
-    } else {
-        $ret .= "<?p " . BML::ml('.ccinfo.charge', {'legalname' => "<b>LiveJournal, Inc.</b>", 'sitename' => $LJ::SITENAME}) . " p?>";
-    }
-    $ret .= "<?p " . BML::ml('.security.text', {'sitename' => $LJ::SITENAMESHORT}) . " p?>";
-    $ret .= LJ::html_hidden("cart", $cart);
-    $ret .= LJ::html_hidden("amt_charge", $amt_charge);
-
-    my $email = $remote ? $remote->email_raw : " ";
-    $email = $POST{email} || $email;
-
-    $ret .= LJ::Widget::CreditCard::render( LJ::Pay::RecBill->valid_countries, $err, \%POST, undef,
+    # $err was filled in did_post() condition body
+    $ccform .= LJ::Widget::CreditCard::render( LJ::Pay::RecBill->valid_countries, $err, \%POST, undef,
                               {
                                   'cvv2' => 1,
                                   'has_coppa' => $has_coppa,
                               }
                             );
 
-    $ret .= "</form>";
+    $ccform .= "</form>";
 
+    $ret .= $ccform;
     return $ret;
 
 }

Tags: bml, ljcom, ssafronova
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