12

What I'm trying to do is displaying a PayPal donation button into a Github project README.md file. The markup I added is displayed as HTML rather than being properly rendered as donation button.

HTML // PayPal source here

Do you have any thought?

apaderno
  • 28,547
  • 16
  • 75
  • 90
user2475624
  • 451
  • 2
  • 6
  • 27

5 Answers5

22

The current code generated by paypal buttons is based on a FORM html tag with a POST method. Fortunately the values are always the same and paypal is supporting them to be passed by the GET method. So, you can safely read the form code and convert it to a direct link.

On my case I just made a link to my button like this:

[![](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=X6XHVCPMRQEL4)

I am using it on my project at http://github.com/ctodobom/OpenNoteScanner

allgood
  • 529
  • 5
  • 11
  • 1
    How do you read the form code and "convert" it into a direct link? – Just a coder Jul 21 '16 at 19:19
  • 2
    @JTAppleCalendarforiOSSwift, I used the navigator's inspection tool to get information about the form and formed the URL on my answer. Probably all you need to change on my code is the "hosted_button_id" value. – allgood Jul 25 '16 at 19:08
  • The image and the "Shareable Link" from manage page are enough. – Sam May 11 '22 at 03:31
3

In all likelihood, it is not possible for security reasons (see CSFR and XSS for examples of potentially related security concerns). In other words, GitHub has intentionally not allowed forms within Markdown text and will strip them out if they are included.

For more general information about how to include a form in Markdown (outside of GitHub) see my previous answer below:


As the Markdown syntax rules state:

For any markup that is not covered by Markdown’s syntax, you simply use HTML itself. There’s no need to preface it or delimit it to indicate that you’re switching from Markdown to HTML; you just use the tags.

The only restrictions are that block-level HTML elements — e.g. <div>, <table>, <pre>, <p>, etc. — must be separated from surrounding content by blank lines, and the start and end tags of the block should not be indented with tabs or spaces.

So just insert your raw HTML into the document. You probably should wrap the entire block in a <div> to make sure Markdown treats it properly as one block.

However, be aware that it is possible that GitHub may filter the content to not allow certain tags for security reasons, so you'll need to test it to find out if it will work.

Additionally, depending on how things are configured, the browser and/or the server you are posting to may not allow the form to post for security reasons.

For more on those issues see these questions and related answers.

Waylan
  • 37,164
  • 12
  • 83
  • 109
  • It doesnt out the form at all. – user2475624 Jun 19 '15 at 14:05
  • Well, then GitHub is stripping out those tags, which means it is not possible. Given the potential security implications, I'm not surprised. I've edited my answer to reflect that. – Waylan Jun 19 '15 at 20:01
3

With Paypal.me , there is no more a security concern :

markdown

[![paypal](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.me/AbdennourT/10)

markup

<p>
  <a href="https://www.paypal.me/AbdennourT/10">
      <img src="https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif" alt="paypal">
  </a>
</p>
Abdennour TOUMI
  • 87,526
  • 38
  • 249
  • 254
1

You have to create an enterprise account or you can update your own, it´s free.

Then you have to create the button in the button center and generate a donate button, this tool generates the html and you can get the hoted_button_id then you have to replace it and paste it in the README.md

[![](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YOUR_OWN)
Jorge Mejia
  • 1,153
  • 1
  • 10
  • 27
0

If you want to just use your email and a donate button you can do it by just filling in the blanks from their "donate email" example:

[![paypal](https://www.paypalobjects.com/en_US/i/btn/btn_buynowCC_LG.gif)](https://www.paypal.com/donate/?business=paypal@poleguy.com&no_recurring=0&item_name=Payment+for+Stackoverflow+Example&item_number=Suggested+Price:+$7.99+USD&currency_code=USD)

It renders like this:

paypal

Paypal warns that it's "not secure" and you should always use a "hosted email payment link to prevent malicious users from tampering with the code." So maybe okay on github, but not on a wiki or stackoverflow where the link could be edited to pay someone else.

poleguy
  • 523
  • 7
  • 11