Revision 695

Date:
2018/08/13 17:52:19
Author:
ahitrov
Revision Log:
Token auth

Files:

Legend:

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

     
    10 10 ############################################################
    11 11 DREAMKAS_ID =
    12 12 DREAMKAS_SECRET = 123
    13
    14 DREAMKAS_TOKEN = xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
    15
    13 16 DREAMKAS_CURRENCY_CODE = RUB
    14 17 DREAMKAS_DEVICE_ID = NNNNN # ID кассового аппарата в системе Dreamkas
    15 18 DREAMKAS_TAX_MODE = DEFAULT # DEFAULT or SIMPLE or SIMPLE_WO or ENVD or AGRICULT or PATENT
     
    17 20 DREAMKAS_TEST_MODE = 1 # 0 - для боевого режима
    18 21
    19 22 REWRITE += DREAMKAS_ID DREAMKAS_SECRET DREAMKAS_CURRENCY_CODE DREAMKAS_TAX_MODE DREAMKAS_TAX_NDS DREAMKAS_TEST_MODE
    23 REWRITE += DREAMKAS_TOKEN DREAMKAS_CURRENCY_CODE DREAMKAS_TAX_MODE DREAMKAS_TAX_NDS DREAMKAS_TEST_MODE
    20 24 ############################################################
    21 25 # /dreamkas.ru
  • utf8/plugins/money/lib/money/Provider/Dreamkas.pm

     
    289 289 my $api_url = 'receipts';
    290 290
    291 291 $self->_MakeRequest( $api_url, 'post', $data );
    292 if ( $self->{result}{code} == 202 ) {
    292 if ( $self->{result}{code} == 202 || $self->{result}{code} == 200 ) {
    293 293 $MM->success( $OP_STATUS{$self->{result}{content}{status}} );
    294 294 $MM->session_id( $self->{result}{content}{id} );
    295 295 $MM->store;
     
    380 380 $ua->timeout( 10 );
    381 381 $ua->agent('Mozilla/5.0');
    382 382
    383 my $auth = encode_base64($self->{app_id}.':'.$self->{secret});
    384 $ua->default_header( 'Authorization' => "Application: {$auth}" );
    383 if ( exists $self->{token} && $self->{token} ) {
    384 $ua->default_header( 'Authorization' => "Bearer ".$self->{token} );
    385 } elsif ( $self->{app_id} && $self->{secret} ) {
    386 my $auth = encode_base64($self->{app_id}.':'.$self->{secret});
    387 $ua->default_header( 'Authorization' => "Application: {$auth}" );
    388 }
    385 389 $ua->default_header( 'Content-Type' => 'application/json' );
    386 390
    387 391 if ( ref $body ) {
  • utf8/plugins/money/lib/money/State.pm.proto

     
    52 52
    53 53 $self->{dreamkas_app_id} = '@DREAMKAS_ID@';
    54 54 $self->{dreamkas_app_secret} = '@DREAMKAS_SECRET@';
    55 $self->{dreamkas_token} = '@DREAMKAS_TOKEN@';
    55 56 $self->{dreamkas_currency_code} = '@DREAMKAS_CURRENCY_CODE@';
    56 57 $self->{dreamkas_tax_mode} = '@DREAMKAS_TAX_MODE@' || 'DEFAULT';
    57 58 $self->{dreamkas_tax_nds} = '@DREAMKAS_TAX_NDS@' || 'NDS_NO_TAX';