1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Give - Stripe Core |
4
|
|
|
* |
5
|
|
|
* @since 2.5.0 |
6
|
|
|
* |
7
|
|
|
* @package Give |
8
|
|
|
* @subpackage Stripe Core |
9
|
|
|
* @copyright Copyright (c) 2019, GiveWP |
10
|
|
|
* @license https://opensource.org/licenses/gpl-license GNU Public License |
11
|
|
|
*/ |
12
|
|
|
|
13
|
|
|
// Exit, if accessed directly. |
14
|
|
|
if ( ! defined( 'ABSPATH' ) ) { |
15
|
|
|
exit; |
16
|
|
|
} |
17
|
|
|
|
18
|
|
|
if ( ! class_exists( 'Give_Stripe' ) ) { |
19
|
|
|
|
20
|
|
|
class Give_Stripe { |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* Give_Stripe() constructor. |
24
|
|
|
* |
25
|
|
|
* @since 2.5.0 |
26
|
|
|
* @access public |
27
|
|
|
* |
28
|
|
|
* @return void |
|
|
|
|
29
|
|
|
*/ |
30
|
|
|
public function __construct() { |
31
|
|
|
|
32
|
|
|
add_action( 'admin_notices', array( $this, 'display_old_recurring_compatibility_notice' ) ); |
33
|
|
|
add_filter( 'give_payment_gateways', array( $this, 'register_gateway' ) ); |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Using hardcoded constant for backward compatibility of Give 2.5.0 with Recurring 1.8.13 when Stripe Premium is not active. |
37
|
|
|
* |
38
|
|
|
* This code will handle extreme rare scenario. |
39
|
|
|
* |
40
|
|
|
* @since 2.5.0 |
41
|
|
|
* |
42
|
|
|
* @todo Remove this constant declaration after 2-3 Give core minor releases. |
43
|
|
|
*/ |
44
|
|
|
if ( ! defined( 'GIVE_STRIPE_BASENAME' ) ) { |
45
|
|
|
define( 'GIVE_STRIPE_BASENAME', 'give-stripe/give-stripe.php' ); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
$this->includes(); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* This function is used to include the related Stripe core files. |
53
|
|
|
* |
54
|
|
|
* @since 2.5.0 |
55
|
|
|
* @access public |
56
|
|
|
* |
57
|
|
|
* @return void |
58
|
|
|
*/ |
59
|
|
|
public function includes() { |
60
|
|
|
|
61
|
|
|
require_once GIVE_PLUGIN_DIR . 'vendor/autoload.php'; |
62
|
|
|
|
63
|
|
|
// Include admin files. |
64
|
|
|
require_once GIVE_PLUGIN_DIR . 'includes/gateways/stripe/includes/admin/admin-actions.php'; |
65
|
|
|
require_once GIVE_PLUGIN_DIR . 'includes/gateways/stripe/includes/admin/admin-filters.php'; |
66
|
|
|
require_once GIVE_PLUGIN_DIR . 'includes/gateways/stripe/includes/admin/class-give-stripe-admin-settings.php'; |
67
|
|
|
require_once GIVE_PLUGIN_DIR . 'includes/gateways/stripe/includes/admin/class-give-stripe-logs.php'; |
68
|
|
|
|
69
|
|
|
// Include frontend files. |
70
|
|
|
require_once GIVE_PLUGIN_DIR . 'includes/gateways/stripe/includes/give-stripe-helpers.php'; |
71
|
|
|
require_once GIVE_PLUGIN_DIR . 'includes/gateways/stripe/includes/actions.php'; |
72
|
|
|
require_once GIVE_PLUGIN_DIR . 'includes/gateways/stripe/includes/class-give-stripe-logger.php'; |
73
|
|
|
require_once GIVE_PLUGIN_DIR . 'includes/gateways/stripe/includes/class-give-stripe-invoice.php'; |
74
|
|
|
require_once GIVE_PLUGIN_DIR . 'includes/gateways/stripe/includes/class-give-stripe-customer.php'; |
75
|
|
|
require_once GIVE_PLUGIN_DIR . 'includes/gateways/stripe/includes/class-give-stripe-payment-intent.php'; |
76
|
|
|
require_once GIVE_PLUGIN_DIR . 'includes/gateways/stripe/includes/class-give-stripe-payment-method.php'; |
77
|
|
|
require_once GIVE_PLUGIN_DIR . 'includes/gateways/stripe/includes/class-give-stripe-gateway.php'; |
78
|
|
|
require_once GIVE_PLUGIN_DIR . 'includes/gateways/stripe/includes/class-give-stripe-webhooks.php'; |
79
|
|
|
require_once GIVE_PLUGIN_DIR . 'includes/gateways/stripe/includes/payment-methods/class-give-stripe-card.php'; |
80
|
|
|
require_once GIVE_PLUGIN_DIR . 'includes/gateways/stripe/includes/give-stripe-scripts.php'; |
81
|
|
|
require_once GIVE_PLUGIN_DIR . 'includes/gateways/stripe/includes/deprecated/deprecated-functions.php'; |
82
|
|
|
require_once GIVE_PLUGIN_DIR . 'includes/gateways/stripe/includes/deprecated/deprecated-filters.php'; |
83
|
|
|
|
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* Register the payment methods supported by Stripe. |
88
|
|
|
* |
89
|
|
|
* @access public |
90
|
|
|
* @since 2.5.0 |
91
|
|
|
* |
92
|
|
|
* @param array $gateways List of registered gateways. |
93
|
|
|
* |
94
|
|
|
* @return array |
95
|
|
|
*/ |
96
|
|
|
public function register_gateway( $gateways ) { |
97
|
|
|
|
98
|
|
|
$gateways['stripe'] = array( |
99
|
|
|
'admin_label' => __( 'Stripe - Credit Card', 'give' ), |
100
|
|
|
'checkout_label' => __( 'Credit Card', 'give' ), |
101
|
|
|
); |
102
|
|
|
|
103
|
|
|
return $gateways; |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* Display compatibility notice for Give 2.5.0 and Recurring 1.8.13 when Stripe premium is not active. |
108
|
|
|
* |
109
|
|
|
* @since 2.5.0 |
110
|
|
|
* |
111
|
|
|
* @return void |
112
|
|
|
*/ |
113
|
|
|
public function display_old_recurring_compatibility_notice() { |
114
|
|
|
|
115
|
|
|
// Show notice, if incompatibility found. |
116
|
|
|
if ( |
117
|
|
|
defined( 'GIVE_RECURRING_VERSION' ) |
118
|
|
|
&& version_compare( GIVE_RECURRING_VERSION, '1.9.0', '<' ) |
119
|
|
|
&& ! defined( 'GIVE_STRIPE_VERSION' ) |
120
|
|
|
) { |
121
|
|
|
|
122
|
|
|
$message = sprintf( |
123
|
|
|
__( '<strong>Attention:</strong> Give 2.5.0+ requires the latest version of the Recurring Donations add-on to process payments properly with Stripe. Please update to the latest version add-on to resolve compatibility issues. If your license is active, you should see the update available in WordPress. Otherwise, you can access the latest version by <a href="%1$s" target="_blank">logging into your account</a> and visiting <a href="%1$s" target="_blank">your downloads</a> page on the GiveWP website.', 'give' ), |
124
|
|
|
esc_url( 'https://givewp.com/wp-login.php' ), |
125
|
|
|
esc_url( 'https://givewp.com/my-account/#tab_downloads' ) |
126
|
|
|
); |
127
|
|
|
|
128
|
|
|
Give()->notices->register_notice( |
129
|
|
|
array( |
130
|
|
|
'id' => 'give-compatibility-with-old-recurring', |
131
|
|
|
'type' => 'error', |
132
|
|
|
'description' => $message, |
133
|
|
|
'show' => true, |
134
|
|
|
) |
135
|
|
|
); |
136
|
|
|
} |
137
|
|
|
|
138
|
|
|
} |
139
|
|
|
} |
140
|
|
|
} |
141
|
|
|
|
142
|
|
|
new Give_Stripe(); |
143
|
|
|
|
Adding a
@return
annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.