Hi, Just for the record I fixed this by doing a getMultiAdapter for the ILineItemFactory and creating the item in the cart using this. All works now!
-Tim On Tue, 2009-05-12 at 09:26 +1200, Tim Knapp wrote: > Sorry, the full traceback is here[1]. > > [1] http://duffyd.pastebin.com/f510a43d9 > > On Tue, 2009-05-12 at 09:13 +1200, Tim Knapp wrote: > > Hi all, > > > > I'm progressing with my pay-for-membership package but have hit a > > roadblock with the "authorize" transition in my package. Essentially, > > within a subscriber to > > Products.PlonePAS.interfaces.events.IUserInitialLoginInEvent I do the > > following: > > > > <code> > > subscribers.py: > > def buyMembership(event): > > """ > > Redirect new member to payment processors website > > for payment > > """ > > if IMembraneUser.providedBy(event.object): > > # TODO:: Is _getMembraneObject() bad? > > if > > ISubscribemember.providedBy(event.object._getMembraneObject()): > > member = event.object._getMembraneObject() > > site = member.portal_url.getPortalObject() > > manage_options = IGetPaidManagementOptions(site) > > cart_util = getUtility(IShoppingCartUtility) > > cart = cart_util.get(site, create=True) > > createLineItem(member, cart) > > order_manager = getUtility(IOrderManager) > > order = Order() > > order.finance_workflow.fireTransition('create') > > order.processor_id = manage_options.payment_processor > > setContactInfo(order, member) > > order.order_id = order_manager.newOrderId() > > order.user_id = member.getId() > > order.shopping_cart = loads(dumps(cart)) > > order_manager.store(order) > > cart_util.destroy(site) > > member.lastOrderID = order.order_id > > > > def createLineItem(member, cart): > > line = PayableLineItem() > > line.uid = member.getMemberType() > > line.item_id = member.getMemberType() > > line.name = member.getMemberType() > > line.description = member.getMemberType() > > line.cost = member.getPrice() > > line.product_code = member.getMemberType() > > line.quantity = 1 > > cart[line.item_id] = line > > > > def setContactInfo(order, member): > > bill_address = payment.BillingAddress() > > bill_address.bill_first_line = member.getMemberAddress() > > bill_address.bill_city = member.getCity() > > bill_address.bill_state = member.getMemberState() > > bill_address.bill_country = "US" > > bill_address.bill_postal_code = member.getZip() > > contact_info = payment.ContactInformation() > > order.contact_information = contact_info > > order.billing_address = bill_address > > order.shipping_address = payment.ShippingAddress() > > </code> > > > > I tried doing the 'authorize' transition in here but it errored. So I've > > moved it to a utility browser view that creates the PayPal button in > > login_success.pt. The code for the button is as follows: > > > > <code> > > browser/common.py: > > class SubscribeMemberView(BrowserView): > > > > def checkout_button(self): > > site = getUtility(ISiteRoot) > > mtool = getToolByName(self.context, 'portal_membership') > > member = mtool.getAuthenticatedMember() > > if ISubscribemember.providedBy(member): > > getpaidoptions = > > IGetPaidManagementPaymentOptions(self.context) > > order_manager = getUtility(IOrderManager) > > order = order_manager.get(member.getLastOrderID()) > > order.finance_workflow.fireTransition('authorize') > > processor = getAdapter(self.context, IPaymentProcessor, > > getpaidoptions.payment_processor) > > if getpaidoptions.payment_processor == 'Paypal Website > > Payments Standard': > > button = processor.cart_post_button(order) > > return button > > else: > > return '' > > </code> > > > > When the above code runs, though, I get a TypeError. My pdb session is > > here for your perusal[1]. > > > > Can anyone give any ideas as to why this doesn't work (a lot of this > > code was copied from getpaid.paypal/brower/paypalbutton.py so should > > work). > > > > Thanks, > > Tim > > > > [1] http://duffyd.pastebin.com/f779a7fca > > > > > > > > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "getpaid-dev" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/getpaid-dev?hl=en -~----------~----~----~----~------~----~------~--~---
