Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Customize payment button #196

Open
anuj9196 opened this issue Jan 2, 2018 · 3 comments
Open

Customize payment button #196

anuj9196 opened this issue Jan 2, 2018 · 3 comments

Comments

@anuj9196
Copy link

anuj9196 commented Jan 2, 2018

I want to customize the pay now button to meed the theme of my template with icons and class like

<button class="btn btn-payment">
    <i class="fa fa-paypal">
       Get Started
    </i>
</button>

In the documentation, I can only see how to change the image. Is there a way to customize it like described above.

@spookylukey
Copy link
Owner

There isn't a documented way at the moment to do that.

However, you can do it fairly simply by subclassing the payment form, and implementing the render method according to your requirements. See https://github.com/spookylukey/django-paypal/blob/master/paypal/standard/forms.py#L163 - your version would need to replace the <input type="image"> with your code.

@vassilisw
Copy link

I assume spookylukey means something like this:

class MyPayPalPaymentsForm(PayPalPaymentsForm):
    def render(self):
        form_open  = u'''<form action="%s" method="post">''' % (self.get_endpoint())
        form_close = u'</form>'
        # format html as you need
        submit_elm = u'''<input type="submit" class="btn btn-success my-custom-class">'''
        return format_html(form_open+self.as_p()+submit_elm+form_close)

@hvitis
Copy link

hvitis commented Nov 9, 2019

I assume spookylukey means something like this:

class MyPayPalPaymentsForm(PayPalPaymentsForm):
    def render(self):
        form_open  = u'''<form action="%s" method="post">''' % (self.get_endpoint())
        form_close = u'</form>'
        # format html as you need
        submit_elm = u'''<input type="submit" class="btn btn-success my-custom-class">'''
        return format_html(form_open+self.as_p()+submit_elm+form_close)

@vassilisw This is highly useful when customizing the payment template that PayPal opens. Thank you!

fabiocaccamo added a commit to fabiocaccamo/django-paypal that referenced this issue Jul 6, 2022
fabiocaccamo added a commit to fabiocaccamo/django-paypal that referenced this issue Jul 17, 2022
spookylukey added a commit that referenced this issue Jul 21, 2022
Simplified payment button customisation. #196
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants