Revision 576

Date:
2016/06/14 14:54:05
Author:
ahitrov
Revision Log:
Test status can be set from constructor
Transaction status improvement

Files:

Legend:

 
Added
 
Removed
 
Modified
  • utf8/plugins/payments/lib/payments/Provider/PayTure.pm

     
    25 25 $self->{app_id} = $state->{payments}->{$prefix."_app_id"};
    26 26 $self->{secret} = $state->{payments}->{$prefix."_app_secret"};
    27 27 $self->{currency} = $state->{payments}->{$prefix."_currency_code"};
    28 $self->{test_mode} = $state->{payments}->{$prefix."_test_mode"};
    28 $self->{test_mode} = exists $params{test_mode} ? $params{test_mode} : $state->{payments}->{$prefix."_test_mode"};
    29 29
    30 30 my $host = $self->{test_mode} ? 'sandbox' : 'secure';
    31 31 $self->{api} = {
     
    209 209
    210 210 warn "PayTure Status: ".Dumper(\%opts) if $DEBUG;
    211 211
    212 my $order_id = $opts{order_id};
    213 unless ( $order_id ) {
    214 $self->{result} = { error => 'Не указан order_id' };
    215 return $self;
    212 my ($order_id, $transaction);
    213 if ( exists $self->{result}{transaction} ) {
    214 $transaction = $self->{result}{transaction};
    215 $order_id = $transaction->order_id;
    216 unless ( $order_id ) {
    217 $self->{result}{error} = 'Транзакция ['.$transaction->id.'] без order_id';
    218 return $self;
    219 }
    220 } else {
    221 $order_id = $opts{order_id};
    222 unless ( $order_id ) {
    223 $self->{result}{error} = 'Не указан order_id';
    224 return $self;
    225 }
    226 ($transaction) = $keeper->get_documents(
    227 class => 'payments::Transaction',
    228 status => $self->{test_mode},
    229 limit => 1,
    230 order_id => $order_id,
    231 provider => $self->{payment_system},
    232 );
    216 233 }
    217 234
    218 my ($transaction) = exists $self->{result}{transaction} ? ($self->{result}{transaction}) : $keeper->get_documents(
    219 class => 'payments::Transaction',
    220 status => $state->{payments}->{payture_test_mode},
    221 limit => 1,
    222 order_id => $order_id,
    223 provider => $self->{payment_system},
    224 );
    225 235 if ( ref $transaction ) {
    226 236 my $ua = LWP::UserAgent->new;
    227 237 $ua->agent('Mozilla/5.0');