Recently we were asked to repair a website for a charity that had been hacked, and during the investigation, it appeared the site was compromised via an out of date donation plugin, “Total Donations Plugin” for WordPress. (If you have this plugin currently active on your WordPress site, it’s best to disable and delete it)
As the plugin in question appears to have been discontinued and didn’t appear to have an updated version with a fix, we decided to check out a few other options to allow the site to continue accepting Donations.
The easiest option would be to use a Donation plugin such as Give, or Charitable, which both have fantastic ratings and offer upgrades to pro versions.
Give requires a per month fee (from $20 to $40 US) for premium payment gateways, Recurring Donations and form field manager, whilst Charitable offers price points of $49 to $249 USD / year for the added extras such as premium payment gateways and Recurring Donations.
As we required Credit Card and PayPal payments as well as Recurring Donations, it made sense that we first try using our favourite form plugin, Gravity Forms which allows also payment to be accepted.
The first step was to create a form with some Conditional Logic so the user could decide if they wanted to donate a fixed amount, or a custom amount of their choosing.
They then are shown the total amount they will be paying to confirm the user knows how much the amount will be, and from here, they choose a One-Off Donation or a Recurring Donation.
The next step is for them to choose which payment method they prefer, and if they choose Stripe, the CC field will be displayed, otherwise it should redirect them to PayPal when they click ‘Submit’.
By default, it doesn’t appear to be straight forward to allow multiple payment methods on the same Gravity Forms submit button, so using some conditional logic to display the method of payment, you can get both Stripe and PayPal to work on the same form.
Once the form is ready to go and you have all the fields you want to capture, we then want to create feeds for both PayPal and Stripe, for both the One-Off payments and the Recurring payments.
For this, we need to create two separate feeds for each Payment method and then make them fire when the correct conditions are met.
If everything has been done correctly, you should see your form working and allowing either fixed donations, custom donations, and then the choice of paying via Stripe / Paypal either one-time or monthly.
Even after you do your testing, it’s always handy to do a few ‘live tests’ with real payments just to ensure everything is working correctly when the form goes live.
Happy Donating!
Functions Extras
/* ---------------------------------------------------------------------------
* Remove Stripe Entry ID message from Email
* --------------------------------------------------------------------------- */
add_filter( 'gform_stripe_charge_description', 'remove_id', 10, 2 );
function remove_id( $description, $strings ) {
unset( $strings['entry_id'] );
return implode( ', ', $strings );
}
/* ---------------------------------------------------------------------------
* Change Default Gravity Forms Error Message
* --------------------------------------------------------------------------- */
add_filter("gform_validation_message", "gf_error", 10, 2);
function gf_error($message, $form) {
return '<div class="gf_error_message">Please fix the errors below.</div>';
}