Committer: nnikulochkina
LJSUP-14234: Implement server part for shop payment pagesU trunk/bin/upgrading/en_LJ.dat U trunk/cgi-bin/LJ/Pay/Method/WebMoney.pm U trunk/templates/Shop/method/webmoney.tmpl
Modified: trunk/bin/upgrading/en_LJ.dat =================================================================== --- trunk/bin/upgrading/en_LJ.dat 2012-11-14 08:14:44 UTC (rev 12896) +++ trunk/bin/upgrading/en_LJ.dat 2012-11-14 08:44:13 UTC (rev 12897) @@ -6891,6 +6891,8 @@ pay.cart.unknownclothing=Unknown Clothing: [[name]] +pay.cart.webmoney.desc=LiveJournal Shop payment for order number [[cart]] + pay.cc.form.address.bubble-lite|staleness=1 pay.cc.form.address.bubble-lite=Enter your billing address. Modified: trunk/cgi-bin/LJ/Pay/Method/WebMoney.pm =================================================================== --- trunk/cgi-bin/LJ/Pay/Method/WebMoney.pm 2012-11-14 08:14:44 UTC (rev 12896) +++ trunk/cgi-bin/LJ/Pay/Method/WebMoney.pm 2012-11-14 08:44:13 UTC (rev 12897) @@ -28,29 +28,53 @@ sub get_page_params { my ($class, $cart) = @_; - my $remote = LJ::get_remote(); - my $amt = sprintf("%.02f", $cart->{amount}); - my $cart_owner = $cart->get_owner; - my $desc = "LiveJournal Shop payment for order number " . $cart->get_cart_as_string; - - my $form_intro = LJ::html_hidden( - 'LMI_PAYEE_PURSE' => $LJ::PAY_WEBMONEY_PURSE_ID, - 'LMI_PAYMENT_AMOUNT' => $amt, - 'LMI_PAYMENT_NO' => $cart->get_payid, - 'LMI_PAYMENT_DESC' => $desc, - 'LMI_SIM_MODE' => $LJ::PAY_WEBMONEY_TEST_SIM_MODE, - 'anum' => $cart->get_anum, - ); - my $form_action = BML::get_language() eq 'ru' ? 'https://merchant.webmoney.ru/lmi/payment.asp' : 'https://merchant.wmtransfer.com/lmi/payment.asp'; - return { - 'amt' => $amt, - 'form_action' => $form_action, - 'form_intro' => $form_intro, - }; + if (LJ::is_enabled('dengionline')) { + my $cart_id = $cart->get_cart_as_string(); + + my $result = LJ::DengiOnline->create_bill( + cart_id => $cart_id, + shop_method => code(), + phone => LJ::Request->post_param('phone_number'), + ); + + unless($result && $result->{status} && ($result->{status} eq 'OK')){ + LJ::Request->redirect("$LJ::SITEROOT/shop/cart.bml?pay_err=1&cart=$cart_id"); + } + + my %form_params = map {$_ => $result->{$_}} qw(LMI_PAYEE_PURSE LMI_PAYMENT_AMOUNT LMI_PAYMER_NUMBER + LMI_PAYMENT_NO LMI_PAYMENT_DESC LMI_MODE RND); + + return { + 'form_action' => $form_action, + %form_params, + 'LMI_PAYMENT_DESC' => LJ::Lang::ml('pay.cart.webmoney.desc', {cart => $cart_id}), + }; + + } else { + my $remote = LJ::get_remote(); + my $amt = sprintf("%.02f", $cart->{amount}); + my $cart_owner = $cart->get_owner; + my $desc = "LiveJournal Shop payment for order number " . $cart->get_cart_as_string; + + my $form_intro = LJ::html_hidden( + 'LMI_PAYEE_PURSE' => $LJ::PAY_WEBMONEY_PURSE_ID, + 'LMI_PAYMENT_AMOUNT' => $amt, + 'LMI_PAYMENT_NO' => $cart->get_payid, + 'LMI_PAYMENT_DESC' => $desc, + 'LMI_SIM_MODE' => $LJ::PAY_WEBMONEY_TEST_SIM_MODE, + 'anum' => $cart->get_anum, + ); + + return { + 'amt' => $amt, + 'form_action' => $form_action, + 'form_intro' => $form_intro, + }; + } } sub check_signature { Modified: trunk/templates/Shop/method/webmoney.tmpl =================================================================== --- trunk/templates/Shop/method/webmoney.tmpl 2012-11-14 08:14:44 UTC (rev 12896) +++ trunk/templates/Shop/method/webmoney.tmpl 2012-11-14 08:44:13 UTC (rev 12897) @@ -1,3 +1,9 @@ +<TMPL_UNLESS dengionline_disabled> + +<TMPL_INCLUDE name="templates/Shop/DengiOnline/Webmoney.tmpl"> + +<TMPL_ELSE> + <div class="b-wmpay"> <form action="<TMPL_VAR form_action>" method="post"> <TMPL_VAR form_intro> @@ -9,3 +15,5 @@ </form> </div> + +</TMPL_UNLESS> \ No newline at end of file