diff options
author | Christian Grothoff <christian@grothoff.org> | 2020-05-06 21:41:59 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2020-05-06 21:41:59 +0200 |
commit | 02faacad3cd56e3266be625980920e420f61250f (patch) | |
tree | 87cdea74319d0fe822e0cabe481114409973791a /src/backend/taler-merchant-httpd_private-post-transfers.c | |
parent | c84339de2d37076cfd114ae1a097cf084d36b7a0 (diff) | |
download | merchant-02faacad3cd56e3266be625980920e420f61250f.tar.gz merchant-02faacad3cd56e3266be625980920e420f61250f.tar.bz2 merchant-02faacad3cd56e3266be625980920e420f61250f.zip |
db work for POST /transfers
Diffstat (limited to 'src/backend/taler-merchant-httpd_private-post-transfers.c')
-rw-r--r-- | src/backend/taler-merchant-httpd_private-post-transfers.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/backend/taler-merchant-httpd_private-post-transfers.c b/src/backend/taler-merchant-httpd_private-post-transfers.c index 2f22d051..5c3a0e3e 100644 --- a/src/backend/taler-merchant-httpd_private-post-transfers.c +++ b/src/backend/taler-merchant-httpd_private-post-transfers.c @@ -1013,6 +1013,7 @@ TMH_private_post_transfers (const struct TMH_RequestHandler *rh, /* reply not in database, ensure the POST is in the database, and start work to obtain the reply from the exchange */ qs = TMH_db->insert_transfer (TMH_db->cls, + rctx->hc->instance->settings.id, rctx->exchange_url, &rctx->wtid, &rctx->amount, @@ -1029,6 +1030,23 @@ TMH_private_post_transfers (const struct TMH_RequestHandler *rh, TALER_EC_POST_TRANSFER_DB_STORE_ERROR, "Fail to update database with transfer record"); } + if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs) + { + uint64_t account_serial; + + /* Either the record already exists (we should ignore this), or + the INSERT failed because we did not find the account based on + the given payto-URI and the instance. */ + qs = TMH_db->lookup_account (TMH_db->cls, + rctx->hc->instance->settings.id, + rctx->payto_uri, + &account_serial); + if (0 >= qs) + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_NOT_FOUND, + TALER_EC_POST_TRANSFER_ACCOUNT_NOT_FOUND, + "Instance does not have this bank account"); + } GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Suspending POST /private/transfers handling while working with exchange\n"); |