[IMP] acquirers: added support of context-based submit button customize + transaction url. Also removed all fields holding transaction URLS; calling a method should be sufficient. Also standardized acquirer buttons.
bzr revid: tde@openerp.com-20131204130505-webiutb22kb7t4il
@@ -21,26 +21,24 @@ _logger = logging.getLogger(__name__)
|
||||
class AcquirerAdyen(osv.Model):
|
||||
_inherit = 'payment.acquirer'
|
||||
|
||||
def _get_adyen_urls(self, cr, uid, ids, name, args, context=None):
|
||||
def _get_adyen_urls(self, cr, uid, env, context=None):
|
||||
""" Adyen URLs
|
||||
|
||||
- yhpp: hosted payment page: pay.shtml for single, select.shtml for multiple
|
||||
"""
|
||||
res = {}
|
||||
for acquirer in self.browse(cr, uid, ids, context=context):
|
||||
qualif = acquirer.env
|
||||
res[acquirer.id] = {
|
||||
'adyen_form_url': 'https://%s.adyen.com/hpp/pay.shtml' % qualif,
|
||||
if env == 'prod':
|
||||
return {
|
||||
'adyen_form_url': 'https://prod.adyen.com/hpp/pay.shtml',
|
||||
}
|
||||
else:
|
||||
return {
|
||||
'adyen_form_url': 'https://test.adyen.com/hpp/pay.shtml',
|
||||
}
|
||||
return res
|
||||
|
||||
_columns = {
|
||||
'adyen_merchant_account': fields.char('Merchant Account', required_if_provider='adyen'),
|
||||
'adyen_skin_code': fields.char('Skin Code', required_if_provider='adyen'),
|
||||
'adyen_skin_hmac_key': fields.char('Skin HMAC Key', required_if_provider='adyen'),
|
||||
'adyen_form_url': fields.function(
|
||||
_get_adyen_urls, multi='_get_adyen_urls',
|
||||
type='char', string='Transaction URL', required_if_provider='adyen'),
|
||||
}
|
||||
|
||||
def _adyen_generate_merchant_sig(self, acquirer, inout, values):
|
||||
@@ -99,7 +97,7 @@ class AcquirerAdyen(osv.Model):
|
||||
|
||||
def adyen_get_form_action_url(self, cr, uid, id, context=None):
|
||||
acquirer = self.browse(cr, uid, id, context=context)
|
||||
return acquirer.adyen_form_url
|
||||
return self._get_adyen_urls(cr, uid, acquirer.env, context=context)['adyen_form_url']
|
||||
|
||||
|
||||
class TxAdyen(osv.Model):
|
||||
|
||||
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 6.7 KiB |
|
Before Width: | Height: | Size: 4.0 KiB |
|
After Width: | Height: | Size: 11 KiB |
@@ -3,7 +3,7 @@
|
||||
<data noupdate="0">
|
||||
|
||||
<template id="adyen_acquirer_button">
|
||||
<form t-if="acquirer.adyen_merchant_account" t-att-action="acquirer.adyen_form_url" method="post" target="_self">
|
||||
<form t-if="acquirer.adyen_merchant_account" t-att-action="tx_url" method="post" target="_self">
|
||||
<input type="hidden" name="merchantReference" t-att-value="tx_values['merchantReference']"/>
|
||||
<input type="hidden" name="paymentAmount" t-att-value="tx_values['paymentAmount']"/>
|
||||
<input type="hidden" name="currencyCode" t-att-value="tx_values['currencyCode']"/>
|
||||
@@ -19,10 +19,12 @@
|
||||
<!-- custom -->
|
||||
<input t-if="tx_values.get('merchantReturnData')" type='hidden' name='merchantReturnData'
|
||||
t-att-value="tx_values.get('merchantReturnData')"/>
|
||||
<!-- button -->
|
||||
<input type="image" name="submit" id="payment_submit"
|
||||
width="100px"
|
||||
src="/payment_acquirer_adyen/static/src/img/logo.jpg"/>
|
||||
<!-- submit -->
|
||||
<button type="image" name="submit" width="100px"
|
||||
t-att-class="submit_class">
|
||||
<img t-if="not submit_txt" src="/payment_acquirer_adyen/static/src/img/adyen_icon.png"/>
|
||||
<span t-if="submit_txt"><t t-esc="submit_txt"/></span>
|
||||
</button>
|
||||
</form>
|
||||
</template>
|
||||
|
||||
|
||||
@@ -7,10 +7,12 @@
|
||||
<field name="model">payment.acquirer</field>
|
||||
<field name="inherit_id" ref="payment_acquirer.acquirer_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr='//group[@name="acquirer_base"]' position='after'>
|
||||
<group string="Adyen Details"
|
||||
attrs="{'invisible': [('name', '!=', 'adyen')]}">
|
||||
<xpath expr='//group[@name="acquirer_display"]' position='after'>
|
||||
<group attrs="{'invisible': [('name', '!=', 'adyen')]}">
|
||||
<field name="adyen_merchant_account"/>
|
||||
<field name="adyen_skin_code"/>
|
||||
<field name="adyen_skin_hmac_key"/>
|
||||
<field name="adyen_form_url"/>
|
||||
</group>
|
||||
</xpath>
|
||||
</field>
|
||||
|
||||
@@ -25,23 +25,19 @@ _logger = logging.getLogger(__name__)
|
||||
class PaymentAcquirerOgone(osv.Model):
|
||||
_inherit = 'payment.acquirer'
|
||||
|
||||
def _get_ogone_urls(self, cr, uid, ids, name, args, context=None):
|
||||
def _get_ogone_urls(self, cr, uid, env, context=None):
|
||||
""" Ogone URLS:
|
||||
|
||||
- standard order: POST address for form-based
|
||||
|
||||
@TDETODO: complete me
|
||||
"""
|
||||
res = {}
|
||||
for acquirer in self.browse(cr, uid, ids, context=context):
|
||||
qualif = acquirer.env
|
||||
res[acquirer.id] = {
|
||||
'ogone_standard_order_url': 'https://secure.ogone.com/ncol/%s/orderstandard.asp' % qualif,
|
||||
'ogone_direct_order_url': 'https://secure.ogone.com/ncol/%s/orderdirect.asp' % qualif,
|
||||
'ogone_direct_query_url': 'https://secure.ogone.com/ncol/%s/querydirect.asp' % qualif,
|
||||
'ogone_afu_agree_url': 'https://secure.ogone.com/ncol/%s/AFU_agree.asp' % qualif,
|
||||
}
|
||||
return res
|
||||
return {
|
||||
'ogone_standard_order_url': 'https://secure.ogone.com/ncol/%s/orderstandard.asp' % env,
|
||||
'ogone_direct_order_url': 'https://secure.ogone.com/ncol/%s/orderdirect.asp' % env,
|
||||
'ogone_direct_query_url': 'https://secure.ogone.com/ncol/%s/querydirect.asp' % env,
|
||||
'ogone_afu_agree_url': 'https://secure.ogone.com/ncol/%s/AFU_agree.asp' % env,
|
||||
}
|
||||
|
||||
_columns = {
|
||||
'ogone_pspid': fields.char(
|
||||
@@ -54,19 +50,6 @@ class PaymentAcquirerOgone(osv.Model):
|
||||
'SHA Key IN', size=32, required_if_provider='ogone'),
|
||||
'ogone_shakey_out': fields.char(
|
||||
'SHA Key OUT', size=32, required_if_provider='ogone'),
|
||||
# store ogone contact URLs -> not necessary IMHO
|
||||
'ogone_standard_order_url': fields.function(
|
||||
_get_ogone_urls, type='char', multi='_get_ogone_urls',
|
||||
string='Stanrd Order URL (form)'),
|
||||
'ogone_direct_order_url': fields.function(
|
||||
_get_ogone_urls, type='char', multi='_get_ogone_urls',
|
||||
string='Direct Order URL (2)'),
|
||||
'ogone_direct_query_url': fields.function(
|
||||
_get_ogone_urls, type='char', multi='_get_ogone_urls',
|
||||
string='Direct Query URL'),
|
||||
'ogone_afu_agree_url': fields.function(
|
||||
_get_ogone_urls, type='char', multi='_get_ogone_urls',
|
||||
string='AFU Agree URL'),
|
||||
}
|
||||
|
||||
def _ogone_generate_shasign(self, acquirer, inout, values):
|
||||
@@ -128,7 +111,7 @@ class PaymentAcquirerOgone(osv.Model):
|
||||
|
||||
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
|
||||
return self._get_ogone_urls(cr, uid, acquirer.env, context=context)['ogone_standard_order_url']
|
||||
|
||||
|
||||
class PaymentTxOgone(osv.Model):
|
||||
@@ -140,10 +123,8 @@ class PaymentTxOgone(osv.Model):
|
||||
_ogone_cancel_tx_status = [1]
|
||||
|
||||
_columns = {
|
||||
'ogone_3ds': fields.dummy('3ds Activated'),
|
||||
'ogone_3ds': fields.boolean('3DS Activated'),
|
||||
'ogone_3ds_html': fields.html('3DS HTML'),
|
||||
'ogone_feedback_model': fields.char(),
|
||||
'ogone_feedback_eval': fields.char(),
|
||||
'ogone_complus': fields.char('Complus'),
|
||||
'ogone_payid': fields.char('PayID', help='Payment ID, generated by Ogone')
|
||||
}
|
||||
@@ -243,6 +224,7 @@ class PaymentTxOgone(osv.Model):
|
||||
'PROCESS_MODE': 'CHECKANDPROCESS',
|
||||
}
|
||||
|
||||
# TODO: fix URL computation
|
||||
request = urllib2.Request(tx.acquirer_id.ogone_afu_agree_url, urlencode(tx_data))
|
||||
result = urllib2.urlopen(request).read()
|
||||
|
||||
|
||||
|
After Width: | Height: | Size: 8.5 KiB |
|
Before Width: | Height: | Size: 8.3 KiB |
|
Before Width: | Height: | Size: 3.1 KiB |
@@ -3,7 +3,7 @@
|
||||
<data noupdate="0">
|
||||
|
||||
<template id="ogone_acquirer_button">
|
||||
<form t-if="acquirer" t-att-action="acquirer.ogone_standard_order_url" method="post" target="_self">
|
||||
<form t-if="acquirer" t-att-action="tx_url" method="post" target="_self">
|
||||
<!-- seller -->
|
||||
<input type='hidden' name='PSPID' t-att-value='tx_values["PSPID"]'/>
|
||||
<input type='hidden' name='ORDERID' t-att-value='tx_values["ORDERID"]'/>
|
||||
@@ -40,8 +40,12 @@
|
||||
<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" id="payment_submit"
|
||||
src="/payment_acquirer_ogone/static/src/img/ogone_logo_plain.gif"/>
|
||||
<!-- submit -->
|
||||
<button type="image" name="submit" width="100px"
|
||||
t-att-class="submit_class">
|
||||
<img t-if="not submit_txt" src="/payment_acquirer_ogone/static/src/img/ogone_icon.png"/>
|
||||
<span t-if="submit_txt"><t t-esc="submit_txt"/></span>
|
||||
</button>
|
||||
</form>
|
||||
</template>
|
||||
|
||||
|
||||
@@ -7,9 +7,8 @@
|
||||
<field name="model">payment.acquirer</field>
|
||||
<field name="inherit_id" ref="payment_acquirer.acquirer_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr='//group[@name="acquirer_base"]' position='after'>
|
||||
<group string="Ogone Details"
|
||||
attrs="{'invisible': [('name', '!=', 'ogone')]}">
|
||||
<xpath expr='//group[@name="acquirer_display"]' position='after'>
|
||||
<group attrs="{'invisible': [('name', '!=', 'ogone')]}">
|
||||
<field name="ogone_pspid"/>
|
||||
<field name="ogone_userid"/>
|
||||
<field name="ogone_password"/>
|
||||
@@ -29,8 +28,10 @@
|
||||
<page string="Ogone TX Details">
|
||||
<group>
|
||||
<field name="ogone_payid"/>
|
||||
<!-- <field name="ogone_3ds"/>
|
||||
<field name="ogone_3ds_html"/> -->
|
||||
<field name="ogone_3ds"/>
|
||||
<field name="ogone_3ds_html"/>
|
||||
<field name="ogone_complus"/>
|
||||
<field name="ogone_payid"/>
|
||||
</group>
|
||||
</page>
|
||||
</xpath>
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
<field name="name">paypal</field>
|
||||
<field name="view_template_id" ref="paypal_acquirer_button"/>
|
||||
<field name="env">test</field>
|
||||
<field name="message"><![CDATA[
|
||||
<p>You will be redirected to the Paypal website after cliking on the payment button.</p>]]></field>
|
||||
<field name="paypal_tx_url">https://www.sandbox.paypal.com/cgi-bin/webscr</field>
|
||||
<field name="paypal_email_id">dummy</field>
|
||||
<field name="paypal_username">dummy</field>
|
||||
|
||||
@@ -21,10 +21,22 @@ _logger = logging.getLogger(__name__)
|
||||
class AcquirerPaypal(osv.Model):
|
||||
_inherit = 'payment.acquirer'
|
||||
|
||||
def _get_paypal_urls(self, cr, uid, env, context=None):
|
||||
""" Paypal URLS """
|
||||
if env == 'prod':
|
||||
return {
|
||||
'paypal_form_url': 'https://www.sandbox.paypal.com/cgi-bin/webscr',
|
||||
'paypal_rest_url': 'https://api.sandbox.paypal.com/v1/oauth2/token',
|
||||
}
|
||||
else:
|
||||
return {
|
||||
'paypal_form_url': 'https://www.sandbox.paypal.com/cgi-bin/webscr',
|
||||
'paypal_rest_url': 'https://api.sandbox.paypal.com/v1/oauth2/token',
|
||||
}
|
||||
|
||||
_columns = {
|
||||
'paypal_email_id': fields.char('Email ID', required_if_provider='paypal'),
|
||||
'paypal_username': fields.char('Username', required_if_provider='paypal'),
|
||||
'paypal_tx_url': fields.char('Transaction URL', required_if_provider='paypal'),
|
||||
'paypal_use_ipn': fields.boolean('Use IPN'),
|
||||
# Server 2 server
|
||||
'paypal_api_enabled': fields.boolean('Use Rest API'),
|
||||
@@ -35,7 +47,6 @@ class AcquirerPaypal(osv.Model):
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
'paypal_tx_url': 'https://www.sandbox.paypal.com/cgi-bin/webscr',
|
||||
'paypal_use_ipn': True,
|
||||
'fees_active': False,
|
||||
'fees_dom_fixed': 0.35,
|
||||
@@ -95,7 +106,7 @@ class AcquirerPaypal(osv.Model):
|
||||
|
||||
def paypal_get_form_action_url(self, cr, uid, id, context=None):
|
||||
acquirer = self.browse(cr, uid, id, context=context)
|
||||
return acquirer.paypal_tx_url
|
||||
return self._get_paypal_urls(cr, uid, acquirer.env, context=context)['paypal_form_url']
|
||||
|
||||
def _paypal_s2s_get_access_token(self, cr, uid, ids, context=None):
|
||||
"""
|
||||
|
||||
|
After Width: | Height: | Size: 7.1 KiB |
@@ -10,14 +10,16 @@
|
||||
<xpath expr='//group[@name="acquirer_display"]' position='after'>
|
||||
<group attrs="{'invisible': [('name', '!=', 'paypal')]}">
|
||||
<group>
|
||||
<field name="paypal_email_id"/>
|
||||
<field name="paypal_username"/>
|
||||
<field name="paypal_use_ipn"/>
|
||||
<field name="paypal_api_enabled"/>
|
||||
<field name="paypal_api_username"
|
||||
attrs="{'invisible': [('paypal_api_enabled', '=', False)]}"/>
|
||||
<field name="paypal_api_password"
|
||||
attrs="{'invisible': [('paypal_api_enabled', '=', False)]}"/>
|
||||
<group>
|
||||
<field name="paypal_email_id"/>
|
||||
<field name="paypal_username"/>
|
||||
<field name="paypal_use_ipn"/>
|
||||
<field name="paypal_api_enabled"/>
|
||||
<field name="paypal_api_username"
|
||||
attrs="{'invisible': [('paypal_api_enabled', '=', False)]}"/>
|
||||
<field name="paypal_api_password"
|
||||
attrs="{'invisible': [('paypal_api_enabled', '=', False)]}"/>
|
||||
</group>
|
||||
</group>
|
||||
</group>
|
||||
</xpath>
|
||||
|
||||
@@ -3,16 +3,14 @@
|
||||
<data noupdate="0">
|
||||
|
||||
<template id="paypal_acquirer_button">
|
||||
<form t-if="acquirer.paypal_email_id" t-att-action="acquirer.paypal_tx_url" method="post" target="_self">
|
||||
<form t-if="acquirer.paypal_email_id" t-att-action="tx_url" method="post" target="_self">
|
||||
<input type="hidden" name="cmd" t-att-value="tx_values['cmd']"/>
|
||||
<input type="hidden" name="business" t-att-value="tx_values['business']"/>
|
||||
<input type="hidden" name="item_name" t-att-value="tx_values['item_name']"/>
|
||||
<input type="hidden" name="item_number" t-att-value="tx_values['item_number']"/>
|
||||
<input type="hidden" name="amount" t-att-value="tx_values['amount']"/>
|
||||
<t t-if="'handling' in tx_values">
|
||||
<input type="hidden" name="handling" t-att-value="tx_values['handling']"/>
|
||||
</t>
|
||||
<input type="hidden" name="amount" t-att-value="tx_values['amount']"/>
|
||||
<input t-if="'handling' in tx_values" type="hidden" name="handling"
|
||||
t-att-value="tx_values.get('handling')"/>
|
||||
<input type="hidden" name="currency_code" t-att-value="tx_values['currency_code']"/>
|
||||
<!-- partner / address data -->
|
||||
<input type="hidden" name="address1" t-att-value="tx_values['address1']"/>
|
||||
@@ -23,20 +21,21 @@
|
||||
<input type="hidden" name="last_name" t-att-value="tx_values['last_name']"/>
|
||||
<input type="hidden" name="zip" t-att-value="tx_values['zip']"/>
|
||||
<!-- after payment parameters -->
|
||||
<t t-if='tx_values.get("custom")'>
|
||||
<input type='hidden' name="custom" t-att-value='tx_values["custom"]'/>
|
||||
</t>
|
||||
<input t-if='tx_values.get("custom")' type='hidden' name="custom"
|
||||
t-att-value='tx_values.get("custom")'/>
|
||||
<!-- URLs -->
|
||||
<input t-if="tx_values.get('return')" type='hidden' name='return'
|
||||
t-att-value="tx_values['return']"/>
|
||||
t-att-value="tx_values.get('return')"/>
|
||||
<input t-if="acquirer.paypal_use_ipn" type='hidden' name='notify_url'
|
||||
t-att-value="tx_values['notify_url']"/>
|
||||
t-att-value="tx_values.get('notify_url')"/>
|
||||
<input t-if="tx_values.get('cancel_return')" type="hidden" name="cancel_return"
|
||||
t-att-value="tx_values['cancel_return']"/>
|
||||
<!-- button -->
|
||||
<input type="image" name="submit" id="payment_submit"
|
||||
width="100px"
|
||||
src="/payment_acquirer_paypal/static/src/img/paypal_logo.png"/>
|
||||
t-att-value="tx_values.get('cancel_return')"/>
|
||||
<!-- submit -->
|
||||
<button type="image" name="submit" width="100px"
|
||||
t-att-class="submit_class">
|
||||
<img t-if="not submit_txt" src="/payment_acquirer_paypal/static/src/img/paypal_icon.png"/>
|
||||
<span t-if="submit_txt"><t t-esc="submit_txt"/></span>
|
||||
</button>
|
||||
</form>
|
||||
</template>
|
||||
|
||||
|
||||
|
After Width: | Height: | Size: 14 KiB |
@@ -3,16 +3,19 @@
|
||||
<data noupdate="0">
|
||||
|
||||
<template id="transfer_acquirer_button">
|
||||
<div t-field="acquirer.message"/>
|
||||
<form t-if="acquirer" action="/payment/transfer/feedback" method="post" target="_self">
|
||||
<form t-if="acquirer" t-att-action="tx_url" method="post" target="_self">
|
||||
<t t-if="tx_values.get('return_url')">
|
||||
<input type='hidden' name='return_url' t-att-value='tx_values["return_url"]'/>
|
||||
</t>
|
||||
<input type='hidden' name='reference' t-att-value='reference'/>
|
||||
<input type='hidden' name='amount' t-att-value='amount'/>
|
||||
<input type='hidden' name='currency' t-att-value='currency.name'/>
|
||||
<input type="submit" name="submit" id="payment_submit"
|
||||
class="btn btn-primary" value="Confirmer"/>
|
||||
<!-- submit -->
|
||||
<button type="image" name="submit" width="100px"
|
||||
t-att-class="submit_class">
|
||||
<img t-if="not submit_txt" src="/payment_acquirer_transfer/static/src/img/transfer_icon.png"/>
|
||||
<span t-if="submit_txt"><t t-esc="submit_txt"/></span>
|
||||
</button>
|
||||
</form>
|
||||
</template>
|
||||
|
||||
|
||||