Revision 525

Date:
2015/11/24 12:45:58
Author:
ahitrov
Revision Log:
Payture, the beginning

Files:

Legend:

 
Added
 
Removed
 
Modified
  • utf8/plugins/payments/config.proto

     
    25 25 XSO_ID =
    26 26 XSO_SECRET =
    27 27 XSO_CURRENCY_CODE = RUB
    28 XSO_TEST_MODE = 1 # 0 - для боевого режима
    28 XSO_TEST_MODE = 1 # 0 - для боевого режима
    29 29 XSO_VALID_IPS = # список разрешенных ip
    30 30 # Для подтверждения целостности
    31 31 XSO_SIG_CODE =
     
    35 35 ############################################################
    36 36 # /xsolla.com
    37 37
    38
    39 # payture.ru
    40 ############################################################
    41 PTR_ID =
    42 PTR_SECRET =
    43 PTR_BACKEND_SECRET =
    44 PTR_CURRENCY_CODE = RUB
    45 PTR_TEST_MODE = 1 # 0 - для боевого режима
    46
    47 REWRITE += PTR_ID PTR_SECRET PTR_BACKEND_SECRET
    48 ############################################################
    49 # /payture.ru
    50
  • utf8/plugins/payments/lib/payments/Provider/PayTure.pm

     
    1 package payments::Provider::PayTure;
    2
    3 use strict;
    4 use warnings 'all';
    5
    6 use base 'payments::Provider::Base';
    7 use Contenido::Globals;
    8 use payments::Keeper;
    9 use Digest::MD5;
    10 use Data::Dumper;
    11 use URI;
    12 use URI::QueryParam;
    13
    14 our $init_url = '';
    15
    16 sub new {
    17 my ($proto, %params) = @_;
    18 my $class = ref($proto) || $proto;
    19 my $self = {};
    20 my $prefix = $class =~ /\:\:(\w+)$/ ? lc($1) : undef;
    21 return unless $prefix;
    22
    23 $self->{payment_system} = $prefix;
    24 $self->{app_id} = $state->{payments}->{$prefix."_app_id"};
    25 $self->{secret} = $state->{payments}->{$prefix."_app_secret"};
    26 $self->{currency} = $state->{payments}->{$prefix."_currency_code"};
    27 $self->{test_mode} = $state->{payments}->{$prefix."_test_mode"};
    28
    29 $self->{api}{init} = 'https://sandbox.payture.com/apim/Init';
    30
    31 bless $self, $class;
    32
    33 return $self;
    34 }
    35
    36 sub init {
    37 my $self = shift;
    38 my (%opts) = @_;
    39
    40 my $session_type = delete $opts{session_type} || 'Pay'; ### 'Pay' or 'Block'
    41 my $order_id = delete $opts{order_id} || return 0;
    42
    43 ### Сумма копейках. Если дробное - преобразуем
    44 my $sum = delete $opts{sum} || return 0;
    45 if ( $sum =~ /[\.\,]/ ) {
    46 $sum =~ s/\,/\./;
    47 $sum = int($sum * 100);
    48 }
    49
    50 my $ip = delete $opts{ip} || return 0;
    51
    52 my $url = delete $opts{url};
    53 my $template = delete $opts{teplate};
    54 my $lang = delete $opts{lang};
    55 my $params = delete $opts{params};
    56
    57 my $ua = LWP::UserAgent->new;
    58 my $req = URI->new( $self->{api}{init} );
    59 $req->query_param( Key => $self->id );
    60 my @data = ( "SessionType=$session_type", "OrderId=$order_id", "Amount=$sum", "IP=$ip");
    61 push @data, "Url=$url" if $url;
    62 push @data, "TemplateTag=$template" if $template;
    63 push @data, "Url=$url" if $url;
    64 push @data, "Language=$lang" if $lang;
    65 if ( ref $params eq 'HASH' ) {
    66 while ( my ($param, $val) = each %$params ) {
    67 }
    68 }
    69 }
    70
    71 1;
  • utf8/plugins/payments/lib/payments/State.pm.proto

     
    65 65 $self->{xsolla_valid_ips} = \@valid_ips_default;
    66 66 }
    67 67
    68 $self->{payture_app_id} = '@PTR_ID@';
    69 $self->{payture_app_secret} = '@PTR_SECRET@';
    70 $self->{payture_backend_secret} = '@PTR_BACKEND_SECRET@';
    71 $self->{payture_currency_code} = '@PTR_CURRENCY_CODE@';
    72 $self->{payture_test_mode} = int('@PTR_TEST_MODE@' || 0);
    73 $self->{payture_sig_code} = '@PTR_SIG_CODE@';
    74
    68 75 $self->_init_();
    69 76 $self;
    70 77 }