diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 9f8f9cbe9b49aa707851ce832f52cfaa46f04530..245985ac63039cdd5bd9b99ecb463ed07a0a223b 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -2,7 +2,7 @@ image: docker:20.10.9
 
 variables:
   DOCKER_TLS_CERTDIR: "/certs"
-  IMAGE_VER: 0.5.2
+  IMAGE_VER: 0.6.0
 
 services:
   - docker:20.10.9-dind
diff --git a/lib/CF2022/Controller/Orders.pm b/lib/CF2022/Controller/Orders.pm
index 5fea11331f6a40b9fc706a92d5257a06733c6d29..ec755d6297a241fd48959721fe2b3560cc3a81ba 100644
--- a/lib/CF2022/Controller/Orders.pm
+++ b/lib/CF2022/Controller/Orders.pm
@@ -2,7 +2,10 @@ package CF2022::Controller::Orders;
 use Mojo::Base 'Mojolicious::Controller';
 use Mojo::UserAgent;
 
-use constant MAIN_PRODUCTS => qr/^(1|2|3)$/;
+use constant MAIN_PRODUCTS        => qr/^(1|2|3)$/; # typy akreditace
+use constant NONFREE_PRODUCTS     => qr/^(1)$/;     # akreditace vyzadujici token
+use constant SUBSIDY_PRUDUCTS     => qr/^(58)$/;    # prispevkove polozky
+use constant FALLBACK_PRODUCT     => 2;             # fallback akreditace
 
 use feature 'signatures';
 no warnings qw{ experimental::signatures };
@@ -11,10 +14,11 @@ sub create ($c ) {
     $c->openapi->valid_input or return;
 
     my $args      = $c->req->json;
-    my @products  = @{ $args->{products} };
-    my @responses = @{ $args->{responses} };
     my $claims;
     my $group;
+    my @products      = ();
+    my $accredited    = 0;
+    my $accreditation = 0;
 
     my $url = sprintf ('%s/organizers/%s/events/%s/orders/',
         $c->config->{pretix_api},
@@ -22,6 +26,13 @@ sub create ($c ) {
         $c->config->{pretix_event},
     );
 
+    my @answers = map {{
+        question => $_->{question_id},
+        answer   => $_->{response},
+    }} @{ $args->{responses} };
+
+    # processing tokenu
+
     if ( $args->{token} ) {
         $c->oauth_token($args->{token});
 
@@ -33,7 +44,7 @@ sub create ($c ) {
 
         $args->{name} = $claims->{name};
 
-        push @responses, (
+        push @answers, (
             {
                 question_id => $c->config->{pretix_qid_sso},
                 response    => $claims->{sub},
@@ -44,10 +55,7 @@ sub create ($c ) {
             },
         );
 
-        @products = grep { $_->{id} !~ MAIN_PRODUCTS } @products;
-        @products = ({
-            id => $c->config->{'pretix_product_' . $group->{role}}
-        }, @products);
+        $accreditation = $c->config->{'pretix_product_' . $group->{role}};
 
         if ( $group->{role} eq 'member' ) {
             $args->{email} = $claims->{preferred_username}
@@ -58,6 +66,31 @@ sub create ($c ) {
         }
     }
 
+    # korekce akreditace
+
+    PRODUCT:
+    foreach my $product ( @{ $args->{products} } ) {
+
+        next PRODUCT if $product->{id} =~ SUBSIDY_PRUDUCTS && ! $product->{price};
+
+        if ( $product->{id} =~ MAIN_PRODUCTS ) {
+            next PRODUCT if $accredited++; # neumoznit dvoji akreditace
+
+            if ( $accreditation ) {
+                $product->{id} = $accreditation;
+            }
+            elsif ($product->{id} =~ NONFREE_PRODUCTS) {
+                $product->{id} = FALLBACK_PRODUCT;
+            }
+        }
+
+        push @products, $product;
+
+    }
+
+    # fallback akreditace
+    @products = ( { id => FALLBACK_PRODUCT}, @products ) if ! $accredited;
+
     my $order = {
         email            => $args->{email},
         locale           => 'en',
@@ -69,23 +102,16 @@ sub create ($c ) {
 
     PRODUCT:
     foreach my $product ( @products ) {
+
         my $item = {
-            item      => $product->{id},
-            variation => $product->{variation},
+            item          => $product->{id},
+            variation     => $product->{variation},
             attendee_name => $args->{name},
-            price => $product->{price},
-            company => $args->{company},
+            price         => $product->{price},
+            company       => $args->{company},
         };
 
-        if ( $product->{id} =~ MAIN_PRODUCTS ) {
-            RESPONSE:
-            foreach my $response ( @responses ) {
-                push @{ $item->{answers} }, {
-                    question => $response->{question_id},
-                    answer   => $response->{response},
-                };
-            }
-        }
+        $item->{answers} = \@answers if $product->{id} =~ MAIN_PRODUCTS;
 
         push @{ $order->{positions} }, $item;
     }