Revision 327
- Date:
- 2013/05/01 17:20:58
- Files:
-
- /utf8/plugins/monetaru/comps
- /utf8/plugins/monetaru/comps/contenido
- /utf8/plugins/monetaru/comps/contenido/monetaru
- /utf8/plugins/monetaru/comps/contenido/monetaru/autohandler (Diff) (Checkout)
- /utf8/plugins/monetaru/comps/contenido/monetaru/dhandler (Diff) (Checkout)
- /utf8/plugins/monetaru/comps/contenido/monetaru/index.html (Diff) (Checkout)
- /utf8/plugins/monetaru/comps/www
- /utf8/plugins/monetaru/comps/www/monetaru
- /utf8/plugins/monetaru/comps/www/monetaru/pay.xml (Diff) (Checkout)
- /utf8/plugins/monetaru/config.proto (Diff) (Checkout)
- /utf8/plugins/monetaru/lib
- /utf8/plugins/monetaru/lib/monetaru
- /utf8/plugins/monetaru/lib/monetaru/Apache.pm (Diff) (Checkout)
- /utf8/plugins/monetaru/lib/monetaru/Init.pm (Diff) (Checkout)
- /utf8/plugins/monetaru/lib/monetaru/Keeper.pm (Diff) (Checkout)
- /utf8/plugins/monetaru/lib/monetaru/State.pm.proto (Diff) (Checkout)
- /utf8/plugins/monetaru/sql
- /utf8/plugins/monetaru/sql/TOAST
Legend:
- Added
- Removed
- Modified
-
utf8/plugins/monetaru/comps/contenido/monetaru/autohandler
1 <%init> 2 3 $r->content_type('text/html'); 4 $m->call_next(); 5 6 </%init> -
utf8/plugins/monetaru/comps/contenido/monetaru/dhandler
1 <& $call, %ARGS &> 2 <%init> 3 4 my $call; 5 if ( $r->uri eq '/contenido/monetaru/' ) { 6 $call = 'index.html'; 7 } else { 8 &abort404; 9 } 10 11 </%init> -
utf8/plugins/monetaru/comps/contenido/monetaru/index.html
1 <& "/contenido/components/header.msn" &> 2 <& "/contenido/components/naviline.msn" &> 3 4 <p>PLugin [monetaru]</p> 5 6 </body> 7 </html> -
utf8/plugins/monetaru/comps/www/monetaru/pay.xml
1 <%args> 2 3 $MNT_ID => undef 4 $MNT_TRANSACTION_ID => undef 5 $MNT_OPERATION_ID => undef 6 $MNT_AMOUNT => 0 7 $MNT_CURRENCY_CODE => undef 8 $MNT_TEST_MODE => undef 9 $MNT_SIGNATURE => undef 10 $MNT_USER => undef 11 $MNT_CORRACCOUNT => undef 12 $MNT_CUSTOM1 => undef 13 $MNT_CUSTOM2 => undef 14 $MNT_CUSTOM3 => undef 15 16 </%args> 17 <%init> 18 19 20 21 </%init> -
utf8/plugins/monetaru/config.proto
1 ############################################################################# 2 # 3 # Параметры данного шаблона необходимо ВРУЧНУЮ добавить в config.mk проекта 4 # и привести в соответствие с требованиями проекта 5 # 6 ############################################################################# 7 PLUGINS += monetaru 8 9 MNT_ID = 10 MNT_SECRET = 11 MNT_CURRENCY_CODE = RUB 12 MNT_TEST_MODE = 1 # 0 - для боевого режима 13 # Для подтверждения целостности 14 MNT_SIG_CODE = 15 16 REWRITE += MNT_ID MNT_SECRET MNT_CURRENCY_CODE MNT_TEST_MODE MNT_SIG_CODE -
utf8/plugins/monetaru/lib/monetaru/Apache.pm
1 package monetaru::Apache; 2 3 use strict; 4 use warnings 'all'; 5 6 use monetaru::State; 7 use Contenido::Globals; 8 9 10 sub child_init { 11 # встраиваем keeper плагина в keeper проекта 12 $keeper->{monetaru} = monetaru::Keeper->new($state->monetaru); 13 } 14 15 sub request_init { 16 } 17 18 sub child_exit { 19 } 20 21 1; -
utf8/plugins/monetaru/lib/monetaru/Init.pm
1 package monetaru::Init; 2 3 use strict; 4 use warnings 'all'; 5 6 use Contenido::Globals; 7 use monetaru::Apache; 8 use monetaru::Keeper; 9 10 11 # загрузка всех необходимых плагину классов 12 # monetaru::SQL::SomeTable 13 # monetaru::SomeClass 14 Contenido::Init::load_classes(qw( 15 )); 16 17 sub init { 18 0; 19 } 20 21 1; -
utf8/plugins/monetaru/lib/monetaru/Keeper.pm
1 package monetaru::Keeper; 2 3 use strict; 4 use warnings 'all'; 5 use base qw(Contenido::Keeper); 6 7 use Contenido::Globals; 8 use Digest::MD5; 9 10 11 sub get_form { 12 my $self = shift; 13 my (%opts) = @_; 14 my $id = delete $opts{id}; 15 return unless $id; 16 my $sum = delete $opts{sum}; 17 return unless $sum; 18 19 $sum = $sum =~ /\d+\.\d{2}/ ? $sum : sprintf( "%.2f", $sum ); 20 21 my %fields = ( 22 'method' => 'post', 23 'action' => 'https://www.moneta.ru/assistant.htm', 24 'visible' => [ 25 { type => 'submit', value => $opts{submit} || 'Оплатить' }, 26 ], 27 'hidden' => [ 28 { name => 'MNT_ID', value => $self->state->{moneta_app_id} }, 29 { name => 'MNT_TRANSACTION_ID', value => $id }, 30 { name => 'MNT_CURRENCY_CODE', value => $self->state->{moneta_currency_code} }, 31 { name => 'MNT_AMOUNT', value => $sum }, 32 ], 33 ); 34 if ( $self->state->{moneta_test_mode} ) { 35 push @{$fields{hidden}}, { name => 'MNT_TEST_MODE', value => 1 } 36 } 37 if ( $opts{success} ) { 38 push @{$fields{hidden}}, { name => 'MNT_SUCCESS_URL', value => $opts{success} } 39 } 40 if ( $opts{fail} ) { 41 push @{$fields{hidden}}, { name => 'MNT_FAIL_URL', value => $opts{fail} } 42 } 43 if ( $self->state->{moneta_sig_code} ) { 44 my $md5 = Digest::MD5::md5_hex ( 45 $self->state->{moneta_app_id}.$id.$sum.$self->state->{moneta_currency_code}.$self->state->{moneta_test_mode}.$self->state->{moneta_sig_code} 46 ); 47 push @{$fields{hidden}}, { name => 'MNT_SIGNATURE', value => $md5 } 48 } 49 50 if ( exists $opts{custom1} ) { 51 push @{$fields{hidden}}, { name => 'MNT_CUSTOM1', value => $opts{custom1} } 52 } 53 if ( exists $opts{custom2} ) { 54 push @{$fields{hidden}}, { name => 'MNT_CUSTOM2', value => $opts{custom2} } 55 } 56 if ( exists $opts{custom3} ) { 57 push @{$fields{hidden}}, { name => 'MNT_CUSTOM3', value => $opts{custom3} } 58 } 59 60 return \%fields; 61 } 62 63 64 1; -
utf8/plugins/monetaru/lib/monetaru/State.pm.proto
1 package monetaru::State; 2 3 use strict; 4 use warnings 'all'; 5 use vars qw($AUTOLOAD); 6 7 8 sub new { 9 my ($proto) = @_; 10 my $class = ref($proto) || $proto; 11 my $self = {}; 12 bless $self, $class; 13 14 # configured 15 $self->{debug} = (lc('') eq 'yes'); 16 $self->{project} = ''; 17 18 # зашитая конфигурация плагина 19 $self->{db_type} = 'none'; ### For REAL database use 'remote' 20 $self->{db_keepalive} = 0; 21 $self->{db_host} = ''; 22 $self->{db_name} = ''; 23 $self->{db_user} = ''; 24 $self->{db_password} = ''; 25 $self->{db_port} = ''; 26 $self->{store_method} = 'toast'; 27 $self->{cascade} = 1; 28 $self->{db_prepare} = 0; 29 30 $self->{memcached_enable} = lc( '' ) eq 'yes' ? 1 : 0; 31 $self->{memcached_enable_compress} = 1; 32 $self->{memcached_backend} = ''; 33 $self->{memcached_servers} = [qw()]; 34 $self->{memcached_busy_lock} = 60; 35 $self->{memcached_delayed} = lc('') eq 'yes' ? 1 : 0; 36 37 $self->{serialize_with} = 'json'; ### or 'dumper' 38 39 # not implemented really (core compatibility) 40 $self->{binary_directory} = '/nonexistent'; 41 $self->{data_directory} = '/nonexistent'; 42 $self->{images_directory} = '/nonexistent'; 43 $self->{preview} = '0'; 44 45 $self->{moneta_app_id} = '@MNT_ID@'; 46 $self->{moneta_app_secret} = '@MNT_SECRET@'; 47 $self->{moneta_currency_code} = '@MNT_CURRENCY_CODE@'; 48 $self->{moneta_test_mode} = int('@MNT_TEST_MODE@' || 0); 49 $self->{moneta_sig_code} = '@MNT_SIG_CODE@'; 50 51 $self->_init_(); 52 $self; 53 } 54 55 sub info { 56 my $self = shift; 57 return unless ref $self; 58 59 for (sort keys %{$self->{attributes}}) { 60 my $la = length $_; 61 warn "\t$_".("\t" x (2-int($la/8))).": $self->{$_}\n"; 62 } 63 } 64 65 sub _init_ { 66 my $self = shift; 67 68 # зашитая конфигурация плагина 69 $self->{attributes}->{$_} = 'SCALAR' for qw( 70 debug 71 project 72 73 db_type 74 db_keepalive 75 db_host 76 db_port 77 db_name 78 db_user 79 db_password 80 store_method 81 cascade 82 db_prepare 83 db_client_encoding 84 85 memcached_enable 86 memcached_enable_compress 87 memcached_backend 88 memcached_servers 89 memcached_busy_lock 90 memcached_delayed 91 92 binary_directory 93 data_directory 94 images_directory 95 preview 96 ); 97 } 98 99 sub AUTOLOAD { 100 my $self = shift; 101 my $attribute = $AUTOLOAD; 102 103 $attribute =~ s/.*:://; 104 return unless $attribute =~ /[^A-Z]/; # Отключаем методы типа DESTROY 105 106 if (!exists $self->{attributes}->{$attribute}) { 107 warn "Contenido Error (monetaru::State): Вызов метода, для которого не существует обрабатываемого свойства: ->$attribute()\n"; 108 return; 109 } 110 111 $self->{$attribute} = shift @_ if $#_>=0; 112 $self->{$attribute}; 113 } 114 115 1;