From c141142c47d71ef4473cab48cf8df7daf06a8fec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Thu, 23 Jan 2014 16:57:44 +0100 Subject: [PATCH] [IMP] payment_paypal: use acquirer-defined URLs instead of hardcoded URLs bzr revid: tde@openerp.com-20140123155744-ao35bu6ct7btuytq --- addons/payment_paypal/models/paypal.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/addons/payment_paypal/models/paypal.py b/addons/payment_paypal/models/paypal.py index 6b31440468c..84b3fcfce97 100644 --- a/addons/payment_paypal/models/paypal.py +++ b/addons/payment_paypal/models/paypal.py @@ -135,12 +135,15 @@ class AcquirerPaypal(osv.Model): """ res = dict.fromkeys(ids, False) parameters = urllib.urlencode({'grant_type': 'client_credentials'}) - request = urllib2.Request('https://api.sandbox.paypal.com/v1/oauth2/token', parameters) - # add other headers (https://developer.paypal.com/webapps/developer/docs/integration/direct/make-your-first-call/) - request.add_header('Accept', 'application/json') - request.add_header('Accept-Language', 'en_US') for acquirer in self.browse(cr, uid, ids, context=context): + tx_url = self._get_paypal_urls(cr, uid, acquirer.env)['paypal_rest_url'] + request = urllib2.Request(tx_url, parameters) + + # add other headers (https://developer.paypal.com/webapps/developer/docs/integration/direct/make-your-first-call/) + request.add_header('Accept', 'application/json') + request.add_header('Accept-Language', 'en_US') + # add authorization header base64string = base64.encodestring('%s:%s' % ( acquirer.paypal_api_username,