Modify/Create new PayPal plugin to send Itemized cart


In indico v1.2 I modified the PayPal plugin to send an itemized cart using something like the following to construct the PayPal request HTML form:

s = """<form action="%s" method="POST" id="%s">
    <input type="hidden" name="cmd" value="_cart">
    <input type="hidden" name="upload" value="1">
    <input type="hidden" name="business" value="%s">
    <input type="hidden" name="invoice" value="%s">
    <input type="hidden" name=="currency_code" value="%s">
    <input type="hidden" name="charset" value="utf-8">
    <input type="hidden" name="return" value="%s">
    <input type="hidden" name="cancel_return" value="%s">
    <input type="hidden" name="notify_url" value="%s">
    <div id="paypalItems" name="paypalItems">""" %(..values...)

i = 0    
for bf in registrant.getBilledForms():
    for item in bf.getBilledItems():
        caption = item.getCaption()
        item_number = "None"
        if caption.upper().strip() in self._items:
            item_number = self._items[caption.upper().strip()]
        currency = item.getCurrency()
        price = item.getPrice()
        quantity = item.getQuantity()
        total += price * quantity
        if quantity > 0:
            si = si + """
                <input type="hidden" name="item_name_%s" value="%s">""" %(i,caption)
            si = si + """
                <input type="hidden" name="item_number_%s" value="%s">""" %(i,item_number)
            si = si + """
                <input type="hidden" name="amount_%s" value="%s">""" %(i, price)
            si = si + """
                <input type="hidden" name="quantity_%s" value="%s">""" %(i, quantity)
            i += 1
s= s + si + """

I am trying to do something similar for indico v2 but I am not able to get the billable items in the PayPal plugin.

Also, I would like to add a text field that will only be available to PayPal for all billable items.

Your help will be appreciated!

Thank you