-- name: CreatePayment :one
INSERT INTO payments (user_id, amount, currency, status, payment_processor_id, paid_at)
VALUES (?, ?, ?, ?, ?, ?)
RETURNING *;

-- name: GetPaymentByID :one
SELECT * FROM payments
WHERE id = ?;

-- name: GetPaymentsByUserID :many
SELECT * FROM payments
WHERE user_id = ?
ORDER BY created_at DESC;

-- name: UpdatePaymentStatus :one
UPDATE payments
SET status = ?, paid_at = CASE WHEN ? IS NOT NULL THEN ? ELSE paid_at END
WHERE id = ?
RETURNING *;
