- member = mtool.getAuthenticatedMember()
- mg = lambda name : member.getProperty(name, '')
- billing = {'name' : member.getMemberFullName(nameBefore=0)
- ,'address' : mg('billing_address')
- ,'city' : mg('billing_city')
- ,'zipcode' : mg('billing_zipcode')
- ,'country' : mg('country')
- ,'phone' : mg('phone') }
- self.editBilling(**billing)
-
- sg = lambda name : cart._shippingInfo.get(name, '')
- shipping = {'name' : sg('shipping_fullname')
- ,'address' : sg('shipping_address')
- ,'city' : sg('shipping_city')
- ,'zipcode' : sg('shipping_zipcode')
- ,'country' : sg('shipping_country')}
- self.editShipping(**shipping)
-
- self.shippingFees = pptool.getShippingFeesFor(shippable=self)
-
- cart._confirmed = True
- cart.pendingOrderPath = self.getPhysicalPath()
-
- security.declareProtected(ManagePrintOrders, 'resetCopiesCounters')
- def resetCopiesCounters(self) :
- pptool = getToolByName(self, 'portal_photo_print')
- uidh = getToolByName(self, 'portal_uidhandler')
-
- for item in self.items :
- photo = uidh.getObject(item['cmf_uid'])
- counters = getattr(photo, COPIES_COUNTERS, None)
- if counters :
- counters.cancel(item['productReference'],
- item['quantity'])
-
- security.declareProtected(View, 'getPaymentRequest')
- def getPaymentRequest(self) :
- config = _getCyberplusConfig()
- requester = CyberplusRequester(config)
- hereurl = self.absolute_url()
- amount = self.price + self.shippingFees
- amount = amount.getValues()['taxed']
- amount = amount * 100
- amount = str(int(round(amount, 0)))
- pptool = getToolByName(self, 'portal_photo_print')
- transaction_id = pptool.getNextTransactionId()
-
- userLanguages = getPreferredLanguages(self)
- for pref in userLanguages :
- lang = pref.split('-')[0]
- if lang in CYBERPLUS_LANGUAGES :
- break
- else :
- lang = 'en'
-
- options = { 'amount': amount
- ,'cancel_return_url' : '%s/paymentCancelHandler' % hereurl
- ,'normal_return_url' : '%s/paymentManualResponseHandler' % hereurl
- ,'automatic_response_url' :'%s/paymentAutoResponseHandler' % hereurl
- ,'transaction_id' : transaction_id
- ,'order_id' : self.getId()
- ,'language' : lang
- }
- req = requester.generateRequest(options)
- return req
-
- def _decodeCyberplusResponse(self, form) :
- config = _getCyberplusConfig()
- responder = CyberplusResponder(config)
- response = responder.getResponse(form)
- return response
-
- def _compareWithAutoResponse(self, manu) :
- keys = manu.keys()
- auto = self._paymentResponse
- autoKeys = auto.keys()
- if len(keys) != len(autoKeys) :
- console.warn('Manual has not the same keys.\nauto: %r\nmanual: %r' % \
- (sorted(autoKeys), sorted(keys)))
- else :
- for k, v in manu.items() :
- if not auto.has_key(k) :
- console.warn('%r field only found in manual response.' % k)
- else :
- if v != auto[k] :
- console.warn('data mismatch for %r\nauto: %r\nmanual: %r' % (k, auto[k], v))
-
- def _checkOrderId(self, response) :
- expected = self.getId()
- assert expected == response['order_id'], \
- "Cyberplus response transaction_id doesn't match the order object:\n" \
- "expected: %s\n" \
- "found: %s" % (expected, response['transaction_id'])
-
- def _executeOrderWfTransition(self, response) :
- if CyberplusResponder.transactionAccepted(response) :
- wfaction = 'auto_accept_payment'
- elif CyberplusResponder.transactionRefused(response) :
- self.resetCopiesCounters()
- wfaction = 'auto_refuse_payment'
- elif CyberplusResponder.transactionCanceled(response) :
- wfaction = 'auto_cancel_order'
- else :
- # transaction failed
- wfaction = 'auto_transaction_failed'