журнал (shhh) wrote in changelog,
журнал
shhh
changelog

[ljcom] r12899: LJSUP-14234: Implement server part for s...

Committer: nnikulochkina
LJSUP-14234: Implement server part for shop payment pages
U   trunk/cgi-bin/LJ/Pay/Method/CreditCard.pm
U   trunk/cgi-bin/LJ/Widget/CreditCard.pm
U   trunk/ssldocs/pay/cc.bml
U   trunk/templates/Shop/method/cc.tmpl
Modified: trunk/cgi-bin/LJ/Pay/Method/CreditCard.pm
===================================================================
--- trunk/cgi-bin/LJ/Pay/Method/CreditCard.pm	2012-11-14 09:18:23 UTC (rev 12898)
+++ trunk/cgi-bin/LJ/Pay/Method/CreditCard.pm	2012-11-14 11:18:55 UTC (rev 12899)
@@ -62,6 +62,11 @@
         }
     );
 
+    my $template_params = {
+        'amt_charge' => $amt_charge, 
+        'cart_id' => $cart_id,
+    };
+
     if (LJ::is_enabled('dengionline')) {
         if ( grep /$type/, @LJ::DENGIONLINE_VALID_CARDS) {
             my $result = LJ::DengiOnline->create_bill (
@@ -72,26 +77,24 @@
             unless ($result && $result->{status} &&
                     $result->{status} eq 'OK') {
                 LJ::Request->redirect("$LJ::SITEROOT/shop/cart.bml?pay_err=1&cart=${cart_id}");
-                return;  
+                return;
             }
             
+            $template_params->{iframe} = 1;
+
             $html = LJ::Widget::CreditCard::render_iframe('url' => $result->{url});
 
         } else {
 
-            $html = LJ::Widget::CreditCard::render_form(@params);
+            $html = LJ::Widget::CreditCard::render_new(@params);
 
         }
     } else {
         $err  = '';
-        $html = 
-            "<form method='post' action='$LJ::SSLROOT/pay/cc.bml?c=$cart_id' id='ccform'>"
-            . LJ::html_hidden("amt_charge", $amt_charge)
-            . LJ::Widget::CreditCard::render(@params)
-            . "</form>";
+        $html = LJ::Widget::CreditCard::render(@params);
     }
 
-    return { cc_payment_widget => $html };
+    return { cc_payment_widget => $html, %$template_params };
 }
 
 1;

Modified: trunk/cgi-bin/LJ/Widget/CreditCard.pm
===================================================================
--- trunk/cgi-bin/LJ/Widget/CreditCard.pm	2012-11-14 09:18:23 UTC (rev 12898)
+++ trunk/cgi-bin/LJ/Widget/CreditCard.pm	2012-11-14 11:18:55 UTC (rev 12899)
@@ -13,6 +13,8 @@
 # pay.css and pay.js
 sub render {
     my ( $countries, $err, $POST, $card, $opts ) = @_;
+    
+    return render_new(@_) if LJ::is_enabled('dengionline');
 
     my $remote = LJ::get_remote();
 
@@ -307,7 +309,7 @@
 }
 
 
-sub render_form {
+sub render_new {
     my ( $countries, $err, $POST, $card, $opts ) = @_;
 
     $opts ||= {};
@@ -316,6 +318,8 @@
 
     LJ::need_res(need_res());
 
+    LJ::need_res('stc/widgets/dengionline.css');
+
     # init some vars
     my ($name, $exp_m, $exp_y, @exp_yrs);
     if ( $card ) {
@@ -351,8 +355,11 @@
                                            die_on_bad_params => 0,
                                            strict => 0,
                                            ) or die "Can't open template: $!";
+
     $template->param(
         %$opts,
+        'selected_type' => $POST->{type},
+        'valid_cards'   => [map { {card_type => $_} } LJ::Pay::RecBill->valid_cards], 
         'cc_num'        => $POST->{cc_num} || ($LJ::IS_DEV_SERVER && '4111111111111111'),
         'show_cvv2'     => $opts->{cvv2},
         'cc_cvv2'       => $POST->{cc_cvv2} || ($LJ::IS_DEV_SERVER && '123'),

Modified: trunk/ssldocs/pay/cc.bml
===================================================================
--- trunk/ssldocs/pay/cc.bml	2012-11-14 09:18:23 UTC (rev 12898)
+++ trunk/ssldocs/pay/cc.bml	2012-11-14 11:18:55 UTC (rev 12899)
@@ -134,6 +134,7 @@
                           {
                               'cvv2' => 1,
                               'has_coppa' => $has_coppa,
+                              'type' => $POST{type},
                           }
                         );
 
@@ -714,6 +715,7 @@
                               {
                                   'cvv2' => 1,
                                   'has_coppa' => $has_coppa,
+                                  'type' => $POST{type},
                               }
                             );
 

Modified: trunk/templates/Shop/method/cc.tmpl
===================================================================
--- trunk/templates/Shop/method/cc.tmpl	2012-11-14 09:18:23 UTC (rev 12898)
+++ trunk/templates/Shop/method/cc.tmpl	2012-11-14 11:18:55 UTC (rev 12899)
@@ -1,3 +1,16 @@
 <div class="b-ccpay">
+<TMPL_IF iframe> 
+
+        <TMPL_VAR cc_payment_widget>
+
+<TMPL_ELSE>
+
+<form method="post" action="<TMPL_VAR LJ_SSLROOT>/pay/cc.bml?c=<TMPL_VAR cart_id>" id="ccform" class="confirm-form">
+        <input type="hidden" name="amt_charge" value="<TMPL_VAR amt_charge>">
 	<TMPL_VAR cc_payment_widget>
+</form>
+
+</TMPL_IF>
+
 </div>
+

Tags: bml, ljcom, nikulochkina, nnikulochkina, pm, tmpl
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