DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `hedera`.`tpvTransaction_end`(
	vSelf INT,
	vStatus VARCHAR(12))
BEGIN
/**
 * Ends a transaction by setting its status to 'ok' or 'ko' depending on
 * if this has been done correctly.
 * This procedure must be called directly by the client when the transaction
 * ends, it is only valid until the arrival of the definitive notification from
 * the payment platform.
 *
 * @param vSelf Transaction indentifier
 * @param vStatus The status, 'ok' o 'ko'
 */
	IF vStatus IN ('ok', 'ko') THEN
		UPDATE tpvTransaction SET `status` = vStatus
			WHERE id = vSelf AND response IS NULL;
	END IF;
END$$
DELIMITER ;
