PayPal Donations - Version 1.9.4

Version Description

Download this release

Release Info

Developer mra13
Plugin Icon 128x128 PayPal Donations
Version 1.9.4
Comparing to
See all releases

Code changes from version 1.8.5 to 1.9.4

paypal-donations.php CHANGED
@@ -1,31 +1,17 @@
1
  <?php
2
  /*
3
  Plugin Name: PayPal Donations
4
- Plugin URI: http://johansteen.se/code/paypal-donations/
5
  Description: Easy and simple setup and insertion of PayPal donate buttons with a shortcode or through a sidebar Widget. Donation purpose can be set for each button. A few other customization options are available as well.
6
- Author: Johan Steen
7
- Author URI: http://johansteen.se/
8
- Version: 1.8.5
9
  License: GPLv2 or later
10
  Text Domain: paypal-donations
11
-
12
- Copyright 2009-2014 Johan Steen (email : artstorm [at] gmail [dot] com)
13
-
14
- This program is free software; you can redistribute it and/or modify
15
- it under the terms of the GNU General Public License as published by
16
- the Free Software Foundation; either version 2 of the License, or
17
- (at your option) any later version.
18
-
19
- This program is distributed in the hope that it will be useful,
20
- but WITHOUT ANY WARRANTY; without even the implied warranty of
21
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
- GNU General Public License for more details.
23
-
24
- You should have received a copy of the GNU General Public License
25
- along with this program; if not, write to the Free Software
26
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
27
  */
28
 
 
 
29
  /** Load all of the necessary class files for the plugin */
30
  spl_autoload_register('PayPalDonations::autoload');
31
 
@@ -156,6 +142,7 @@ class PayPalDonations
156
  $this->checkout_languages
157
  );
158
 
 
159
  add_shortcode('paypal-donation', array(&$this,'paypalShortcode'));
160
  add_action('wp_head', array($this, 'addCss'), 999);
161
 
@@ -246,6 +233,7 @@ class PayPalDonations
246
  'amount' => '',
247
  'return_page' => '',
248
  'button_url' => '',
 
249
  ),
250
  $atts
251
  )
@@ -256,7 +244,8 @@ class PayPalDonations
256
  $reference,
257
  $amount,
258
  $return_page,
259
- $button_url
 
260
  );
261
  }
262
 
@@ -268,7 +257,8 @@ class PayPalDonations
268
  $reference = null,
269
  $amount = null,
270
  $return_page = null,
271
- $button_url = null
 
272
  ) {
273
  $pd_options = get_option(self::OPTION_DB_KEY);
274
 
@@ -287,6 +277,7 @@ class PayPalDonations
287
  'amount' => $amount,
288
  'button_url' => $button_url,
289
  'donate_buttons' => $this->donate_buttons,
 
290
  );
291
 
292
  return PayPalDonations_View::render('paypal-button', $data);
1
  <?php
2
  /*
3
  Plugin Name: PayPal Donations
4
+ Plugin URI: https://www.tipsandtricks-hq.com/paypal-donations-widgets-plugin
5
  Description: Easy and simple setup and insertion of PayPal donate buttons with a shortcode or through a sidebar Widget. Donation purpose can be set for each button. A few other customization options are available as well.
6
+ Author: Tips and Tricks HQ, Johan Steen
7
+ Author URI: https://www.tipsandtricks-hq.com/
8
+ Version: 1.9.4
9
  License: GPLv2 or later
10
  Text Domain: paypal-donations
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  */
12
 
13
+ include_once('paypal_utility.php');
14
+
15
  /** Load all of the necessary class files for the plugin */
16
  spl_autoload_register('PayPalDonations::autoload');
17
 
142
  $this->checkout_languages
143
  );
144
 
145
+ add_filter('widget_text', 'do_shortcode');
146
  add_shortcode('paypal-donation', array(&$this,'paypalShortcode'));
147
  add_action('wp_head', array($this, 'addCss'), 999);
148
 
233
  'amount' => '',
234
  'return_page' => '',
235
  'button_url' => '',
236
+ 'validate_ipn' => '',
237
  ),
238
  $atts
239
  )
244
  $reference,
245
  $amount,
246
  $return_page,
247
+ $button_url,
248
+ $validate_ipn
249
  );
250
  }
251
 
257
  $reference = null,
258
  $amount = null,
259
  $return_page = null,
260
+ $button_url = null,
261
+ $validate_ipn = ''
262
  ) {
263
  $pd_options = get_option(self::OPTION_DB_KEY);
264
 
277
  'amount' => $amount,
278
  'button_url' => $button_url,
279
  'donate_buttons' => $this->donate_buttons,
280
+ 'validate_ipn' => $validate_ipn,
281
  );
282
 
283
  return PayPalDonations_View::render('paypal-button', $data);
paypal_utility.php ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ add_action('init', 'pp_donations_ipn_listener');
4
+
5
+ function pp_donations_ipn_listener(){
6
+ //Listen for IPN and validate it
7
+ if (isset($_REQUEST['ppd_paypal_ipn']) && $_REQUEST['ppd_paypal_ipn'] == "process") {
8
+ pp_donations_validate_paypl_ipn();
9
+ exit;
10
+ }
11
+ }
12
+
13
+ function pp_donations_validate_paypl_ipn() {
14
+
15
+ $ipn_validated = true;
16
+
17
+ // Reading POSTed data directly from $_POST causes serialization issues with array data in the POST.
18
+ // Instead, read raw POST data from the input stream.
19
+ $raw_post_data = file_get_contents('php://input');
20
+ $raw_post_array = explode('&', $raw_post_data);
21
+ $myPost = array();
22
+ foreach ($raw_post_array as $keyval) {
23
+ $keyval = explode('=', $keyval);
24
+ if (count($keyval) == 2)
25
+ $myPost[$keyval[0]] = urldecode($keyval[1]);
26
+ }
27
+
28
+ // read the IPN message sent from PayPal and prepend 'cmd=_notify-validate'
29
+ $req = 'cmd=_notify-validate';
30
+ if (function_exists('get_magic_quotes_gpc')) {
31
+ $get_magic_quotes_exists = true;
32
+ }
33
+ foreach ($myPost as $key => $value) {
34
+ if ($get_magic_quotes_exists == true && get_magic_quotes_gpc() == 1) {
35
+ $value = urlencode(stripslashes($value));
36
+ } else {
37
+ $value = urlencode($value);
38
+ }
39
+ $req .= "&$key=$value";
40
+ }
41
+
42
+
43
+ // Step 2: POST IPN data back to PayPal to validate
44
+ $ch = curl_init('https://www.paypal.com/cgi-bin/webscr');
45
+ curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
46
+ curl_setopt($ch, CURLOPT_POST, 1);
47
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
48
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $req);
49
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
50
+ curl_setopt($ch, CURLOPT_HTTPHEADER, array('Connection: Close'));
51
+
52
+ if (!($res = curl_exec($ch))) {
53
+ // error_log("Got " . curl_error($ch) . " when processing IPN data");
54
+ curl_close($ch);
55
+ exit;
56
+ }
57
+ curl_close($ch);
58
+
59
+ // Inspect IPN validation result and act accordingly
60
+ if (strcmp ($res, "VERIFIED") == 0) {
61
+ // The IPN is verified, process it
62
+ $ipn_validated = true;
63
+ } else if (strcmp ($res, "INVALID") == 0) {
64
+ // IPN invalid, log for manual investigation
65
+ $ipn_validated = false;
66
+ }
67
+
68
+
69
+ if (!$ipn_validated) {
70
+ // IPN validation failed. Email the admin to notify this event.
71
+ $admin_email = get_bloginfo('admin_email');
72
+ $subject = 'IPN validation failed for a payment';
73
+ $body = "This is a notification email from the WP Accept PayPal Payment plugin letting you know that a payment verification failed." .
74
+ "\n\nPlease check your paypal account to make sure you received the correct amount in your account before proceeding" .
75
+ wp_mail($admin_email, $subject, $body);
76
+ exit;
77
+ }
78
+ }
readme.txt CHANGED
@@ -1,10 +1,10 @@
1
  === PayPal Donations ===
2
- Contributors: artstorm
3
- Donate link: http://johansteen.se/donate/
4
- Tags: paypal, donation, shortcode, widget, donate, button, sidebar
5
  Requires at least: 3.0
6
- Tested up to: 4.0
7
- Stable tag: 1.8.5
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -30,14 +30,32 @@ Which is the simplest option, and uses all default and optional settings. If you
30
 
31
  This donation plugin generates valid XHTML Transitional and Strict code.
32
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  = Related Links =
34
 
35
- * [Documentation](http://johansteen.se/code/paypal-donations/
36
  "Usage instructions")
37
  * [Support Forum](http://wordpress.org/support/plugin/paypal-donations
38
  "Use this for support and feature requests")
39
- * [GitHub](https://github.com/artstorm/paypal-donations
40
- "Develop and contribute your code or report bugs")
41
 
42
 
43
  == Installation ==
@@ -62,25 +80,42 @@ This donation plugin generates valid XHTML Transitional and Strict code.
62
  Please visit the [Support Forum](http://wordpress.org/support/plugin/paypal-donations "Use this for support and feature requests")
63
  for questions, answers, support and feature requests.
64
 
65
- = Where can I send bug reports? =
66
 
67
- Please visit the GitHub repository for [PayPal Donations](https://github.com/artstorm/paypal-donations)
68
- and open an [issue](https://github.com/artstorm/paypal-donations/issues).
69
 
70
- = How can I contribute to the plugin? =
71
 
72
- If you want to contribute improved code or new features for the plugin. Please
73
- open a pull request at the [PayPal Donations GitHub repository](https://github.com/artstorm/paypal-donations).
74
- Contributions are appreciated and encouraged.
75
 
 
 
76
 
77
- == Screenshots ==
 
78
 
79
- 1. Admin page where you setup the plugin
80
- 1. Sidebar Widget Admin Options
81
 
 
 
82
 
83
- == Changelog ==
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
84
 
85
  = Version 1.8.5 - 21 Sep 2014 =
86
  * Add support for PayPal Sandbox.
1
  === PayPal Donations ===
2
+ Contributors: Tips and Tricks HQ, artstorm
3
+ Donate link: https://www.tipsandtricks-hq.com/paypal-donations-widgets-plugin
4
+ Tags: paypal, donation, donations, shortcode, widget, donate, button, sidebar, paypal donation, payment
5
  Requires at least: 3.0
6
+ Tested up to: 4.9
7
+ Stable tag: 1.9.4
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
30
 
31
  This donation plugin generates valid XHTML Transitional and Strict code.
32
 
33
+ = Translations =
34
+
35
+ The following language translations are already available in the plugin:
36
+
37
+ * Albanian (sq_AL)
38
+ * Danish (da_DK)
39
+ * Dutch (nl_NL)
40
+ * French (fr_FR)
41
+ * German (de_DE)
42
+ * Hebrew (he_IL)
43
+ * Italian (it_IT)
44
+ * Lithuanian (lt_LT)
45
+ * Malay – Bahasa Melayu (ms_MY)
46
+ * Norwegian bokmål
47
+ * Romanian (ro_RO)
48
+ * Russian (ru_RU)
49
+ * Spanish (es_ES)
50
+ * Swedish (sv_SE)
51
+ * Turkish (tr_TR)
52
+
53
  = Related Links =
54
 
55
+ * [Documentation](https://www.tipsandtricks-hq.com/paypal-donations-widgets-plugin
56
  "Usage instructions")
57
  * [Support Forum](http://wordpress.org/support/plugin/paypal-donations
58
  "Use this for support and feature requests")
 
 
59
 
60
 
61
  == Installation ==
80
  Please visit the [Support Forum](http://wordpress.org/support/plugin/paypal-donations "Use this for support and feature requests")
81
  for questions, answers, support and feature requests.
82
 
83
+ == Screenshots ==
84
 
85
+ 1. Admin page where you setup the plugin
86
+ 1. Sidebar Widget Admin Options
87
 
 
88
 
89
+ == Changelog ==
 
 
90
 
91
+ = version 1.9.4 =
92
+ * Added a new filter that allows overriding of the paypal email address dynamically.
93
 
94
+ = version 1.9.3 =
95
+ * Added sanitization and escaping where appropriate.
96
 
97
+ = version 1.9.2 =
98
+ * Added the do_shortcode filtering call on widget_text.
99
 
100
+ = version 1.9.1 =
101
+ * WordPress 4.4 compatibility.
102
 
103
+ = version 1.9.0 =
104
+ * Added a new filter that will allow tweaks to localize the button image on a multi-lingual website.
105
+ * Added PayPal IPN validation option.
106
+
107
+ = version 1.8.9 =
108
+ * Fixed an issue with saving the custom image URL for the donate button in the admin interface.
109
+
110
+ = Version 1.8.8 =
111
+ * WordPress 4.2 compatibility
112
+
113
+ = Version 1.8.7 =
114
+ * WordPress 4.1 compatibility
115
+
116
+ = Version 1.8.6 =
117
+ * WordPress 4.0 compatibility
118
+ * Updated documentation page links
119
 
120
  = Version 1.8.5 - 21 Sep 2014 =
121
  * Add support for PayPal Sandbox.
src/PayPalDonations/Admin.php CHANGED
@@ -536,7 +536,7 @@ class PayPalDonations_Admin
536
  }
537
  echo " /> <img src='" . str_replace('en_US', $button_localized, $button) . "' alt='" . $key . "' style='vertical-align: middle;' /></label><br /><br />\n";
538
  }
539
- echo ' <label><input type="radio" name="{$optionKey}[button]" value="custom"';
540
  checked($custom, true);
541
  echo '/> '.__('Custom Button', PayPalDonations::TEXT_DOMAIN);
542
 
536
  }
537
  echo " /> <img src='" . str_replace('en_US', $button_localized, $button) . "' alt='" . $key . "' style='vertical-align: middle;' /></label><br /><br />\n";
538
  }
539
+ echo ' <label><input type="radio" name="'.$optionKey.'[button]" value="custom"';
540
  checked($custom, true);
541
  echo '/> '.__('Custom Button', PayPalDonations::TEXT_DOMAIN);
542
 
views/admin.php CHANGED
@@ -3,6 +3,15 @@
3
  <div id="icon-plugins" class="icon32"></div>
4
  <h2>PayPal Donations</h2>
5
 
 
 
 
 
 
 
 
 
 
6
  <h2 class="nav-tab-wrapper">
7
  <ul id="paypal-donations-tabs">
8
  <li id="paypal-donations-tab_1" class="nav-tab nav-tab-active"><?php _e('General', 'paypal-donations'); ?></li>
3
  <div id="icon-plugins" class="icon32"></div>
4
  <h2>PayPal Donations</h2>
5
 
6
+ <div style="background:#FFF6D5;border: 1px solid #D1B655;color: #3F2502;margin: 10px 0;padding: 5px 5px 5px 10px;text-shadow: 1px 1px #FFFFFF;">
7
+ <p>
8
+ The usage instruction and video tutorial is available on the PayPal Donations plugin <a href="https://www.tipsandtricks-hq.com/paypal-donations-widgets-plugin" target="_blank">documentation page</a>.
9
+ </p>
10
+ <p>
11
+ If you need a feature rich and sleek plugin for accepting PayPal donation and payment then check out our <a target="_blank" href="https://www.tipsandtricks-hq.com/wordpress-estore-plugin-complete-solution-to-sell-digital-products-from-your-wordpress-blog-securely-1059">WP eStore Plugin</a> (it comes with premium support). You can accept recurring payments with it also.
12
+ </p>
13
+ </div>
14
+
15
  <h2 class="nav-tab-wrapper">
16
  <ul id="paypal-donations-tabs">
17
  <li id="paypal-donations-tab_1" class="nav-tab nav-tab-active"><?php _e('General', 'paypal-donations'); ?></li>
views/paypal-button.php CHANGED
@@ -1,4 +1,4 @@
1
- <!-- Begin PayPal Donations by http://johansteen.se/ -->
2
  <?php
3
  $url = isset($pd_options['sandbox']) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr' : 'https://www.paypal.com/cgi-bin/webscr';
4
  ?>
@@ -10,7 +10,8 @@ if (isset($pd_options['new_tab'])) {
10
  ?>>
11
  <div class="paypal-donations">
12
  <input type="hidden" name="cmd" value="_donations" />
13
- <input type="hidden" name="business" value="<?php echo $pd_options['paypal_account']; ?>" />
 
14
  <?php
15
  # Build the button
16
  $paypal_btn = '';
@@ -18,33 +19,44 @@ if (isset($pd_options['new_tab'])) {
18
 
19
  // Optional Settings
20
  if ($pd_options['page_style'])
21
- $paypal_btn .= $indent.'<input type="hidden" name="page_style" value="' .$pd_options['page_style']. '" />'.PHP_EOL;
22
  if ($return_page)
23
- $paypal_btn .= $indent.'<input type="hidden" name="return" value="' .$return_page. '" />'.PHP_EOL; // Return Page
24
  if ($purpose)
25
- $paypal_btn .= apply_filters('paypal_donations_purpose_html', $indent.'<input type="hidden" name="item_name" value="' .$purpose. '" />'.PHP_EOL); // Purpose
26
  if ($reference)
27
- $paypal_btn .= $indent.'<input type="hidden" name="item_number" value="' .$reference. '" />'.PHP_EOL; // LightWave Plugin
28
- if ($amount)
 
 
 
29
  $paypal_btn .= $indent.'<input type="hidden" name="amount" value="' . apply_filters( 'paypal_donations_amount', $amount ) . '" />'.PHP_EOL;
 
30
 
 
 
 
 
 
31
  // More Settings
32
  if (isset($pd_options['return_method']))
33
- $paypal_btn .= $indent.'<input type="hidden" name="rm" value="' .$pd_options['return_method']. '" />'.PHP_EOL;
34
  if (isset($pd_options['currency_code']))
35
- $paypal_btn .= $indent.'<input type="hidden" name="currency_code" value="' .$pd_options['currency_code']. '" />'.PHP_EOL;
36
  if (isset($pd_options['button_localized']))
37
  { $button_localized = $pd_options['button_localized']; } else { $button_localized = 'en_US'; }
38
  if (isset($pd_options['set_checkout_language']) and $pd_options['set_checkout_language'] == true)
39
- $paypal_btn .= $indent.'<input type="hidden" name="lc" value="' .$pd_options['checkout_language']. '" />'.PHP_EOL;
40
 
41
  // Settings not implemented yet
42
  // $paypal_btn .= '<input type="hidden" name="amount" value="20" />';
43
 
44
  // Get the button URL
45
- if ( $pd_options['button'] != "custom" && !$button_url)
 
46
  $button_url = str_replace('en_US', $button_localized, $donate_buttons[$pd_options['button']]);
47
- $paypal_btn .= $indent.'<input type="image" src="' .$button_url. '" name="submit" alt="PayPal - The safer, easier way to pay online." />'.PHP_EOL;
 
48
 
49
  // PayPal stats tracking
50
  if (!isset($pd_options['disable_stats']) or $pd_options['disable_stats'] != true)
1
+ <!-- Begin PayPal Donations by https://www.tipsandtricks-hq.com/paypal-donations-widgets-plugin -->
2
  <?php
3
  $url = isset($pd_options['sandbox']) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr' : 'https://www.paypal.com/cgi-bin/webscr';
4
  ?>
10
  ?>>
11
  <div class="paypal-donations">
12
  <input type="hidden" name="cmd" value="_donations" />
13
+ <input type="hidden" name="bn" value="TipsandTricks_SP" />
14
+ <input type="hidden" name="business" value="<?php echo apply_filters('paypal_donations_merchant_email', $pd_options['paypal_account']); ?>" />
15
  <?php
16
  # Build the button
17
  $paypal_btn = '';
19
 
20
  // Optional Settings
21
  if ($pd_options['page_style'])
22
+ $paypal_btn .= $indent.'<input type="hidden" name="page_style" value="' .esc_attr($pd_options['page_style']). '" />'.PHP_EOL;
23
  if ($return_page)
24
+ $paypal_btn .= $indent.'<input type="hidden" name="return" value="' .esc_url($return_page). '" />'.PHP_EOL; // Return Page
25
  if ($purpose)
26
+ $paypal_btn .= apply_filters('paypal_donations_purpose_html', $indent.'<input type="hidden" name="item_name" value="' .esc_attr($purpose). '" />'.PHP_EOL); // Purpose
27
  if ($reference)
28
+ $paypal_btn .= $indent.'<input type="hidden" name="item_number" value="' .esc_attr($reference). '" />'.PHP_EOL; // Any reference for this donation
29
+ if ($amount){
30
+ if(!is_numeric($amount)){
31
+ wp_die('Error! Donation amount must be a numeric value.');
32
+ }
33
  $paypal_btn .= $indent.'<input type="hidden" name="amount" value="' . apply_filters( 'paypal_donations_amount', $amount ) . '" />'.PHP_EOL;
34
+ }
35
 
36
+ if (!empty($validate_ipn)){
37
+ $notify_url = site_url() . '/?ppd_paypal_ipn=process';
38
+ $paypal_btn .= $indent.'<input type="hidden" name="notify_url" value="' .esc_url($notify_url). '" />'.PHP_EOL; // Notify URL
39
+ }
40
+
41
  // More Settings
42
  if (isset($pd_options['return_method']))
43
+ $paypal_btn .= $indent.'<input type="hidden" name="rm" value="' .esc_attr($pd_options['return_method']). '" />'.PHP_EOL;
44
  if (isset($pd_options['currency_code']))
45
+ $paypal_btn .= $indent.'<input type="hidden" name="currency_code" value="' .esc_attr($pd_options['currency_code']). '" />'.PHP_EOL;
46
  if (isset($pd_options['button_localized']))
47
  { $button_localized = $pd_options['button_localized']; } else { $button_localized = 'en_US'; }
48
  if (isset($pd_options['set_checkout_language']) and $pd_options['set_checkout_language'] == true)
49
+ $paypal_btn .= $indent.'<input type="hidden" name="lc" value="' .esc_attr($pd_options['checkout_language']). '" />'.PHP_EOL;
50
 
51
  // Settings not implemented yet
52
  // $paypal_btn .= '<input type="hidden" name="amount" value="20" />';
53
 
54
  // Get the button URL
55
+ if ( $pd_options['button'] != "custom" && !$button_url){
56
+ $button_localized = apply_filters('pd_button_localized_value', $button_localized);
57
  $button_url = str_replace('en_US', $button_localized, $donate_buttons[$pd_options['button']]);
58
+ }
59
+ $paypal_btn .= $indent.'<input type="image" style="cursor: pointer;" src="' .esc_url($button_url). '" name="submit" alt="PayPal - The safer, easier way to pay online." />'.PHP_EOL;
60
 
61
  // PayPal stats tracking
62
  if (!isset($pd_options['disable_stats']) or $pd_options['disable_stats'] != true)