merchant

Merchant backend to process payments, run by merchants
Log | Files | Refs | Submodules | README | LICENSE

taler-merchant-httpd_delete-private-accounts-H_WIRE.c (3772B)


      1 /*
      2   This file is part of TALER
      3   (C) 2023 Taler Systems SA
      4 
      5   TALER is free software; you can redistribute it and/or modify it under the
      6   terms of the GNU Affero General Public License as published by the Free Software
      7   Foundation; either version 3, or (at your option) any later version.
      8 
      9   TALER is distributed in the hope that it will be useful, but WITHOUT ANY
     10   WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
     11   A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
     12 
     13   You should have received a copy of the GNU General Public License along with
     14   TALER; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
     15 */
     16 /**
     17  * @file src/backend/taler-merchant-httpd_delete-private-accounts-H_WIRE.c
     18  * @brief implement DELETE /account/$H_WIRE
     19  * @author Christian Grothoff
     20  */
     21 #include "platform.h"
     22 #include "taler-merchant-httpd_delete-private-accounts-H_WIRE.h"
     23 #include <taler/taler_json_lib.h>
     24 #include <taler/taler_dbevents.h>
     25 #include "merchant-database/inactivate_account.h"
     26 #include "merchant-database/event_notify.h"
     27 
     28 
     29 enum MHD_Result
     30 TMH_private_delete_account_ID (const struct TMH_RequestHandler *rh,
     31                                struct MHD_Connection *connection,
     32                                struct TMH_HandlerContext *hc)
     33 {
     34   struct TMH_MerchantInstance *mi = hc->instance;
     35   struct TALER_MerchantWireHashP h_wire;
     36   enum GNUNET_DB_QueryStatus qs;
     37 
     38   (void) rh;
     39   if (GNUNET_OK !=
     40       GNUNET_STRINGS_string_to_data (hc->infix,
     41                                      strlen (hc->infix),
     42                                      &h_wire,
     43                                      sizeof (h_wire)))
     44   {
     45     GNUNET_break_op (0);
     46     return TALER_MHD_reply_with_error (connection,
     47                                        MHD_HTTP_BAD_REQUEST,
     48                                        TALER_EC_GENERIC_PARAMETER_MALFORMED,
     49                                        "h_wire");
     50   }
     51   GNUNET_assert (NULL != mi);
     52   qs = TALER_MERCHANTDB_inactivate_account (TMH_db,
     53                                             mi->settings.id,
     54                                             &h_wire);
     55   switch (qs)
     56   {
     57   case GNUNET_DB_STATUS_HARD_ERROR:
     58     return TALER_MHD_reply_with_error (connection,
     59                                        MHD_HTTP_INTERNAL_SERVER_ERROR,
     60                                        TALER_EC_GENERIC_DB_STORE_FAILED,
     61                                        "inactivate_account");
     62   case GNUNET_DB_STATUS_SOFT_ERROR:
     63     GNUNET_break (0);
     64     return TALER_MHD_reply_with_error (connection,
     65                                        MHD_HTTP_INTERNAL_SERVER_ERROR,
     66                                        TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE,
     67                                        NULL);
     68   case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
     69     return TALER_MHD_reply_with_error (connection,
     70                                        MHD_HTTP_NOT_FOUND,
     71                                        TALER_EC_MERCHANT_PRIVATE_ACCOUNT_DELETE_UNKNOWN_ACCOUNT,
     72                                        "account unknown");
     73   case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT:
     74     break;
     75   }
     76   {
     77     struct GNUNET_DB_EventHeaderP es = {
     78       .size = htons (sizeof (es)),
     79       .type = htons (TALER_DBEVENT_MERCHANT_ACCOUNTS_CHANGED)
     80     };
     81 
     82     TALER_MERCHANTDB_event_notify (TMH_db,
     83                                    &es,
     84                                    NULL,
     85                                    0);
     86   }
     87   TMH_reload_instances (mi->settings.id);
     88   return TALER_MHD_reply_static (connection,
     89                                  MHD_HTTP_NO_CONTENT,
     90                                  NULL,
     91                                  NULL,
     92                                  0);
     93 }
     94 
     95 
     96 /* end of taler-merchant-httpd_delete-private-accounts-H_WIRE.c */