Free Donation Plugin for WordPress
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
assets Fix tax receipt checkbox bug Aug 29, 2018
bin Refactored config inheritance from the ground up and added unit tests Sep 20, 2017
bitpay Renamed eas to raise Oct 5, 2017
doc/images Complete Coinbase integration using popup Aug 28, 2018
lang Complete Coinbase integration using popup Aug 28, 2018
tests Refactor error messages and update unit tests Jun 20, 2018
vendor Update Stripe and GoCardless SDKs Aug 27, 2018
.gitignore Added BitPay support Jan 29, 2017
.travis.yml Refactored config inheritance from the ground up and added unit tests Sep 20, 2017
LICENSE Updated README and LICENSE Oct 6, 2017
README.md Complete Coinbase integration using popup Aug 28, 2018
_globals.php Complete Coinbase integration using popup Aug 28, 2018
_options.php Add JsonLogic functions and small fixes Apr 26, 2018
_parameters.js.php.dist Changed language structure for finish > email Oct 11, 2017
changelog.txt Fix tax receipt checkbox bug Aug 29, 2018
composer.json Update Stripe and GoCardless SDKs Aug 27, 2018
composer.lock Update Stripe and GoCardless SDKs Aug 27, 2018
form.php Complete Coinbase integration using popup Aug 28, 2018
functions.php Replace coinbase logo by currency logos Aug 28, 2018
index.php First commit Mar 15, 2015
phpcs.xml.dist Refactored config inheritance from the ground up and added unit tests Sep 20, 2017
phpunit.xml.dist Refactored config inheritance from the ground up and added unit tests Sep 20, 2017
raise.php Bump version to 1.6.0 Aug 30, 2018
updates.php Mixed up locale bug when sending asynchronous POST calls on multi-dom… Oct 12, 2017

README.md

Raise

Free donation plugin for Wordpress. Supports one-time and monthly payments, confirmation and notification-emails, webhooks, a newsletter checkbox, a tax deductibility checkbox, multiple purposes, custom colors, Javascript events, single form inheritance, sandbox mode, centralized settings and translations.

Accept donations via Stripe, PayPal, GoCardless, BitPay, Coinbase, Skrill or bank transfers.

Screenshot of Raise - The Free Donation Plugin for WordPress

Prerequisites

  • PHP ≥5.6.3
  • WordPress ≥4.8

Installation

For a manual installation, download this repository and follow the instructions for a manual install.

To receive updates, install Github Updater.

To embed the form in a page, use the shortcode [raise_form form="<form_name>" live="<true or false>"].

If the live parameter is set to false, the plugin will use the sandbox settings for each payment provider.

Configuration

Configuration is done in JSON. The plugin comes with a visual JSON editor.

Initially, the default settings are loaded from _parameters.js.php.dist. Once a modified version is saved, the plugin fetches settings from the database.

Full example

{
  "organization": {
    "en": "Effective Altruism Foundation",
    "de": "Stiftung für Effektiven Altruismus"
  },
  "forms": {
    "my_form": {
      "inherits": "parent_form",
      "amount": {
        "button": [
          10,
          30
        ],
        "button_monthly": [
          5,
          10
        ],
        "custom": true,
        "columns": 3,  # use 1,2,3,4,6,12 for optiomal display
        "currency": {
          "eur": {
            "pattern": "%amount% €",
            "country_flag": "eu",
            "minimum": 4.5
          },
          "usd": {
            "pattern": "$%amount%",
            "country_flag": "us",
            "minimum": 5,
            "minimum_monthly": 3,
            "below_minimum_message": "Please donate more than %minimum_amount%."
          }
        }
      },
      "payment": {
        "purpose": {
            "my_org": "My organisation"  # If first element has an empty key, no purpose is selected by default
        },
        "provider": {
          "stripe": {
            "account": "DE",
            "live": {
              "secret_key": "sk_live_mykey",
              "public_key": "pk_live_mykey"
            },
            "sandbox": {
              "secret_key": "sk_test_mykey",
              "public_key": "pk_test_mykey"
            }
          },
          "banktransfer": [
            {
              "value": {
                "account": "UK",
                "details": {
                  "Beneficiary": "My Organization UK",
                  "Account number": 1234567,
                  "Sort code": "12-34-56",
                  "IBAN": "GB50 1234 1234 1234 1234 A",
                  "BIC/SWIFT": "LOYDGB2L",
                  "Bank": "Lloyds Bank Plc",
                  "Purpose": "%reference_number%"
                },
                "tooltip": {
                  "en": "No fees",
                  "de": "Gebührenfrei"
                }
              },
              "if": {
                "and": [
                  {
                    "===": [
                      {
                        "var": "country_code"
                      },
                      "GB"
                    ]
                  },
                  {
                    "!!": [
                      {
                        "var": "tax_receipt"
                      }
                    ]
                  }
                ]
              }
            },
            {
              "value": {
                "account": "US",
                "details": {
                  "Beneficiary": "My Organization USA",
                  "Account number": 123456789,
                  "Routing number": 123456789,
                  "Bank": "JPMorgan Chase Bank, 188 Spear St, Ste 190, San Francisco, CA 94105, United States",
                  "Purpose": "%reference_number%"
                },
                "tooltip": {
                  "en": "No fees",
                  "de": "Gebührenfrei"
                }
              },
              "if": {
                "===": [
                  {
                    "var": "country_code"
                  },
                  "US"
                ]
              }
            },
            {
              "value": {
                "account": "DE",
                "details": {
                  "Beneficiary": "My Organization Germany",
                  "IBAN CHF": "DE67 1234 1234 1234 1234 N",
                  "IBAN EUR": "DE20 1234 1234 1234 1234 D",
                  "IBAN USD": "DE79 1234 1234 1234 1234 F",
                  "IBAN GBP": "DE08 1234 1234 1234 1234 T",
                  "BIC/SWIFT": "DEUTINBBPBC",
                  "Bank": "Deutsche Bank",
                  "Purpose": "%reference_number%"
                },
                "tooltip": {
                  "en": "Banks may charge a fee for international transactions.",
                  "de": "Banken können Gebühren auf internationale Überweisungen erheben."
                }
              },
              "if": true
            }
          ]
        },
        "reference_number_prefix": {
          "my_org": "ORG",
          "default": "XRG"
        },
        "fundraiser": 145,
        "extra_fields": {
          "country": false,  # move country dropdown up to required fields
          "anonymous": false,  # add anonynmous checkbox
          "comment": false # add comment textarea
        },
        "country": {
          "initial": "geoip",  # Initial value for country dropdown, e.g. "US"
          "fallback": "US"  # Fallback value if GeoIP is not available
        },
        "recaptcha": {
          "site_key": "my_recaptcha_site_key",
          "secret_key": "my_secret_key"
        },
        "form_elements": {
          "purpose": {
            "en": "Charity",
            "de": "Organisation"
          },
          "tip": [
            {
              "value": {
                "label": {
                  "en": "Add 5% tip",
                  "de": "5% Trinkgeld hinzufügen"
                },
                "tip_percentage": 5,
                "checked": true
              },
              "if": {
                "in": [
                  {
                    "var": "purpose"
                  },
                  [
                    "purpose_1",
                    "purpose_2"
                  ]
                ]
              }
            }
          ],
          "tax_receipt": [
            {
              "info": "DE: tax-deductible", // Label
              "value": {
                "label": {
                  "en": "I need a tax receipt for Germany.",
                  "de": "Ich benötige eine Steuerbescheinigung für Deutschland."
                }
              },
              "if": {
                "===": [
                  {
                    "var": "country_code"
                  },
                  "DE"
                ]
              }
            },
            {
              "info": "not supported",
              "value": {
                "label": {
                  "en": "We currently don't offer tax receipts for %country%.",
                  "de": "Wir können zurzeit leider keine Steuerbescheinigungen für %country% ausstellen."
                },
                "disabled": true
              },
              "if": true
            }
          ],
          "share_data": [
            {
              "value": {
                "label": null,
                "disabled": false
              },
              "if": {
                "in": [
                  {
                    "var": "purpose"
                  },
                  [
                    "purpose_1",
                    "purpose_2",
                    "purpose_3"
                  ]
                ]
              }
            },
            {
              "value": {
                "label": {
                  "en": "Share my data with %purpose_label%",
                  "de": "Meine Daten mit %purpose_label% teilen"
                },
                "disabled": false
              },
              "if": true
            }
          ],
        }
      },
      "finish": {
        "success_message": {
          "en": "Thank you very much for your donation!",
          "de": "Vielen Dank für Ihre Spende!"
        },
        "post_donation_instructions": [
          {
            "info": "banktransfer",
            "value": {
              "en": "You can now make your transfer using the bank details below.\n\n%bank_account_formatted%\n\nIf you would like to make several donations right now, you can transfer the total sum in one payment and include the individual purpose numbers in the bank transfer annotation field.",
              "de": "Sie können nun Ihre Überweisung anhand der Bankverbindung unten tätigen.\n\n%bank_account_formatted%\n\nFür die Überweisung mehrerer Spenden können Sie eine Sammelüberweisung über die Gesamtsumme aufsetzen und alle Referenznummern im Verwendungszweck vermerken."
            },
            "if": {
              "===": [
                {
                  "var": "payment_provider"
                },
                "Bank Transfer"
              ]
            }
          },
          {
            "info": "show nothing",
            "value": "",
            "if": true
          }
        ],
        "email": {
          "sender": {
            "en": "My Organization",
            "de": "Meine Organisation"
          },
          "address": "anne.wissemann@ea-foundation.org",
          "subject": {
            "en": "Thank you for your donation",
            "de": "Vielen Dank für Ihre Spende"
          },
          "text": {
            "en": "Dear {{ name }} ...",
            "de": "Liebe/r {{ name }} ..."
          },
          "html": true
        },
        "notification_email": {
          "notify-me@example.org": {
            "country": "United States"
          }
        }
      },
      "log": {
        "max": 50
      },
      "webhook": {
        "logging": {
          "sandbox": [
            "https://example.org/my-sandbox-logging-webhook/"
          ],
          "live": [
            "https://example.org/my-logging-webhook/"
          ]
        },
        "mailing_list": {
          "sandbox": [
            "https://example.org/my-sandbox-mailinglist-webhook/"
          ],
          "live": [
            "https://example.org/my-mailinglist-webhook/"
          ]
        }
      }
    }
  }
}

Inheritance

Each form can specify a parent form from which to inherit settings. To unset options inherited, set the value to null.

Example: forms > my_form > inherits: "default"

⚠️ The values in arrays (such as forms > my_form > amount > button) are prepended to their parent counterpart.

Dedicated plugin

If the plugin is used on several sites, it can be convenient to specify one or several distributed parent forms. Local settings can inherit from these forms. To take advantage of this feature, create a new Wordpress plugin with the function raise_donation_processor_config.

<?php
/**
 * Plugin Name: Your config plugin
 * Plugin URI: https://github.com/your_github_account/your_plugin
 * GitHub Plugin URI: your_github_account/your_plugin
 * Description: Contains default form of the donation plugin
 * Author: Your Name
 * Version: 0.1
 */
function raise_donation_processor_config() {
    return json_decode(<<<'EOD'
{
  "forms": {
    "default": {
      "amount": {
        "button": [
          35,
          75
        ],
...
}
EOD
    , true);
}

JsonLogic

The following properties can be specified in an array format that lets you encode if ... else if ... else rules:

  • forms > my_form > payment > provider > (banktransfer|stripe|paypal|gocardless|bitpay|coinbase|skrill)
  • forms > my_form > payment > form_elements > tax_receipt
  • forms > my_form > payment > form_elements > share_data
  • forms > my_form > payment > form_elements > tip
  • forms > my_form > finish > post_donation_instructions

The value objects for the checkbox form elements (forms > my_form > form_elements > *) can take the following properties:

  • label: Checkbox label (string or object)
  • disabled: Checkbox disabled (boolean). Default is false.
  • checked: Checkbox checked by default (boolean). Default is false.

The value objects for forms > my_form > form_elements > tip also take tip_percentage.

Note: Replace my_form with the name of the corresponding form in your config.

Essentially, instead of assigning the usual object to the above properties, you assign an array of objects that each have a condition. So instead of

"some_obejct_property": {
  "subproperty1": "foo",
  "subproperty2": "foo"
}

you get

"some_obejct_property": [
  {
    "value": {
      "subproperty1": "foo 1",
      "subproperty2": "foo 2"
    },
    "if": {
      "===": [
        {
          "var": "purpose"
        },
        "purpose_1"
      ]
    }
  },
  {
    "value": {
      "subproperty1": "foo 3",
      "subproperty2": "foo 4"
    },
    "if": {
      "in": [
        {
          "var": "country_code"
        },
        [
          "CH",
          "DE",
          "AT"
        ]
      ]
    }
  },
  {
    "value": {
      "subproperty1": "foo 5",
      "subproperty2": "foo 6"
    },
    "if": true
  }
]

All objects in the array must have a value property and an if property. value has whatever type the corresponding property supports. The if property contains a JsonLogic rule.

The objects are evaluated top down. As soon as one if rule matches, the property is assigned the corresponding value object.

If you leave away the final catch-all node ("if": true), the value null is returned.

See list of supported JsonLogic operations.

Donation property placeholders

The following placeholder can be used in strings: %currency%, %amount%, %frequency%, %frequency_label% (localized), %payment_provider%, %payment_provider_label% (localized), %email%, %name%, %purpose% (key), %purpose_label%, %address%, %zip%, %city%, %country_code%, %country% (in English), %comment%, %account%, %reference% (in post_donation_instruction only), %tax_receipt_label% (yes/no, localized), %share_data_label% (yes/no, localized), %tip_label% (yes/no, localized), %mailinglist_label% (yes/no, localized)

Payment methods

Each payment method except bank transfer object is further nested into live and sandbox.

Bank transfer

Has a details property with a object of key-value pairs which can be displayed on the confirmation page using the %bank_account_formatted% placeholder in post_donation_instructions. The optional account property is sent in the webhook payload.

Each key will be printed in bold and translated if a translation is found. Currently translated: "Bank", "Beneficiary", "BIC/SWIFT", "IBAN", "Purpose", "Reference number", "Sort code".

Supports the %reference_number% placeholder.

"banktransfer": {
  "account": "Optional identifier for the bank account the donation is eventually transferred to",
  "tooltip": "Something you want the donor to know",
  "details": {
    "Beneficiary": "My organisation",
    "IBAN": "DE12500105170648489890",
    "Purpose": "%reference_number%"
  }
}

The following detail keys are localized:

  • Beneficiary
  • IBAN
  • BIC/SWIFT
  • Sort code
  • Routing number
  • Bank
  • Purpose

You can use other keys as well, but they won't be localized.

Bank transfer flow

Reference numbers

To match bank transfers with registrations, you can declare a reference number prefix per purpose. This will get joined with a random 10-letter string and becomes available as the %reference_number% placeholder, e.g. "ORG-6FD5-7H91".

{
  "forms": {
    "my_form": {
      "payment": {
        "reference_number_prefix": {
          "purpose1": "ORG",
          "default": "DONATION"
        }
      }
    }
  }
}

Stripe

Requires secret_key and public_key. The organisation logo used in the checkout modal can be configured on the settings page.

"stripe": {
  "account": "Optional identifier for the bank account the donation is eventually transferred to",
  "tooltip": "Something you want the donor to know",
  "live": {
    "secret_key": "sk_live_mykey",
    "public_key": "pk_live_mykey"
  },
  "sandbox": {
    "secret_key": "sk_test_mykey",
    "public_key": "pk_test_mykey"
  }
}

Additional webhook data:

  • vendor_transaction_id: Charge ID (one-time)
  • vendor_subscription_id: Subscription ID (recurring)
  • vendor_customer_id: Customer ID

Stripe flow

PayPal

Requires client_id and client_secret. Generate credentials on PayPal Dashboard > My Apps & Credentials > REST API apps.

"paypal": {
  "account": "Optional identifier for the bank account the donation is eventually transferred to",
  "tooltip": "Something you want the donor to know",
  "live": {
    "client_id": "paypal_live_client_id",
    "client_secret": "paypal_live_client_secret"
  },
  "sandbox": {
    "client_id": "sandbox",
    "client_secret": "paypal_sandbox_client_id"
  }
}

Additional webhook data:

  • vendor_transaction_id: Transaction ID (one-time)
  • vendor_subscription_id: Agreement/Profile ID (recurring)
  • vendor_customer_id: Payer ID

PayPal flow

GoCardless

Requires access_token (read-write access).

"gocardless": {
  "account": "Optional identifier for the bank account the donation is eventually transferred to",
  "tooltip": "Something you want the donor to know",
  "live": {
    "access_token": "gocardless_live_access_token"
  },
  "sandbox": {
    "access_token": "gocardless_sandbox_access_token"
  }
}

You can generate sandbox access tokens here.

GoCardless is currently only available in the Eurozone, UK, and Sweden. Beware of maximum amounts.

Additional webhook data:

  • vendor_customer_id: Customer ID

GoCardless flow

BitPay

Requires pairing_code.

"bitpay": {
  "account": "Optional identifier for the bank account the donation is eventually transferred to",
  "tooltip": "Something you want the donor to know",
  "live": {
    "pairing_code": "bitpay_live_pairing_code"
  },
  "sandbox": {
    "pairing_code": "bitpay_sandbox_pairing_code"
  }
}

Bitpay does not support recurring donations.

You can make a sandbox account here. Go to Payment Tools > Manage API Tokens > Add New Token to generate a pairing code.

Note: Donations are registered only if the donor clicks continue in the BitPay modal.

Additional webhook data:

  • vendor_transaction_id: Invoice ID

Bitpay flow

Coinbase

Requires api_key.

"coinbase": {
  "account": "Optional identifier for the bank account the donation is eventually transferred to",
  "tooltip": "Something you want the donor to know",
  "live": {
    "api_key": "coinbase_sandbox_api_key"
  }
}

Coinbase does not support recurring donations. Also, it does not have a sandbox environment for testing.

Note: Donations are registered only if the donor waits until the transaction is fully verified without closing the popup.

Additional webhook data:

  • vendor_transaction_id: Charge code

Coinbase flow

Skrill

Requires merchant_account.

"skrill": {
  "account": "Optional identifier for the bank account the donation is eventually transferred to",
  "tooltip": "Something you want the donor to know",
  "live": {
    "merchant_account": "skrill_live_merchang_account"
  },
  "sandbox": {
    "merchant_account": "skrill_sandbox_merchang_account"
  }
}

You the following email as sandbox merchant_account: demoqcoflexible@sun-fish.com

The following credit card can be used for testing: 5438311234567890

Skrill flow

Confirmation email

"email": {
  "sender": "My organisation",
  "address": "my.org@example.org",
  "subject": "Thank you for your donation",
  "text": "Dear {{ name }},\n\nNew line.",
  "html": true
}

Keys are lowercase 2-letter language codes.

  • sender defaults to wp_mail default sender.
  • address defaults to wp_mail default sender
  • subject supports variables via Twig
  • html will send the email as text/html if true, else text/plain (Note: In html mode new lines (\n) are converted to <br> tags at runtime.)
  • text supports variables via Twig

See the Twig 1.x documentation for placeholders. Available variables: form, mode, url, language, time, currency, amount, frequency, payment_provider, email, name, purpose, address, zip, city, country (in English), comment, post_donation_instructions, receipt_text, deductible

If an account is referenced in tax_deduction, the bank_account variable can be dumped using the raise.dump macro.

{{ raise.dump(bank_account, 'html') }} // use 'text' if email is sent as text

Internally, Raise uses wp_mail to send email. If you prefer sending email over SMTP, you can use a plugin like WP Mail SMTP or direct a webhook to an external service like Zapier.

Notification emails

Send a notification email whenever a donation was completed. Can be a comma-separated list of email addresses or an object with sending rules:

{
  "notification_email": {
    "partner-charity@example.org": {
      "payment_provider": "Bank Transfer",
      "country_code": "us"
    },
    "new-donation@example.org": {}
  }
}

All keys sent in webhooks can be used as rule conditions. If at least one condition does not match, the notification email is skipped. An empty object will always pass.

Note: The possible payment_provider values are Stripe, PayPal, GoCardless, Skrill, BitPay, Coinbase and Bank Transfer

Webhooks

Array of webhook URLs. There are currently two options, logging and mailing_list, the latter of which will only get triggered when the subscribe checkbox was ticked. Upon successful donation a JSON object will be sent to each webhook, containing these parameters for logging:

form, url, mode (sandbox/live), language (ISO-639-1), time, currency, amount (includes tip), payment_provider, email, frequency, purpose, name, address, zip, city, country (in English), country_code (ISO-3166-1 alpha-2, e.g. US), comment, anonymous (yes/no), tax_receipt (yes/no), mailinglist (yes/no), account, deductible (yes/no), share_data (yes/no), share_data_offered (yes/no), tip (yes/no), tip_offered (yes/no), tip_amount, tip_percentage (the offered percentage), post_donation_instructions (text on confirmation page), reference, referrer, vendor_transaction_id, vendor_subscription_id, vendor_customer_id

And these for mailing_list: form, mode, email, name, language

Events

The following events will get dispatched to the window object. Each event is thrown only once per page impression.

  • raise_loaded_donation_form: The user has visited the page of the donation form. The detail property of the event has the following keys: form.
  • raise_interacted_with_donation_form: The user has reached the second slide. The detail property of the event has the following keys: form, amount, currency.
  • raise_initiated_donation: The user has clicked on the donate button on the second slide. The detail property of the event has the following keys: form, amount, currency, payment_provider, purpose, account
  • raise_completed_donation: The user has completed a donation. Note that the payment provider may differ from the one in raise_initiated_donation if the user has aborted a previous checkout process with a different payment provider. The detail property of the event has the following keys: form, amount, currency, payment_provider, purpose, account.

Translations

Each key containing a localizable string displayed to the user can also be specified as an object with multiple languages.

{
  "organization": "My organization"
}
{
  "organization": {
    "en": "My organization",
    "de": "Meine Organisation"
  }
}

If the key for the language of the website is missing, the first language is used as a fallback (en in this case).

Use Poedit or a similar tool to translate or modify the .pot and .po files that come with this plugin.

Logging

If set, the plugin will save the specified number of donations as a custom post type in the database. If the max number is reached, older donations will get pushed out (first-in first-out). This can be used for backup purposes, in case the webhooks fail.

{
  "forms": {
    "my_form": {
      "log": {
        "max": 50
      },
    }
  }
}

Integration with fundraising plugin

To reference the post ID of a fundraiser, set the fundraiser option. The fundraiser ID can be found in the URL, e.g. https://example.org/wp-admin/post.php?post=<fundraiser_id>&action=edit.

{
  "forms": {
    "my_form": {
      "payment": {
        "fundraiser": 159
      },
    }
  }
}

Tests

Requires phpunit.

bash bin/install-wp-tests.sh wordpress_test <mysql_user> <mysql_pass> <mysql_host> latest

phpunit

Built with

Contributing

A new version is released by adding the appropriate tag, matching the version number in the plugin header. Pull requests welcome.

Versioning

We use SemVer for versioning.

License

This project is licensed under the GNU GPLv3 - see the LICENSE file for details.