summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThibault Delavallée <tde@openerp.com>2014-01-23 16:47:35 +0100
committerThibault Delavallée <tde@openerp.com>2014-01-23 16:47:35 +0100
commit4cfdab77b23d20df329883c486a47fd4dfd63e76 (patch)
tree2430e45cdb4e561e4929e792466f46722da17c98
parent24c8a6307bf3a1ea36235ea953391054da27f572 (diff)
[CLEAN] payment_ogone, payment_paypal: added tags in docstrings for s2s methods. Those methods are now identified as experimental as not finished and/or not tested.
bzr revid: tde@openerp.com-20140123154735-o5z6j4fh1ysll356
-rw-r--r--addons/payment_ogone/models/ogone.py31
-rw-r--r--addons/payment_paypal/models/paypal.py67
2 files changed, 84 insertions, 14 deletions
diff --git a/addons/payment_ogone/models/ogone.py b/addons/payment_ogone/models/ogone.py
index 1cbd3a53666..e447b212765 100644
--- a/addons/payment_ogone/models/ogone.py
+++ b/addons/payment_ogone/models/ogone.py
@@ -212,7 +212,14 @@ class PaymentTxOgone(osv.Model):
# --------------------------------------------------
def ogone_s2s_create_alias(self, cr, uid, id, values, context=None):
- """ Purpose: create an alias via batch """
+ """ Create an alias at Ogone via batch.
+
+ .. versionadded:: pre-v8 saas-3
+ .. warning::
+
+ Experimental code. You should not use it before OpenERP v8 official
+ release.
+ """
tx = self.browse(cr, uid, id, context=context)
assert tx.type == 'server2server', 'Calling s2s dedicated method for a %s acquirer' % tx.type
alias = 'OPENERP-%d-%d' % (tx.partner_id.id, tx.id)
@@ -265,6 +272,14 @@ class PaymentTxOgone(osv.Model):
return True
def ogone_s2s_generate_values(self, cr, uid, id, custom_values, context=None):
+ """ Generate valid Ogone values for a s2s tx.
+
+ .. versionadded:: pre-v8 saas-3
+ .. warning::
+
+ Experimental code. You should not use it before OpenERP v8 official
+ release.
+ """
tx = self.browse(cr, uid, id, context=context)
tx_data = {
'PSPID': tx.acquirer_id.ogone_pspid,
@@ -295,9 +310,23 @@ class PaymentTxOgone(osv.Model):
return tx_data
def ogone_s2s_feedback(self, cr, uid, data, context=None):
+ """
+ .. versionadded:: pre-v8 saas-3
+ .. warning::
+
+ Experimental code. You should not use it before OpenERP v8 official
+ release.
+ """
pass
def ogone_s2s_execute(self, cr, uid, id, values, context=None):
+ """
+ .. versionadded:: pre-v8 saas-3
+ .. warning::
+
+ Experimental code. You should not use it before OpenERP v8 official
+ release.
+ """
tx = self.browse(cr, uid, id, context=context)
tx_data = self.ogone_s2s_generate_values(cr, uid, id, values, context=context)
diff --git a/addons/payment_paypal/models/paypal.py b/addons/payment_paypal/models/paypal.py
index f02fb644eec..6b31440468c 100644
--- a/addons/payment_paypal/models/paypal.py
+++ b/addons/payment_paypal/models/paypal.py
@@ -245,23 +245,42 @@ class TxPaypal(osv.Model):
# --------------------------------------------------
def _paypal_try_url(self, request, tries=3, context=None):
- try:
- res = urllib2.urlopen(request)
- except urllib2.HTTPError as e:
- res = e.read()
- e.close()
- if tries and res and json.loads(res)['name'] == 'INTERNAL_SERVICE_ERROR':
- _logger.warning('Failed contacting Paypal, retrying (%s remaining)' % tries)
- return self._paypal_try_url(request, tries=tries - 1, context=context)
- raise
- except:
- raise
+ """ Try to contact Paypal. Due to some issues, internal service errors
+ seem to be quite frequent. Several tries are done before considering
+ the communication as failed.
+ .. versionadded:: pre-v8 saas-3
+ .. warning::
+
+ Experimental code. You should not use it before OpenERP v8 official
+ release.
+ """
+ done, res = False, None
+ while (not done and tries):
+ try:
+ res = urllib2.urlopen(request)
+ done = True
+ except urllib2.HTTPError as e:
+ res = e.read()
+ e.close()
+ if tries and res and json.loads(res)['name'] == 'INTERNAL_SERVICE_ERROR':
+ _logger.warning('Failed contacting Paypal, retrying (%s remaining)' % tries)
+ tries = tries - 1
+ if not res:
+ pass
+ # raise openerp.exceptions.
result = res.read()
res.close()
return result
def _paypal_s2s_send(self, cr, uid, values, cc_values, context=None):
+ """
+ .. versionadded:: pre-v8 saas-3
+ .. warning::
+
+ Experimental code. You should not use it before OpenERP v8 official
+ release.
+ """
tx_id = self.create(cr, uid, values, context=context)
tx = self.browse(cr, uid, tx_id, context=context)
@@ -301,9 +320,10 @@ class TxPaypal(osv.Model):
}]
}
else:
+ # TODO: complete redirect URLs
data['redirect_urls'] = {
- 'return_url': 'http://example.com/your_redirect_url/',
- 'cancel_url': 'http://example.com/your_cancel_url/',
+ # 'return_url': 'http://example.com/your_redirect_url/',
+ # 'cancel_url': 'http://example.com/your_cancel_url/',
},
data['payer'] = {
'payment_method': 'paypal',
@@ -315,10 +335,24 @@ class TxPaypal(osv.Model):
return (tx_id, result)
def _paypal_s2s_get_invalid_parameters(self, cr, uid, tx, data, context=None):
+ """
+ .. versionadded:: pre-v8 saas-3
+ .. warning::
+
+ Experimental code. You should not use it before OpenERP v8 official
+ release.
+ """
invalid_parameters = []
return invalid_parameters
def _paypal_s2s_validate(self, cr, uid, tx, data, context=None):
+ """
+ .. versionadded:: pre-v8 saas-3
+ .. warning::
+
+ Experimental code. You should not use it before OpenERP v8 official
+ release.
+ """
values = json.loads(data)
status = values.get('state')
if status in ['approved']:
@@ -348,6 +382,13 @@ class TxPaypal(osv.Model):
return False
def _paypal_s2s_get_tx_status(self, cr, uid, tx, context=None):
+ """
+ .. versionadded:: pre-v8 saas-3
+ .. warning::
+
+ Experimental code. You should not use it before OpenERP v8 official
+ release.
+ """
# TDETODO: check tx.paypal_txn_id is set
headers = {
'Content-Type': 'application/json',