Avatar of Lev Seltzer
Lev Seltzer
Flag for Israel asked on

How do I add a PayPal button to a WordPress site using the block editor?

This seems like a ridiculous questions, but the obvious method is not working for me.My button code is as follows:
<form style="text-align: center;" action="https://www.paypal.com/cgi-bin/webscr" method="post"><input type="hidden" name="cmd" value="_s-xclick" />
<div class="wp-block-column"><!-- wp:html -->
<input type="hidden" name="hosted_button_id" value="S37XKJTFBJXT6" />    
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif" border="0" name="submit" title="PayPal - The safer, easier way to pay online!" alt="Donate with PayPal button" />    
<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1" />    

Open in new window

The page was a classic WordPress page, and I recently converted it to a block. I added a custom code block, pasted the PayPal code, previewed the page (it worked), saved the page, and then got the message

This block contains unexpected or invalid content.

What am I doing wrong? Or is there an easier way to have a simple PayPal donation button using the block editor?

Thank you.

Avatar of undefined
Last Comment
Lev Seltzer

8/22/2022 - Mon
David Favor

Provide the URL of the actual page, so entire page can be analyzed.

Likely something in surrounding HTML requires some refinement, as code you provided (what little there is) appears correct.
Lev Seltzer

Page is http://belevechad.org/
Paypal link is at the bottom of the page.
Thank you.

Scott Fell

 I added a custom code block,

I did the exact same thing not too long ago thinking code block was HTML and what it really means is displaying code.  You need to add custom html.

1) Add your block
2) Use Custom HTML. Go to Browse All then find Custom HTML

You can also just search for Custom HTML
3) Now you can paste in your HTMLfrom Paypal
4) Previewing shows it works
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
Scott Fell

I just looked at your link and your Paypal link is working as it should. 
Lev Seltzer

After saving the page successfully, I return to the page and see the error message below. The block is missing the PayPal button code.

If you know how to avoid this error, then please help..
Or perhaps somewhere there is a PayPal block that securely stores the unique identifier for the button?

Thank you.
Scott Fell

View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Lev Seltzer

Thank you both for your help!
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.