Committer: gprochaev
LJSUP-6582. Custom Userheads: SMS payments. Server side.U trunk/bin/upgrading/en_LJ.dat U trunk/cgi-bin/LJ/Widget/IPPU/VGiftSmsPay.pm U trunk/cgi-bin/LJ/Widget/Shop/View/UserHeads.pm U trunk/htdocs/admin/userheads/stat.bml U trunk/htdocs/js/pay.js
Modified: trunk/bin/upgrading/en_LJ.dat =================================================================== --- trunk/bin/upgrading/en_LJ.dat 2010-08-27 07:13:29 UTC (rev 9426) +++ trunk/bin/upgrading/en_LJ.dat 2010-08-27 07:15:56 UTC (rev 9427) @@ -5411,6 +5411,8 @@ shop.view.userheads.important=Each purchased custom userhead will be available for a year in your “Userheads Collection” at “Edit Profile” page. +shop.view.userheads.smspay.title=Pay by SMS + shop.view.userheads.warning.disabled.anon=You have not logged in, so you cannot buy the Disk Quota addon. Please log in using the form above to purchase it. shop.view.userpics.label.userpics=+[[userpics]] [[?userpics|userpic|userpics|userpics]] @@ -9022,6 +9024,12 @@ widget.verticalsummary.nosubject=No Subject +widget.userhead.sms.to_pay=To pay for the userhead, please send SMS with text + +widget.userhead.sms.to=to + +widget.userhead.sms.prices=<span style="color:#FF0000;">Attention!</span> Prices and conditions of use are available <a [[aopts]]>here</a> + widget.vgift.sms.prices|staleness=1 widget.vgift.sms.prices=<span style="color:#FF0000;">Attention!</span> Prices and conditions of use are available <a [[aopts]]>here</a> Modified: trunk/cgi-bin/LJ/Widget/IPPU/VGiftSmsPay.pm =================================================================== --- trunk/cgi-bin/LJ/Widget/IPPU/VGiftSmsPay.pm 2010-08-27 07:13:29 UTC (rev 9426) +++ trunk/cgi-bin/LJ/Widget/IPPU/VGiftSmsPay.pm 2010-08-27 07:15:56 UTC (rev 9427) @@ -1,4 +1,4 @@ -package LJ::Widget::IPPU::VGiftSmsPay; +package LJ::Widget::IPPU::VGiftSmsPay; use strict; use base qw(LJ::Widget::IPPU); Modified: trunk/cgi-bin/LJ/Widget/Shop/View/UserHeads.pm =================================================================== --- trunk/cgi-bin/LJ/Widget/Shop/View/UserHeads.pm 2010-08-27 07:13:29 UTC (rev 9426) +++ trunk/cgi-bin/LJ/Widget/Shop/View/UserHeads.pm 2010-08-27 07:15:56 UTC (rev 9427) @@ -8,6 +8,13 @@ sub get_subpage { 'userhead' } sub require_remote { 0 } +sub need_res { + my $self = shift; + + LJ::need_res(qw(js/widget_ippu/userheadsmspay.js)); + $self->SUPER::need_res(); +} + sub premature_checks { my ($self) = @_; @@ -50,11 +57,26 @@ map { $_->user } ($remote->people_friends) : (); my $js_complete = LJ::JSUtil::autocomplete(list => \@flist); + # Initialize some javascript variables + my $authtoken = LJ::Auth->ajax_auth_token(LJ::get_remote(), "/_widget"); + $authtoken = LJ::ejs($authtoken); + + my $uhs = LJ::UserHead->get_all_userheads (1); + $uhs = [ + map { + my $sup_sms = + $_->get_price == 1.99 && + LJ::Pay::can_use_sup_sms($remote); + $_->{sup_sms} = $sup_sms; + $_; + } @$uhs + ]; + my %ret = ( siteroot => $LJ::SITEROOT, is_gift => $gift, is_self_disabled => $self->gift_only, - userheads => LJ::UserHead->get_all_userheads (1), + userheads => $uhs, default_page => $gift && LJ::u_equals($remote, $recipient) ? 'gift' : $gift && $recipient ? 'self' : 'gift', rcpt_username => $recipient && $recipient->user, thispage => "$LJ::SITEROOT/shop/userheads.bml", @@ -71,6 +93,8 @@ giveafter_yyyy => LJ::Request->post_param('giveafter_yyyy') || ($year + 1900), js_complete => $js_complete, + auth_token => $authtoken, + smspay_title => LJ::Lang::ml('shop.view.userheads.smspay.title'), ); @@ -89,6 +113,8 @@ $self->raise_errors(LJ::Lang::ml('shop.error.userhead.nothing_selected')) unless $uh; + $self->raise_errors(LJ::Lang::ml('shop.error.userhead.nothing_selected')) unless $uh; + my $recipient = (LJ::Request->get_param('gift') and LJ::Request->get_param('giftto')) ? LJ::load_user(LJ::Request->get_param('giftto')) Modified: trunk/htdocs/admin/userheads/stat.bml =================================================================== --- trunk/htdocs/admin/userheads/stat.bml 2010-08-27 07:13:29 UTC (rev 9426) +++ trunk/htdocs/admin/userheads/stat.bml 2010-08-27 07:15:56 UTC (rev 9427) @@ -73,9 +73,6 @@ my %uh_stat = (); foreach my $item (@$userheads) { my $u = LJ::load_userid($item->{userid}); - warn $item->{userid}; - warn LJ::SUP->is_sup_enabled($u) ? "SUP" : "NonSUP"; - warn $POST{nonsup}; if ((LJ::SUP->is_sup_enabled($u) and $POST{'sup'}) or (!LJ::SUP->is_sup_enabled($u) and $POST{nonsup})) { $uh_stat{$item->{subitem}}{qty} += $item->{qty}; $uh_stat{$item->{subitem}}{amt} += $item->{amt}; Modified: trunk/htdocs/js/pay.js =================================================================== --- trunk/htdocs/js/pay.js 2010-08-27 07:13:29 UTC (rev 9426) +++ trunk/htdocs/js/pay.js 2010-08-27 07:15:56 UTC (rev 9427) @@ -292,6 +292,20 @@ } }, + userheadsPaySms_click: function(e, userhead_id) + { + jQuery.event.fix(e).preventDefault(); + + new LJWidgetIPPU_UserheadSmsPay({ + title: this.ml_userheadsSmsPayTitle, + authToken: this.authToken + }, { + 'Widget[IPPU_UserHeadSmsPay]_id': userhead_id, + 'Widget[IPPU_UserHeadSmsPay]_to': LiveJournal.parseGetArgs(location+'').giftto || '', + _widget_post: 1 + }); + }, + pageDiskquota: function() { jQuery('#shop_diskquota .b-buy-onetime input:radio').change(function()