X-Git-Url: https://svn.cri.ensmp.fr/git/photoprint.git/blobdiff_plain/1b83cf35c475d8736a960cb62e756116e99045dc..02c36b8896ac73cfa6c3eb22709693810fb3ff6e:/order.py?ds=sidebyside diff --git a/order.py b/order.py index 9323dd3..028a73a 100755 --- a/order.py +++ b/order.py @@ -423,153 +423,7 @@ class PrintOrder(PortalContent, DefaultDublinCoreImpl) : security.declareProtected(ManagePortal, 'getPPLog') def getPPLog(self) : return self._paypalLog - - - - # 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' - # - # wtool = getToolByName(self, 'portal_workflow') - # wf = wtool.getWorkflowById('order_workflow') - # tdef = wf.transitions.get(wfaction) - # wf._changeStateOf(self, tdef) - # wtool._reindexWorkflowVariables(self) - - # security.declarePublic('paymentAutoResponseHandler') - # @postonly - # def paymentAutoResponseHandler(self, REQUEST) : - # """\ - # Handle cyberplus payment auto response. - # """ - # response = self._decodeCyberplusResponse(REQUEST.form) - # self._checkOrderId(response) - # self._paymentResponse.update(response) - # self._executeOrderWfTransition(response) - # - # @postonly - # def paymentManualResponseHandler(self, REQUEST) : - # """\ - # Handle cyberplus payment manual response. - # """ - # response = self._decodeCyberplusResponse(REQUEST.form) - # self._checkOrderId(response) - # - # autoResponse = self._paymentResponse - # if not autoResponse : - # console.warn('Manual response handled before auto response at %s' % '/'.join(self.getPhysicalPath())) - # self._paymentResponse.update(response) - # self._executeOrderWfTransition(response) - # else : - # self._compareWithAutoResponse(response) - # - # url = '%s?%s' % (self.absolute_url(), - # make_query(portal_status_message=translate('Your payment is complete.', self).encode('utf-8')) - # ) - # return REQUEST.RESPONSE.redirect(url) - # - # @postonly - # def paymentCancelHandler(self, REQUEST) : - # """\ - # Handle cyberplus cancel response. - # This handler can be invoqued in two cases: - # - the user cancel the payment form - # - the payment transaction has been refused - # """ - # response = self._decodeCyberplusResponse(REQUEST.form) - # self._checkOrderId(response) - # - # if self._paymentResponse : - # # normaly, it happens when the transaction is refused by cyberplus. - # self._compareWithAutoResponse(response) - # - # - # if CyberplusResponder.transactionRefused(response) : - # if not self._paymentResponse : - # console.warn('Manual response handled before auto response at %s' % '/'.join(self.getPhysicalPath())) - # self._paymentResponse.update(response) - # self._executeOrderWfTransition(response) - # - # msg = 'Your payment has been refused.' - # - # else : - # self._executeOrderWfTransition(response) - # msg = 'Your payment has been canceled. You will be able to pay later.' - # - # url = '%s?%s' % (self.absolute_url(), - # make_query(portal_status_message= \ - # translate(msg, self).encode('utf-8')) - # ) - # return REQUEST.RESPONSE.redirect(url) - def getCustomerSummary(self) : ' ' return {'quantity':self.quantity,