Remove usage of deprecated function and duplicated code in getPayment()