MySQL for loop to show grouped results
As @Rick James mentioned, a GROUP BY function should do the trick here, and you can use  This SO Answer to limit it to the last 12 months.  For your example, the query would look something like this:

SELECT 
    COUNT(DISTINCT user_id) as customers,
    SUM(amount)*.01 as amount,
    SUM(amount_refunded)*.01 as refunded,
    MONTH(MAX(created_at)) as month
FROM `payments`
WHERE `amount` &gt; 0
AND `status` = 'succeeded'
AND `created_at` &gt;= DATE_SUB(NOW(), INTERVAL 1 YEAR)
-- AND `user_id` IN (
--  SELECT `id` FROM `users` WHERE `created_at` &gt;= DATE_SUB(NOW(), INTERVAL 1 YEAR)
-- )
GROUP BY MONTH(`created_at`);


NOTE: I commented the subquery for user_id because it would mean the results were only for those customers who both created an account and made a purchase in the last year, and I wasn't sure if that was your desired result.  If so, just uncomment it.  I edited the subquery so that it should work in that manner