account_kyc_set_failed.sql (1898B)
1 -- 2 -- This file is part of TALER 3 -- Copyright (C) 2024 Taler Systems SA 4 -- 5 -- TALER is free software; you can redistribute it and/or modify it under the 6 -- terms of the GNU 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 18 DROP FUNCTION IF EXISTS merchant_do_account_kyc_set_failed; 19 CREATE FUNCTION merchant_do_account_kyc_set_failed ( 20 IN in_h_wire BYTEA, 21 IN in_exchange_url TEXT, 22 IN in_timestamp INT8, 23 IN in_exchange_http_status INT4, 24 IN in_kyc_ok BOOL, 25 IN in_notify_str TEXT, 26 IN in_notify2_str TEXT, 27 OUT out_no_account BOOL) 28 LANGUAGE plpgsql 29 AS $$ 30 DECLARE 31 my_account_serial INT8; 32 BEGIN 33 34 out_no_account=FALSE; 35 36 SELECT account_serial 37 INTO my_account_serial 38 FROM merchant_accounts 39 WHERE h_wire=in_h_wire; 40 41 IF NOT FOUND 42 THEN 43 out_no_account=TRUE; 44 RETURN; 45 END IF; 46 47 UPDATE merchant_kyc 48 SET kyc_timestamp=in_timestamp 49 ,kyc_ok=in_kyc_ok 50 ,exchange_http_status=in_exchange_http_status 51 ,exchange_ec_code=0 52 WHERE account_serial=my_account_serial 53 AND exchange_url=in_exchange_url; 54 55 IF NOT FOUND 56 THEN 57 58 INSERT INTO merchant_kyc 59 (kyc_timestamp 60 ,kyc_ok 61 ,account_serial 62 ,exchange_url 63 ,exchange_http_status) 64 VALUES 65 (in_timestamp 66 ,in_kyc_ok 67 ,my_account_serial 68 ,in_exchange_url 69 ,in_exchange_http_status); 70 END IF; 71 72 EXECUTE FORMAT ( 73 'NOTIFY %s' 74 ,in_notify_str); 75 76 EXECUTE FORMAT ( 77 'NOTIFY %s' 78 ,in_notify2_str); 79 80 81 -- Success! 82 END $$;