So first off, I needed to create a custom host-to-order processor for 
mezzanine cartridge.  I'm using an older version of 
mezzanine(1.4.5)/cartridge(0.8.2) and due to the way this project was 
initial started, i'm sort of stuck with this (forked/custom) set of code. 
I'll update when i've got time, but for now, I'm almost done with the 
host-to-order.  The one last key issue I have is with adding items to the 
order object. I'm using cybersource secure acceptance and I have a working 
order/checkout that creates Order objects after a purchase.  

How do I create the order's items without using the shopping cart. I'm 
passing an encrypted session key to the callback which cybersource passes 
back to me so I could dig up the cart but i'd rather not use its contents 
as you could change that before the bank authorizes payment :)..  I'm 
passing all the item data through the bank's authorizer as well 
(instance.item_set) and so...

for item in instance.item_set.all():
    # item is a dict has everything defined similarly to the 
SelectedProject object.
    # so we have sku, description, quantity, unit_price, total_price (data 
from cybersource)
    #copy the dict
    order_item = dict([(f, getattr(item, f)) for f in product_fields])
    #guessing this creates the item for the order (but doesn't seem to work)
    order.items.create(**order_item)    

    ## Update stocks of the product
    try:
        variation = ProductVariation.objects.get(sku=item.sku)
    except ProductVariation.DoesNotExist:
        logger.info("ProductVariation didn't exist")
        pass
    else:
        variation.update_stock(item.quantity * -1)
        variation.product.actions.purchased()

My question, how do i manually create the items in the order.  I found this 
code in the class Order, (setup & complete functions) within the 
cartridge/shop/models.py file so i've adapted that to fit my needs but it 
doesn't seem to work. Obviously I'm missing something.

thanks,

-hagan

-- 
You received this message because you are subscribed to the Google Groups 
"Mezzanine Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to