From 4dd42b631ed9e3f5f09b4217302ae6bb589f744c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrej=20Rama=C5=A1euski?= <andrej@x2.cz> Date: Wed, 9 Oct 2024 00:52:56 +0200 Subject: [PATCH] Ukladani VS platby do pretixu --- .gitlab-ci.yml | 6 +++--- lib/CF2022/Controller/Orders.pm | 28 +++++++++++++++++++++------- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5d3dc5a..23f1946 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,11 +1,11 @@ -image: docker:20.10.9 +image: docker:latest variables: DOCKER_TLS_CERTDIR: "/certs" - IMAGE_VER: 0.19.0 + IMAGE_VER: 0.20.0 services: - - docker:20.10.9-dind + - docker:dind before_script: - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY diff --git a/lib/CF2022/Controller/Orders.pm b/lib/CF2022/Controller/Orders.pm index e7296af..b591a90 100644 --- a/lib/CF2022/Controller/Orders.pm +++ b/lib/CF2022/Controller/Orders.pm @@ -138,6 +138,22 @@ sub create ($c ) { } } + # ukladani do lokalni databazi + my $local_order = $c->schema->resultset('Order')->create({ + ip => $c->tx->remote_address, + sso_uuid => $claims->{sub}, + email => $order->{email}, + api => $url, + }); + + # VS + push @answers, ( + { + question => $c->config->{pretix_qid_vs} , + answer => $local_order->id, + }, + ); + PRODUCT: foreach my $product ( @products ) { @@ -163,14 +179,12 @@ sub create ($c ) { json => $order )->result; - return $c->error(400, $rc->body) if ! $rc->is_success; + if (! $rc->is_success) { + $local_order->delete; + return $c->error(400, $rc->body) + } - # ukladani do lokalni databazi - $order = $c->schema->resultset('Order')->create({ - ip => $c->tx->remote_address, - sso_uuid => $claims->{sub}, - email => $order->{email}, - api => $url, + $local_order->update({ request => $order, response => $rc->json, order_id => $rc->json->{code}, -- GitLab