Custom Function to update Custom Field in Zoho Invoice

Custom Function to update Custom Field in Zoho Invoice

Hello, I need you help urgently. 
I would like to see Payment Method associated with the invoice in Zoho Invoice.

I have a custom field in Invoice Module called Payment Type. When I associate a payment with the invoice this field needs to be updated with the data from Payments Module - Payment Method.

Here is the code I wrote but couldn't make it work, need your help.

This is a custom function for payments module and will affect Invoice module.

payment = customer_payment.get("payment_mode");
invoice = List();
invoice = customer_payment.get("invoices").toList();
invoiceid = invoice.getJSON("invoice_id");
odeme = Map();
odeme = zoho.invoice.getRecordById("invoices",717534537,invoiceid).get("invoice").get("custom_field_hash");
odeme.update("cf_deme_tipi",payment);
zoho.invoice.update("invoices", 717534537, invoiceid, odeme);