X-Git-Url: https://scm.cri.ensmp.fr/git/photoprint.git/blobdiff_plain/b92ab62e2af2ba6788d1af5b0750f41948fffa68..077104edcbc86919b1ba1bf6318e88201614faa4:/order.py?ds=inline diff --git a/order.py b/order.py index 6185b9d..db19cc0 100755 --- a/order.py +++ b/order.py @@ -45,7 +45,11 @@ from price import Price from xml.dom.minidom import Document from tool import COPIES_COUNTERS from App.config import getConfiguration -from paypal.interface import PayPalInterface +try : + from paypal.interface import PayPalInterface + paypalAvailable = True +except ImportError : + paypalAvailable = False from logging import getLogger console = getLogger('Products.photoprint.order') @@ -311,12 +315,10 @@ class PrintOrder(PortalContent, DefaultDublinCoreImpl) : portal = utool.getPortalObject() member = mtool.getAuthenticatedMember() - options = {#'PAYMENTREQUEST_0_AMT' : '99.55', # todo - 'PAYMENTREQUEST_0_CURRENCYCODE' : 'EUR', + options = {'PAYMENTREQUEST_0_CURRENCYCODE' : 'EUR', 'PAYMENTREQUEST_0_PAYMENTACTION' : 'Sale', 'RETURNURL' : '%s/photoprint_order_confirm' % self.absolute_url(), 'CANCELURL' : '%s/photoprint_order_cancel' % self.absolute_url(), - # 'CALLBACK' : TODO 'ALLOWNOTE' : 0, # The buyer is unable to enter a note to the merchant. 'HDRIMG' : '%s/logo.gif' % portal_url, 'EMAIL' : member.getProperty('email'), @@ -327,8 +329,6 @@ class PrintOrder(PortalContent, DefaultDublinCoreImpl) : 'GIFTRECEIPTENABLE' : 0, 'BUYEREMAILOPTINENABLE' : 0, # Do not enable buyer to provide email address. 'NOSHIPPING' : 1, # PayPal does not display shipping address fields whatsoever. - # 'PAYMENTREQUEST_0_NOTIFYURL' : TODO - 'PAYMENTREQUEST_0_SHIPTONAME' : self.billing['name'], 'PAYMENTREQUEST_0_SHIPTOSTREET' : self.billing['address'], 'PAYMENTREQUEST_0_SHIPTOCITY' : self.billing['city'], @@ -337,20 +337,18 @@ class PrintOrder(PortalContent, DefaultDublinCoreImpl) : } if len(self.items) > 1 : - quantitySum = reduce(lambda a, b : a['quantity'] + b['quantity'], self.items) + quantitySum = reduce(lambda a, b : a + b, [item['quantity'] for item in self.items]) else : quantitySum = self.items[0]['quantity'] total = round(self.amountWithFees.getValues()['taxed'], 2) - options['L_PAYMENTREQUEST_0_NAME0'] = 'Commande realis photo ref. %s' % self.getId() + options['L_PAYMENTREQUEST_0_NAME0'] = 'Commande photo ref. %s' % self.getId() if quantitySum == 1 : options['L_PAYMENTREQUEST_0_DESC0'] = "Commande d'un tirage photographique" else : options['L_PAYMENTREQUEST_0_DESC0'] = 'Commande de %d tirages photographiques' % quantitySum options['L_PAYMENTREQUEST_0_AMT0'] = total options['PAYMENTINFO_0_SHIPPINGAMT'] = round(self.shippingFees.getValues()['taxed'], 2) - # options['L_PAYMENTREQUEST_0_TAXAMT0'] = tax - # options['L_PAYMENTREQUEST_0_QTY%d' % n] = 1 options['PAYMENTREQUEST_0_AMT'] = total ppi = self._initPayPalInterface()