How can I point to my account via username instead of email by using forms?

mhorniq
Contributor
Contributor

What I am trying to achieve is to create a button on the website, style it and redirect to PayPal with predefined amount. 
I found a (legacy?) way of doing this by pointing to the account with email, (see the 3. line in code). 

 

My question is, is there a way to work with just @username instead of email? 

If yes, what input name should be used in that case instead of "business"?

Appreciate your advices.

 

 

 

 

<form action="https://www.paypal.com/donate" method="post" target="_top">
    <!-- Identify your business so that you can collect the payments. -->
    <input type="hidden" name="business" value="HERE-GOES-THE-EMAIL">
    <!-- Specify details about the contribution -->
    <input type="hidden" name="amount" value="10.00">
    <input type="hidden" name="no_recurring" value="0">
    <input type="hidden" name="item_name" value="example">
    <input type="hidden" name="item_number" value="example">
    <input type="hidden" name="currency_code" value="USD">
    <!-- Display the payment button. -->
    <input type="submit" name="submit" class="button" value="€10.00">
   </form>

 

 

 

 

Login to Me Too
1 ACCEPTED SOLUTION

Accepted Solutions
Solved

Nexus_Software
Contributor
Contributor

Hello, 

 

One way to create a button with a predefined amount without using your email is to use the hosted button hidden input 

E.g., 

 

 

<input type="hidden" name="hosted_button_id" value="xxxxxxxxxx">

 

 

The complete HTML for the hosted button is generated for you when you create a PayPal Payments Standard payment button.

 

Are you trying to create buttons with dynamic amounts?

 

Thank you.

View solution in original post

Login to Me Too
6 REPLIES 6
Solved

Nexus_Software
Contributor
Contributor

Hello, 

 

One way to create a button with a predefined amount without using your email is to use the hosted button hidden input 

E.g., 

 

 

<input type="hidden" name="hosted_button_id" value="xxxxxxxxxx">

 

 

The complete HTML for the hosted button is generated for you when you create a PayPal Payments Standard payment button.

 

Are you trying to create buttons with dynamic amounts?

 

Thank you.

Login to Me Too

mhorniq
Contributor
Contributor
thank you for the answer! I want to create several buttons with predefined amounts and an empty field for custom amount. Your solution works also. I guess we can’t point to the username directly, for some reason.
Login to Me Too

Nexus_Software
Contributor
Contributor

Hi @mhorniq,

 

You're welcome. Using the newer JavaScript generated PayPal buttons provides flexibility in terms of using custom amounts and other dynamic variables. 

paypal_js_sdk.png

Login to Me Too

mhorniq
Contributor
Contributor

hey @Nexus_Software 

Thanks for the snippet.

As far as I can tell, your example is not for donation but for accepting and paying order. Am I right? 
I found more references here, but those all are more suitable for paying for goods.

Login to Me Too

Nexus_Software
Contributor
Contributor

Hi @mhorniq ,

 

Using the donation SDK is different. You would first log in to paypal.com/donate/buttons with the account you want to use to make a Donate button. Then create the predefined button. After you create a button, you get code. From the code, copy:

  • hosted_button_id value if you have a business account
  • business value if you have a personal account.

An example for implementing the button on your page would be:

 

<script src="https://www.paypalobjects.com/donate/sdk/donate-sdk.js" charset="UTF-8"></script>

  <script>
   PayPal.Donation.Button({
       env: 'production',
        hosted_button_id: 'S2KMEP2EAURGY',
      // business: 'PAYPAL_BUSINESS_EMAIL',
       image: {
           src: 'https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif',
           title: 'PayPal - The safer, easier way to pay online!',
           alt: 'Donate with PayPal button'
       },

       onComplete: function (params) {

           // Your onComplete handler

       },

   }).render('#paypal-donate-button-container');

</script>

 

 

 

Thank you.

 

Powered by Custom Software : NexWebSites.com
PayPal Developers

Login to Me Too

mhorniq
Contributor
Contributor

hey @Nexus_Software 

 

got it, so these are the two possibilities we have - business (aka Email) pointer and the button-id pointer.

 

thank you for all the answers and snippets!

Login to Me Too

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.