Help

8

How to Change Custom icons for Payment Acquirers?

Avatar
Ayaz Mansuri

Hello...!!!

Currently I'm Working on Payment Integration Module., But Unable to set custom icon/image for payment methods.

if we create custom payment module, payment_demo, it will be set like...

<img t-if="not submit_txt" src="/payment_demo/static/src/img/demo_icon.png"/>

 But, How can i set custom icon without creating custom payment module..!!!

Thanks,

Ayaz Mansuri

Avatar
Discard
4 Answers
3
Avatar
Ayaz Mansuri
Best Answer

Thank You Guys For your Contribution..but finally i've solved this without creating custom payment module, no need to place image in existing payment module, no need write methods., Just Put one field in payment acquirer model..like...

In Your Py File:

class acquirer(osv.Model):

    _inherit = 'payment.acquirer'

   _columns = { 

    'payment_icon': fields.char(string='Icon location', help='Custom icon to use for this acquirer.'),

}

In Your XML File:

<record id="acquirer_form_payment" model="ir.ui.view">

    <field name="name">acquirer.form.payerse</field>

    <field name="model">payment.acquirer</field>

    <field name="inherit_id" ref="payment.acquirer_form"/>

    <field name="arch" type="xml">

        <xpath expr='//group[@name="acquirer_display"]' position='after'>

    <group>

            <field name="payment_icon"/>

    </group>

        </xpath>

    </field>

</record> 

And...........

  <template id="payment_inherit" inherit_id="website_sale.payment">

    <!-- Enable custom icons in Payment Acquirers -->

    <xpath expr="//div[@id='payment_method']//img" position="attributes">

        <attribute name="t-att-src">acquirer.payment_icon or '/payment_%s/static/src/img/%s_icon.png' % (acquirer.provider, acquirer.provider)</attribute>

    </xpath>

</template>

Now Go to Settings > Payment Acquirers > Select any of payment Method > Go to payment_icon Field & Write icon image path like this. /your_module_name/static/src/img/lastschrift_icon.png

This is how you can change payment icons without creating custom payment module...!!!

Thanks...!!!


Avatar
Discard
8
Best Answer

Hi Mansuri,


The image icon should be saved in this format 'acquirername_icon.png'

The payment methods in odoo e-commerce is listed by using this methode in the corresponding template

        <li t-foreach="acquirers or []" t-as="acquirer">

            <label t-if="acquirer.button">

                <input t-att-value="acquirer.id" type="radio" name="acquirer" t-att-checked="acquirers[0] == acquirer"/>

                <img class="media-object" style="width: 60px; display: inline-block;"

                    t-att-title="acquirer.name"

                    t-att-src="'/payment_%s/static/src/img/%s_icon.png' % (acquirer.provider, acquirer.provider)"/>

                <span t-field="acquirer.name"/>

            </label>

        </li>

I hope it will help.

3 Comments
Avatar
Discard
Avatar
Lince
-

Where is the file, script, to write this code ?

Avatar
fasluca
-

You don't need to include this code...its already there. just give name for that icon as mentioned in answer

Avatar
nikesh
-

Hi Lince, At the time of installation of module 'payment_demo ' some datas are to be set in payment.acquirer as Demo demo test here you may need to create tempate demo_acquirer_button. Note: Look here the provider is 'demo'. You also have to inherit payment.acquirer and follow the code: class PaymentAcquirer(models.Model): _inherit = 'payment.acquirer' def _get_providers(self, cr, uid, context=None): providers = super(PaymentAcquirer, self)._get_providers(cr, uid, context=context) providers.append(['demo', 'demo']) return providers

1
Avatar
nikesh
Best Answer

Hi Lince,
At the time of installation of module 'payment_demo ' some datas are to be set in payment.acquirer as

 

<openerp>
    <data noupdate="1">
        <record id="payment_acquirer_sagepay" model="payment.acquirer">
            <field name="name">Demo</field>
            <field name="provider">demo</field>
            <field name="company_id" ref="base.main_company"/>
            <field name="view_template_id" ref="demo_acquirer_button"/>
            <field name="environment">test</field>
        </record>
    </data>
</openerp>


Here you may need to create tempate demo_acquirer_button.

 Note: Look here the provider is 'demo'. You also have to inherit payment.acquirer and follow the code:

class PaymentAcquirer(models.Model): 
    _inherit = 'payment.acquirer'
    def _get_providers(self, cr, uid, context=None):
        providers = super(PaymentAcquirer, self)._get_providers(cr, uid, context=context)
        providers.append(['demo', 'demo'])
        return providers


Avatar
Discard
0
Avatar
Prakash
Best Answer

just place a icon as the name of acquire name in static/src/img.

For example if you want to change the image of payment_transfer;

place a  .png image  inside payment_transfer/static/src/img/ having name transfer_icon


For example if you want to change the image of payment_paypal;

place a  .png image  inside payment_paypal/static/src/img/ having name paypal_icon

 



Avatar
Discard