[ljcom] r12854: LJSUP-12412: Implement 'Dengi online' pa...
Committer: wisest-owl
LJSUP-12412: Implement 'Dengi online' payment system in LiveJournal ShopU trunk/bin/upgrading/en_LJ.dat U trunk/cgi-bin/LJ/Pay/Method/CreditCard.pm U trunk/cgi-bin/LJ/Pay/Method/PayPal.pm U trunk/cgi-bin/LJ/Pay/Method/Wallet.pm U trunk/cgi-bin/LJ/Pay/Method/WebMoney.pm U trunk/cgi-bin/LJ/Pay/Method/YandexMoney.pm U trunk/cgi-bin/LJ/Pay/Method.pm U trunk/cgi-bin/LJ/Widget/Payment.pm U trunk/cgi-bin/LJ/Widget/Shop/Cart.pm
Modified: trunk/bin/upgrading/en_LJ.dat
===================================================================
--- trunk/bin/upgrading/en_LJ.dat 2012-10-31 08:37:09 UTC (rev 12853)
+++ trunk/bin/upgrading/en_LJ.dat 2012-10-31 12:28:20 UTC (rev 12854)
@@ -11494,6 +11494,8 @@
shop.cart.label.method|staleness=1
shop.cart.label.method=Payment method:
+shop.cart.nonrefundable=All purchases, including but not limited to unused portions of Paid accounts time, are non-refundable
+
shop.cart.option.choose_coupon|staleness=1
shop.cart.option.choose_coupon=Choose a coupon
Modified: trunk/cgi-bin/LJ/Pay/Method/CreditCard.pm
===================================================================
--- trunk/cgi-bin/LJ/Pay/Method/CreditCard.pm 2012-10-31 08:37:09 UTC (rev 12853)
+++ trunk/cgi-bin/LJ/Pay/Method/CreditCard.pm 2012-10-31 12:28:20 UTC (rev 12854)
@@ -5,6 +5,20 @@
sub code { 'cc' }
+sub group { 'credit_card' }
+
+sub vars {
+ return {
+ currency => 'USD',
+ name => 'Credit Cards',
+ code_name => 'credit_card',
+ shop_method => 'cc',
+ img_src => $LJ::IMGPREFIX.'/shop/payment/visa.png',
+ func => sub { &LJ::DengiOnline::credit_card; },
+ id => 60,
+ }
+}
+
sub can_pay_for_coppa { 1 }
sub get_page_params {
Modified: trunk/cgi-bin/LJ/Pay/Method/PayPal.pm
===================================================================
--- trunk/cgi-bin/LJ/Pay/Method/PayPal.pm 2012-10-31 08:37:09 UTC (rev 12853)
+++ trunk/cgi-bin/LJ/Pay/Method/PayPal.pm 2012-10-31 12:28:20 UTC (rev 12854)
@@ -5,6 +5,18 @@
sub code { 'paypal' }
+sub group { 'electronic' }
+
+sub vars {
+ return {
+ currency => 'USD',
+ name => 'PayPal',
+ code_name => 'paypal',
+ img_src => $LJ::IMGPREFIX.'/shop/payment/paypal.png',
+ id => 49,
+ }
+}
+
sub get_page_params {
my ($class, $cart) = @_;
Modified: trunk/cgi-bin/LJ/Pay/Method/Wallet.pm
===================================================================
--- trunk/cgi-bin/LJ/Pay/Method/Wallet.pm 2012-10-31 08:37:09 UTC (rev 12853)
+++ trunk/cgi-bin/LJ/Pay/Method/Wallet.pm 2012-10-31 12:28:20 UTC (rev 12854)
@@ -4,9 +4,24 @@
use base qw(LJ::Pay::Method);
use LJ::Pay::Wallet;
+use LJ::DengiOnline;
sub code { 'wallet' }
+sub group { 'lj' }
+
+sub vars {
+ return {
+ currency => 'LJ tokens',
+ name => 'LJ Tokens',
+ code_name => 'wallet',
+ shop_method => 'wallet',
+ img_src => '',
+ func => sub { &LJ::DengiOnline::create_bill_lj_wallet; },
+ id => -1,
+ }
+}
+
sub name {
my $remote = LJ::get_remote();
my $balance = int LJ::Pay::Wallet->get_user_balance($remote);
Modified: trunk/cgi-bin/LJ/Pay/Method/WebMoney.pm
===================================================================
--- trunk/cgi-bin/LJ/Pay/Method/WebMoney.pm 2012-10-31 08:37:09 UTC (rev 12853)
+++ trunk/cgi-bin/LJ/Pay/Method/WebMoney.pm 2012-10-31 12:28:20 UTC (rev 12854)
@@ -8,6 +8,19 @@
sub code { 'webmoney' }
+sub group { 'electronic' }
+
+sub vars {
+ return {
+ currency => 'WMZ',
+ name => 'WebMoney WMZ',
+ code_name => 'webmoney_wmz',
+ img_src => $LJ::IMGPREFIX.'/shop/payment/webmoney.png',
+ func => sub { &LJ::DengiOnline::create_bill_wz; },
+ id => 1,
+ }
+}
+
sub suitable_for_additional_checks {
return LJ::is_enabled('webmoney');
}
Modified: trunk/cgi-bin/LJ/Pay/Method/YandexMoney.pm
===================================================================
--- trunk/cgi-bin/LJ/Pay/Method/YandexMoney.pm 2012-10-31 08:37:09 UTC (rev 12853)
+++ trunk/cgi-bin/LJ/Pay/Method/YandexMoney.pm 2012-10-31 12:28:20 UTC (rev 12854)
@@ -5,6 +5,18 @@
sub code { 'sup_yandex' }
+sub group { 'electronic' }
+
+sub vars {
+ return {
+ currency => 'RUB',
+ name => 'Yandex Dengi',
+ code_name => 'sup_yandex',
+ img_src => $LJ::IMGPREFIX.'/shop/payment/ya.png',
+ id => 7,
+ }
+}
+
sub suitable_for_additional_conditions {
my ($class, $cart) = @_;
Modified: trunk/cgi-bin/LJ/Pay/Method.pm
===================================================================
--- trunk/cgi-bin/LJ/Pay/Method.pm 2012-10-31 08:37:09 UTC (rev 12853)
+++ trunk/cgi-bin/LJ/Pay/Method.pm 2012-10-31 12:28:20 UTC (rev 12854)
@@ -66,10 +66,19 @@
use constant GROUPS_ORDER => [ qw(fast slow other) ];
+use constant DO_METHODS_LIST => [
+ 'QiWi',
+];
+
# initialization code. do not touch this.
my @METHODS = LJ::ModuleLoader->module_subclasses(__PACKAGE__);
my %CLASS_MAP;
+sub group { 'default' }
+sub title { __PACKAGE__ . "_title" }
+sub desc { __PACKAGE__ . "_desc" }
+sub vars { }
+
foreach my $method (@METHODS) {
eval "use $method";
Carp::confess "Error loading module '$method': $@" if $@;
@@ -139,6 +148,14 @@
$ret{$group} = \@suitable;
}
+ unless ($LJ::DISABLED{'dengionline'}) {
+ foreach my $method (@{DO_METHODS_LIST()}) {
+ my $method_full = __PACKAGE__ . '::' . $method;
+ next unless $method_full->suitable_for($cart);
+ push @{$ret{'fast'}}, $method_full;
+ }
+ }
+
return \%ret;
}
Modified: trunk/cgi-bin/LJ/Widget/Payment.pm
===================================================================
--- trunk/cgi-bin/LJ/Widget/Payment.pm 2012-10-31 08:37:09 UTC (rev 12853)
+++ trunk/cgi-bin/LJ/Widget/Payment.pm 2012-10-31 12:28:20 UTC (rev 12854)
@@ -421,6 +421,7 @@
return {
'items' => \@items_display,
'total_price' => format_price($total_amt, %$opts),
+ 'total_tokens_price' => format_price($total_amt, show_tokens => 1),
'cart_locked' => !$cart->can_modify,
'cart_paid' => $cart->cart_paid,
'can_checkout' => $cart->get_forwhat eq 'cart' && $cart->can_checkout,
Modified: trunk/cgi-bin/LJ/Widget/Shop/Cart.pm
===================================================================
--- trunk/cgi-bin/LJ/Widget/Shop/Cart.pm 2012-10-31 08:37:09 UTC (rev 12853)
+++ trunk/cgi-bin/LJ/Widget/Shop/Cart.pm 2012-10-31 12:28:20 UTC (rev 12854)
@@ -192,7 +192,7 @@
LJ::Pay::Wallet->is_user_eligible($remote) &&
LJ::Pay::Wallet->get_user_balance($remote) < $cart_price_tokens &&
!LJ::Pay::Payment::PayItem::WalletTokens->present_in($cart);
-
+
# compile data
return {
%$table_params,
@@ -202,6 +202,7 @@
'show_wallet_warning' => $show_wallet_warning,
'dengionline_disabled' => $LJ::DISABLED{'dengionline'} ? 1 : 0,
'dengi_online_html' => $dengi_online_html,
+ 'is_wallet_enable' => !$LJ::DISABLED{'dengionline'} && LJ::Pay::Method::Wallet->suitable_for($cart) ? 1 : 0,
};
}
