Revision 529
- Date:
- 2015/11/25 17:36:04
- Files:
Legend:
- Added
- Removed
- Modified
-
utf8/plugins/payments/lib/payments/Init.pm
1 package payments::Init; 2 3 use strict; 4 use warnings 'all'; 5 6 use Contenido::Globals; 7 use payments::Apache; 8 use payments::Keeper; 9 10 # загрузка всех необходимых плагину классов 11 # payments::SQL::SomeTable 12 # payments::SomeClass 13 Contenido::Init::load_classes(qw( 14 payments::SQL::TransactionsTable 15 payments::Transaction 16 17 payments::SQL::OperationsTable 18 payments::Operation 19 20 payments::SQL::CardsTable 21 payments::Card 22 23 payments::TransactionSection 24 25 payments::CardSection 26 27 payments::Provider::Base 28 payments::Provider::Moneta 29 payments::Provider::Xsolla 30 )); 31 32 sub init { 33 push @{ $state->{'available_documents'} }, qw( payments::Transaction payments::Operation payments::Card ); 34 push @{ $state->{'available_sections'} }, qw( payments::TransactionSection payments::CardSection ); 35 0; 36 } 37 38 1; 1 package payments::Init; 2 3 use strict; 4 use warnings 'all'; 5 6 use Contenido::Globals; 7 use payments::Apache; 8 use payments::Keeper; 9 10 # загрузка всех необходимых плагину классов 11 # payments::SQL::SomeTable 12 # payments::SomeClass 13 Contenido::Init::load_classes(qw( 14 payments::SQL::TransactionsTable 15 payments::Transaction 16 17 payments::SQL::OperationsTable 18 payments::Operation 19 20 payments::SQL::CardsTable 21 payments::Card 22 23 payments::TransactionSection 24 25 payments::CardSection 26 27 payments::Provider::Base 28 payments::Provider::Moneta 29 payments::Provider::Xsolla 30 payments::Provider::PayTure 31 )); 32 33 sub init { 34 push @{ $state->{'available_documents'} }, qw( payments::Transaction payments::Operation payments::Card ); 35 push @{ $state->{'available_sections'} }, qw( payments::TransactionSection payments::CardSection ); 36 0; 37 } 38 39 1; -
utf8/plugins/payments/lib/payments/Provider/PayTure.pm
37 37 my $self = shift; 38 38 my (%opts) = @_; 39 39 40 my $session_type = delete $opts{session_type} || 'Pay'; ### 'Pay' or 'Block' 41 my $order_id = delete $opts{order_id} || return 0; 40 warn "PayTure Init: ".Dumper(\%opts) if $DEBUG; 42 41 43 ### Сумма копейках. Если дробное - преобразуем 44 my $sum = delete $opts{sum} || return 0; 42 ### Session Type: Pay or Block 43 my $session_type = $opts{session_type} || 'Pay'; 44 45 my $order_id = $opts{order_id}; 46 return 0 unless $order_id; 47 48 ### Сумма в копейках. Если дробное - преобразуем 49 my $sum = $opts{sum}; 50 return 0 unless $sum; 45 51 if ( $sum =~ /[\.\,]/ ) { 46 52 $sum =~ s/\,/\./; 47 53 $sum = int($sum * 100); 48 54 } 49 55 50 my $ip = delete $opts{ip} || return 0; 56 my $ip = $opts{ip}; 57 return 0 unless $ip && $ip =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/; 58 warn "IP: $ip\n"; 51 59 52 my $url = delete $opts{url}; 53 my $template = delete $opts{teplate}; 54 my $lang = delete $opts{lang}; 55 my $params = delete $opts{params}; 60 ### Пример: http://yoursite.com/result?orderid={orderid}&result={success} 61 my $url = $opts{url}; 56 62 63 my $template = $opts{teplate}; 64 my $lang = $opts{lang}; 65 my $params = $opts{params}; 66 57 67 my $ua = LWP::UserAgent->new; 58 68 my $req = URI->new( $self->{api}{init} ); 59 69 $req->query_param( Key => $self->id ); … … 64 74 push @data, "Language=$lang" if $lang; 65 75 if ( ref $params eq 'HASH' ) { 66 76 while ( my ($param, $val) = each %$params ) { 77 push @data, "$param=$val"; 67 78 } 68 79 } 80 my $data_str = URI::Escape::uri_escape(join ';', @data); 81 $req->query_param( Data => $data_str ); 82 warn "PayTure Init query: ".Dumper($req) if $DEBUG; 83 84 my $result = $ua->get( $req ); 85 if ( $result->code == 200 ) { 86 warn Dumper $result->content; 87 return 1; 88 } else { 89 warn "PayTure Init failed; ".$result->status_line."\n"; 90 } 91 return 0; 69 92 } 70 93 71 94 1;