syncdb_store_payment_TR.sql (1540B)
1 -- 2 -- This file is part of TALER 3 -- Copyright (C) 2026 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 sync_do_store_payment; 19 CREATE FUNCTION sync_do_store_payment ( 20 IN in_account_pub BYTEA, 21 IN in_order_id TEXT, 22 IN in_claim_token BYTEA, 23 IN in_order_timestamp INT8, 24 IN in_amount taler_amount, 25 IN in_lifetime_us INT8, 26 IN in_now_us INT8, 27 OUT out_inserted BOOLEAN) 28 LANGUAGE plpgsql 29 AS $$ 30 BEGIN 31 -- Create account if it doesn't exist yet, so the FK 32 -- from payments.account_pub is satisfied. 33 INSERT INTO accounts 34 (account_pub 35 ,expiration_date) 36 VALUES 37 (in_account_pub 38 ,in_now_us) 39 ON CONFLICT DO NOTHING; 40 41 -- Store the payment record 42 INSERT INTO payments 43 (account_pub 44 ,order_id 45 ,claim_token 46 ,order_timestamp 47 ,amount) 48 VALUES 49 (in_account_pub 50 ,in_order_id 51 ,in_claim_token 52 ,in_order_timestamp 53 ,in_amount); 54 out_inserted := TRUE; 55 END $$;