[IMP] payment_acquirer_ogone: improved urls in rendered button, now using urljoin; added support of PARAMPLUS in button; various fixes due to method renaming; improved controllers; updated tests
bzr revid: tde@openerp.com-20131115133047-eggqo2a3sapzri2j
This commit is contained in:
@@ -25,8 +25,8 @@ from openerp.addons.web.http import request
|
||||
from openerp.addons.website.models import website
|
||||
|
||||
import logging
|
||||
import requests
|
||||
from urllib import urlencode
|
||||
# import requests
|
||||
# from urllib import urlencode
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -38,16 +38,26 @@ class OgoneController(http.Controller):
|
||||
_cancel_url = '/payment/ogone/test/cancel'
|
||||
|
||||
@website.route([
|
||||
'/payment/ogone/feedback', '/payment/ogone/test/accept',
|
||||
'/payment/ogone/accept', '/payment/ogone/test/accept',
|
||||
], type='http', auth='admin')
|
||||
def ogone_form_feedback(self, **post):
|
||||
cr, uid, context = request.cr, request.uid, request.context
|
||||
Payment = request.registry['payment.transaction']
|
||||
print 'Entering ogone feedback with', post
|
||||
return_url = post.pop('return_url', '/')
|
||||
print 'return_url', return_url
|
||||
|
||||
res = Payment.ogone_form_feedback(cr, uid, post, context)
|
||||
print 'result after feedback', res
|
||||
# return ''
|
||||
return request.redirect(return_url)
|
||||
|
||||
@website.route([
|
||||
'/payment/ogone/decline', '/payment/ogone/test/decline',
|
||||
'/payment/ogone/exception', '/payment/ogone/test/exception',
|
||||
'/payment/ogone/cancel', '/payment/ogone/test/cancel',
|
||||
], type='http', auth='admin')
|
||||
def feedback(self, **post):
|
||||
def ogone_form_feedback_other(self, **post):
|
||||
cr, uid, context = request.cr, request.uid, request.context
|
||||
Payment = request.registry['payment.transaction']
|
||||
print 'Entering ogone feedback with', post
|
||||
|
||||
res = Payment.tx_ogone_feedback(cr, uid, post, context)
|
||||
print res
|
||||
print 'Entering ogone_form_feedback_other', post
|
||||
return ''
|
||||
|
||||
@@ -27,7 +27,7 @@ from pprint import pformat
|
||||
import time
|
||||
from urllib import urlencode
|
||||
import urllib2
|
||||
# import urlparse
|
||||
import urlparse
|
||||
|
||||
from openerp.addons.payment_acquirer.models.payment_acquirer import ValidationError
|
||||
from openerp.addons.payment_acquirer_ogone.controllers.main import OgoneController
|
||||
@@ -130,21 +130,27 @@ class PaymentAcquirerOgone(osv.Model):
|
||||
'CN': partner and partner.name or partner_values.get('name', ''),
|
||||
'EMAIL': partner and partner.email or partner_values.get('email', ''),
|
||||
'OWNERZIP': partner and partner.zip or partner_values.get('zip', ''),
|
||||
'OWNERADDRESS': partner and ' '.join((partner.street, partner.street2)).strip() or ' '.join((partner_values.get('street', ''), partner_values.get('street2', ''))).strip(),
|
||||
'OWNERADDRESS': partner and ' '.join((partner.street or '', partner.street2 or '')).strip() or ' '.join((partner_values.get('street', ''), partner_values.get('street2', ''))).strip(),
|
||||
'OWNERTOWN': partner and partner.city or partner_values.get('city', ''),
|
||||
'OWNERCTY': partner and partner.country_id and partner.country_id.name or partner_values.get('country_name', ''),
|
||||
'OWNERTELNO': partner and partner.phone or partner_values.get('phone', ''),
|
||||
'ACCEPTURL': '%s/%s' % (base_url, OgoneController._accept_url),
|
||||
'DECLINEURL': '%s/%s' % (base_url, OgoneController._decline_url),
|
||||
'EXCEPTIONURL': '%s/%s' % (base_url, OgoneController._exception_url),
|
||||
'CANCELURL': '%s/%s' % (base_url, OgoneController._cancel_url),
|
||||
'ACCEPTURL': '%s' % urlparse.urljoin(base_url, OgoneController._accept_url),
|
||||
'DECLINEURL': '%s' % urlparse.urljoin(base_url, OgoneController._decline_url),
|
||||
'EXCEPTIONURL': '%s' % urlparse.urljoin(base_url, OgoneController._exception_url),
|
||||
'CANCELURL': '%s' % urlparse.urljoin(base_url, OgoneController._cancel_url),
|
||||
}
|
||||
if tx_custom_values and tx_custom_values.get('return_url'):
|
||||
tx_values['PARAMPLUS'] = 'return_url=%s' % tx_custom_values.pop('return_url')
|
||||
if tx_custom_values:
|
||||
tx_values.update(tx_custom_values)
|
||||
shasign = self._ogone_generate_shasign(acquirer, 'in', tx_values)
|
||||
tx_values['SHASIGN'] = shasign
|
||||
return tx_values
|
||||
|
||||
def ogone_get_form_action_url(self, cr, uid, id, context=None):
|
||||
acquirer = self.browse(cr, uid, id, context=context)
|
||||
return acquirer.ogone_standard_order_url
|
||||
|
||||
|
||||
class PaymentTxOgone(osv.Model):
|
||||
_inherit = 'payment.transaction'
|
||||
@@ -181,7 +187,7 @@ class PaymentTxOgone(osv.Model):
|
||||
tx = self.pool['payment.transaction'].browse(cr, uid, tx_ids[0], context=context)
|
||||
|
||||
# verify shasign
|
||||
shasign_check = self.pool['payment.acquirer']._generate_ogone_shasign(tx.acquirer_id, 'out', data)
|
||||
shasign_check = self.pool['payment.acquirer']._ogone_generate_shasign(tx.acquirer_id, 'out', data)
|
||||
if shasign_check.upper() != shasign.upper():
|
||||
error_msg = 'Ogone: invalid shasign, received %s, computed %s, for data %s' % (shasign, shasign_check, data)
|
||||
_logger.error(error_msg)
|
||||
@@ -213,7 +219,7 @@ class PaymentTxOgone(osv.Model):
|
||||
|
||||
def ogone_form_feedback(self, cr, uid, data, context=None):
|
||||
print '-- ogone: ogone_form_feedback'
|
||||
tx = self._ogone_get_tx_from_shasign_out(cr, uid, data, context)
|
||||
tx = self._ogone_form_get_tx_from_shasign_out(cr, uid, data, context)
|
||||
if not tx:
|
||||
raise ValidationError('Ogone: feedback: tx not found')
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ from openerp.addons.payment_acquirer_ogone.controllers.main import OgoneControll
|
||||
|
||||
from lxml import objectify
|
||||
# import requests
|
||||
# import urlparse
|
||||
import urlparse
|
||||
|
||||
|
||||
class BasicPayment(PaymentAcquirerCommon):
|
||||
@@ -68,11 +68,11 @@ class BasicPayment(PaymentAcquirerCommon):
|
||||
'OWNERCTY': 'Belgium',
|
||||
'OWNERTOWN': 'Sin City',
|
||||
'OWNERTELNO': '0032 12 34 56 78',
|
||||
'SHASIGN': 'ea74bb42d4f25746279cdd44a737aaddc71e7f9f',
|
||||
'ACCEPTURL': '%s/%s' % (base_url, OgoneController._accept_url),
|
||||
'DECLINEURL': '%s/%s' % (base_url, OgoneController._decline_url),
|
||||
'EXCEPTIONURL': '%s/%s' % (base_url, OgoneController._exception_url),
|
||||
'CANCELURL': '%s/%s' % (base_url, OgoneController._cancel_url),
|
||||
'SHASIGN': '815f67b8ff70d234ffcf437c13a9fa7f807044cc',
|
||||
'ACCEPTURL': '%s' % urlparse.urljoin(base_url, OgoneController._accept_url),
|
||||
'DECLINEURL': '%s' % urlparse.urljoin(base_url, OgoneController._decline_url),
|
||||
'EXCEPTIONURL': '%s' % urlparse.urljoin(base_url, OgoneController._exception_url),
|
||||
'CANCELURL': '%s' % urlparse.urljoin(base_url, OgoneController._cancel_url),
|
||||
}
|
||||
|
||||
# render the button
|
||||
|
||||
@@ -31,12 +31,17 @@
|
||||
<input type='hidden' name='BUTTONTXTCOLOR' t-att-value='tx_dict["currency_name"]'/>
|
||||
<input type='hidden' name='LOGO' t-att-value='tx_dict["currency_name"]'/>
|
||||
<input type='hidden' name='FONTTYPE' t-att-value='tx_dict["currency_name"]'/> -->
|
||||
<!-- after payment parameters -->
|
||||
<t t-if='tx_values.get("PARAMPLUS")'>
|
||||
<input type='hidden' name="PARAMPLUS" t-att-value='tx_values["PARAMPLUS"]'/>
|
||||
</t>
|
||||
<!-- redirection -->
|
||||
<input type='hidden' name='ACCEPTURL' t-att-value='tx_values["ACCEPTURL"]'/>
|
||||
<input type='hidden' name='DECLINEURL' t-att-value='tx_values["DECLINEURL"]'/>
|
||||
<input type='hidden' name='EXCEPTIONURL' t-att-value='tx_values["EXCEPTIONURL"]'/>
|
||||
<input type='hidden' name='CANCELURL' t-att-value='tx_values["CANCELURL"]'/>
|
||||
<input type="image" name="submit" src="https://www.paypal.com/en_US/i/btn/btn_paynowCC_LG.gif"/>
|
||||
<input type="image" name="submit" id="payment_submit"
|
||||
src="/payment_acquirer_ogone/static/src/img/ogone_logo_plain.gif"/>
|
||||
</form>
|
||||
</template>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user