Have aggregate function group results in one row
You are looking for the crosstab() function provided by the additional module tablefunc.

Then your function could look like this:

SELECT * FROM crosstab(
   'SELECT class, payment_method, sum(debit - credit) AS saldo
    FROM   tbl
    GROUP  BY 1,2
    ORDER  BY 1,2'

   ,$$VALUES 
        ('payment_method1'::text), ('sumofpayment_method1')
      , ('payment_method2'), ('sumofpayment_method2')
      , ('payment_method3'), ('sumofpayment_method3')$$
   )
AS ct (class text
     , payment_method1 numeric, sumofpayment_method1 numeric
     , payment_method2 numeric, sumofpayment_method2 numeric
     , payment_method3 numeric, sumofpayment_method3 numeric);


I am using all 6 "types" you mentioned. Well, I see that only half of them are actually intended as type. Either way, substitute your actual types.
More details, links and explanations in this related answer on SO.