Oubli de mot de passe : utilisation du formulaire de réinitialisation au lieu de...
[photoprint.git] / order.py
index 028a73a..ea48483 100755 (executable)
--- a/order.py
+++ b/order.py
@@ -30,6 +30,7 @@ from AccessControl import ClassSecurityInfo
 from AccessControl.requestmethod import postonly
 from zope.interface import implements
 from zope.component.factory import Factory
 from AccessControl.requestmethod import postonly
 from zope.interface import implements
 from zope.component.factory import Factory
+from persistent.list import PersistentList
 from OFS.SimpleItem import SimpleItem
 from ZTUtils import make_query
 from DateTime import DateTime
 from OFS.SimpleItem import SimpleItem
 from ZTUtils import make_query
 from DateTime import DateTime
@@ -41,8 +42,6 @@ from Products.Plinn.utils import getPreferredLanguages
 from interfaces import IPrintOrderTemplate, IPrintOrder
 from permissions import ManagePrintOrderTemplate, ManagePrintOrders
 from price import Price
 from interfaces import IPrintOrderTemplate, IPrintOrder
 from permissions import ManagePrintOrderTemplate, ManagePrintOrders
 from price import Price
-from utils import Message as _
-from utils import translate
 from xml.dom.minidom import Document
 from tool import COPIES_COUNTERS
 from App.config import getConfiguration
 from xml.dom.minidom import Document
 from tool import COPIES_COUNTERS
 from App.config import getConfiguration
@@ -185,7 +184,7 @@ class PrintOrder(PortalContent, DefaultDublinCoreImpl) :
         self.billing = PersistentMapping()
         self.shipping = PersistentMapping()
         self.shippingFees = Price(0,0)
         self.billing = PersistentMapping()
         self.shipping = PersistentMapping()
         self.shippingFees = Price(0,0)
-        self._paymentResponse = PersistentMapping()
+        self._paypalLog = PersistentList()
     
     @property
     def amountWithFees(self) :
     
     @property
     def amountWithFees(self) :
@@ -312,12 +311,10 @@ class PrintOrder(PortalContent, DefaultDublinCoreImpl) :
         portal = utool.getPortalObject()
         member = mtool.getAuthenticatedMember()
         
         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(),
                    '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'),
                    'ALLOWNOTE' : 0, # The buyer is unable to enter a note to the merchant.
                    'HDRIMG' : '%s/logo.gif' % portal_url,
                    'EMAIL' : member.getProperty('email'),
@@ -328,8 +325,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.
                    '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'],
                    'PAYMENTREQUEST_0_SHIPTONAME' : self.billing['name'],
                    'PAYMENTREQUEST_0_SHIPTOSTREET' : self.billing['address'],
                    'PAYMENTREQUEST_0_SHIPTOCITY' : self.billing['city'],
@@ -350,14 +345,12 @@ class PrintOrder(PortalContent, DefaultDublinCoreImpl) :
             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_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()
         response = ppi.set_express_checkout(**options)
         response = PrintOrder.recordifyPPResp(response)
         options['PAYMENTREQUEST_0_AMT'] = total
 
         ppi = self._initPayPalInterface()
         response = ppi.set_express_checkout(**options)
         response = PrintOrder.recordifyPPResp(response)
-        self._paypalLog.append(response)
+        self._paypalLog.append(response)
         response['url'] = ppi.generate_express_checkout_redirect_url(response['TOKEN'])
         console.info(options)
         console.info(response)
         response['url'] = ppi.generate_express_checkout_redirect_url(response['TOKEN'])
         console.info(options)
         console.info(response)
@@ -368,7 +361,7 @@ class PrintOrder(PortalContent, DefaultDublinCoreImpl) :
         ppi = self._initPayPalInterface()
         response = ppi.get_express_checkout_details(TOKEN=token)
         response = PrintOrder.recordifyPPResp(response)
         ppi = self._initPayPalInterface()
         response = ppi.get_express_checkout_details(TOKEN=token)
         response = PrintOrder.recordifyPPResp(response)
-        self._paypalLog.append(response)
+        self._paypalLog.append(response)
         return response
     
     security.declarePrivate('ppDoExpressCheckoutPayment')
         return response
     
     security.declarePrivate('ppDoExpressCheckoutPayment')
@@ -380,7 +373,7 @@ class PrintOrder(PortalContent, DefaultDublinCoreImpl) :
                                                    TOKEN=token,
                                                    PAYERID=payerid)
         response = PrintOrder.recordifyPPResp(response)
                                                    TOKEN=token,
                                                    PAYERID=payerid)
         response = PrintOrder.recordifyPPResp(response)
-        self._paypalLog.append(response)
+        self._paypalLog.append(response)
         return response
     
     security.declareProtected(ModifyPortalContent, 'ppPay')
         return response
     
     security.declareProtected(ModifyPortalContent, 'ppPay')