Revision 734
- Date:
- 2018/10/31 16:57:32
- Files:
Legend:
- Added
- Removed
- Modified
-
utf8/plugins/money/lib/money/Provider/Dreamkas.pm
112 112 payment_type => CASH || CASHLESS 113 113 # или 114 114 payments => ARRAY_REF по стандарту примера 115 116 dryrun => Только заполнение полей, без отправки по API 115 117 }); 116 118 117 119 JSON тела вызова: … … 194 196 if ( exists $opts->{order} ) { 195 197 $MR = $self->_GetLastMoneyReceipt( $opts->{order}->id ); 196 198 } 197 if ( ref $MR && $MR->session_id && $MR->name eq $opts->{type} ) { 199 if ( ref $MR && $MR->session_id && $MR->name eq $type ) { 198 200 $self->{result}{receipt} = $MR; 199 201 return $self; 200 202 } … … 243 245 $counted_sum += $pos->{priceSum}; 244 246 } 245 247 # Может быть разница в копейках между итоговой суммой и суммой по товарам. Её необходимо устранить 246 my $diff = $counted_sum - $order_sum; 248 my $diff = $order_sum - $counted_sum; 247 249 if ( $diff != 0 ) { 248 250 foreach my $pos ( @$positions ) { 249 251 if ( $pos->{quantity} == 1 && ($pos->{priceSum} + $diff) > 0 ) { … … 346 348 my $api_url = 'receipts'; 347 349 348 350 warn "DREAMKAS receipt data: ".Data::Dumper::Dumper( $data ) if $DEBUG; 349 $self->_MakeRequest( $api_url, 'post', $data ); 350 warn Data::Dumper::Dumper( $self->{result} ) if $DEBUG; 351 if ( $self->{result}{code} == 202 || $self->{result}{code} == 200 ) { 352 $MR->success( $OP_STATUS{$self->{result}{content}{status}} ); 353 $MR->session_id( $self->{result}{content}{id} ); 354 $MR->store; 355 $self->{result}{receipt} = $MR; 351 unless ( $opts->{dryrun} ) { 352 $self->_MakeRequest( $api_url, 'post', $data ); 353 warn Data::Dumper::Dumper( $self->{result} ) if $DEBUG; 354 if ( $self->{result}{code} == 202 || $self->{result}{code} == 200 ) { 355 $MR->success( $OP_STATUS{$self->{result}{content}{status}} ); 356 $MR->session_id( $self->{result}{content}{id} ); 357 $MR->store; 358 $self->{result}{receipt} = $MR; 359 } else { 360 $self->{result}{error} = $self->{result}{status}; 361 } 356 362 } else { 357 $self->{result}{error} = $self->{result}{status}; 363 warn "Dry run\n"; 364 $self->{data} = $data; 358 365 } 359 366 360 367 return $self;