Eligibility
The easiest way to find out if you’re eligible to integrate the Donate SDK is to use paypal.com.- Log into paypal.com/donate/buttons/ with the account you want to use to make a Donate button.
- If you can start a flow to make a Donate button, you’re eligible to integrate the Donate SDK.
1. Create a Donate button
To use the Donate SDK, create a Donate button in the sandbox.- Log in to sandbox.paypal.com/donate/buttons/, and make your Donate button. After you create a button, you get code.
- From the code, copy:
- The
hosted_button_id
value if you have a business account - The
business
value if you have a personal account
- The
- You’ll need this parameter to pass to the SDK.
item_name
or item_number
.
2. Add the Donate SDK to your web page
Add the Donate JavaScript SDK to your web page to integrate the Donate button into your site.3. Render the Donate button
Render the Donate button to a container element on your web page. If you have a business account, provide thehosted_button_id
parameter value. For any other account type, provide the business
parameter value.
<div id="paypal-donate-button-container-2">
. Then render the button in the new container: }).render('#paypal-donate-button-container-2')
.
4. Test the Donate button
- On the site, click the Donate button.
- Confirm that the button opens a pop-up window and displays your donation page.
- Complete a donation using a sandbox credit card or sandbox PayPal account.
- Verify that the
onComplete
function returns an object parameter.
Variable | Description |
---|---|
tx | Transaction ID |
st | Status of the transaction |
amt | Amount of the transaction |
cc | Currency code |
cm | Custom message |
item_number | Configurable field for the transaction |
item_name | Value that the donor selects during the transaction |
5. Go live
To go live with your new Donate button, replace the sandbox data with live data.- Replace the
hosted_button_id
value for the sandbox with a livehosted_button_id
for a business account. For any other type of account, replace the sandboxbusiness
value with a livebusiness
value. - Remove the
env
value, or changeenv
toproduction
.