Need help with custom script for Payment Request

I’m setting up a custom script to populate the request payment form. It appears my script is partially working as the Print Format field is populated with the correct info, but not the subject or message fields.

I’m hoping someone can point out my mistakes:

frappe.ui.form.on('Payment Request', {
  onload: function(frm){
    frm.set_value("print_format", "Rental Invoice");
    frm.set_value("message", get_message(frm));
    frm.set_value("subject", "Rental Invoice: " + doc.name);
    }
});

function get_message(frm) {
    var html = "<p>Dear customer</p>\n";
    html += "<p>Attached is the Rental Invoice in PDF format.</p>";
    html += "<table>";
    html += "<tr><td>Location: <td colspan=2>" + doc.shipping_address_name +"</td></tr>";
    html += "<tr><td>Invoice:</td> <td>" + doc.name + "</td><td></td></tr>";
    html += "<tr><td>Total Amount:</td> <td align=\"right\">" + doc.grand_total + "</td><td></td></tr>";
    html += "<tr><td>Less Advance:</td> <td align=\"right\">" + doc.total_advance + "</td><td></td></tr>";
    html += "<tr><td>Total Due:</td> <td align=\"right\">" + doc.outstanding_amount + "</td><td></td>  </tr>";
    html += "</table>";
    html += "<p><strong>To pay with a credit card <a href=\"" + payment_url +"\"> click here</a></strong>.</p>";
    html += "<p>If you have any questions, please feel free to call or email.</p>";
    html += "<p>Regards,";
    html += "<p>Rental Company</p>";

    return html;
}