Advanced payment REFACTOR CODE