Diff: STRATO-apps/wordpress_03/app/wp-content/plugins/paid-memberships-pro/adminpages/paymentsettings.php
Keine Baseline-Datei – Diff nur gegen leer.
1
-
1
+
<?php
2
+
//only admins can get this
3
+
if(!function_exists("current_user_can") || (!current_user_can("manage_options") && !current_user_can("pmpro_paymentsettings")))
4
+
{
5
+
die(esc_html__("You do not have permissions to perform this action.", 'paid-memberships-pro' ));
6
+
}
7
+
8
+
global $wpdb, $pmpro_currency_symbol, $msg, $msgt;
9
+
10
+
// Check if we are editing a specific gateway.
11
+
$edit_gateway = ! empty( $_REQUEST['edit_gateway'] ) ? sanitize_text_field( $_REQUEST['edit_gateway'] ) : '';
12
+
13
+
// If we have a gateway, try to build its gateway class name.
14
+
$gateway_class_name = '';
15
+
if ( ! empty( $edit_gateway ) && class_exists( 'PMProGateway_' . $edit_gateway ) ) {
16
+
$gateway_class_name = 'PMProGateway_' . $edit_gateway;
17
+
} else {
18
+
// If the class doesn't exist, empty the gateway.
19
+
$edit_gateway = '';
20
+
}
21
+
22
+
/*
23
+
Since 2.0, we let each gateway define what options they have in the class files
24
+
*/
25
+
//define options
26
+
$payment_options = array_unique(apply_filters("pmpro_payment_options", array('gateway')));
27
+
28
+
//check nonce for saving settings
29
+
if (!empty($_REQUEST['savesettings']) && (empty($_REQUEST['pmpro_paymentsettings_nonce']) || !check_admin_referer('savesettings', 'pmpro_paymentsettings_nonce'))) {
30
+
$msg = -1;
31
+
$msgt = __("Are you sure you want to do that? Try again.", 'paid-memberships-pro' );
32
+
unset($_REQUEST['savesettings']);
33
+
}
34
+
35
+
//get/set settings
36
+
if ( ! empty( $_REQUEST['savesettings'] ) ) {
37
+
// Check whether we are saving the settings for a specific gateway.
38
+
if ( ! empty( $gateway_class_name ) ) {
39
+
// Save the settings for the specific gateway.
40
+
call_user_func( array( $gateway_class_name, 'save_settings_fields' ) );
41
+
} else {
42
+
// Save the global settings.
43
+
$global_settings = array(
44
+
'gateway',
45
+
'gateway_environment',
46
+
'currency',
47
+
'tax_state',
48
+
'tax_rate',
49
+
'tax_settings_beta',
50
+
);
51
+
foreach ( $global_settings as $setting ) {
52
+
pmpro_setOption( $setting );
53
+
}
54
+
}
55
+
56
+
/**
57
+
* Run additional code after payment settings are saved.
58
+
*
59
+
* @param array $deprecated Deprecated parameter. Was previously used to pass in an array of settings that were saved.
60
+
*/
61
+
do_action( 'pmpro_after_saved_payment_options', array() );
62
+
63
+
//assume success
64
+
$msg = true;
65
+
$msgt = __("Your payment settings have been updated.", 'paid-memberships-pro' );
66
+
67
+
// Append a link to main payments settings page.
68
+
if ( isset( $_REQUEST['edit_gateway'] ) ) {
69
+
$msgt .= ' <a href="' . esc_url( add_query_arg( array( 'page' => 'pmpro-paymentsettings' ), admin_url( 'admin.php' ) ) ) . '">' . esc_html__( 'Return to Payment Settings', 'paid-memberships-pro' ) . '</a>';
70
+
}
71
+
}
72
+
73
+
/*
74
+
Some special cases that get worked out here.
75
+
*/
76
+
//make sure the tax rate is not > 1
77
+
$tax_state = get_option( "pmpro_tax_state");
78
+
$tax_rate = get_option( "pmpro_tax_rate");
79
+
if((double)$tax_rate > 1)
80
+
{
81
+
//assume the entered X%
82
+
$tax_rate = $tax_rate / 100;
83
+
pmpro_setOption("tax_rate", $tax_rate);
84
+
}
85
+
86
+
//default settings
87
+
$gateway_environment = get_option("pmpro_gateway_environment");
88
+
if(empty($gateway_environment))
89
+
{
90
+
$gateway_environment = "sandbox";
91
+
pmpro_setOption("gateway_environment", $gateway_environment);
92
+
}
93
+
94
+
// Get a list of all gateways with human readable names.
95
+
$pmpro_gateways = pmpro_gateways();
96
+
$deprecated_gateways = pmpro_get_deprecated_gateways();
97
+
98
+
require_once(dirname(__FILE__) . "/admin_header.php");
99
+
?>
100
+
101
+
<form action="" method="post" enctype="multipart/form-data">
102
+
<?php wp_nonce_field('savesettings', 'pmpro_paymentsettings_nonce');?>
103
+
<hr class="wp-header-end">
104
+
<?php
105
+
if ( empty( $gateway_class_name ) ) {
106
+
// Show the table of gateways and global settings.
107
+
?>
108
+
<h1><?php esc_html_e( 'Payment Settings', 'paid-memberships-pro' );?></h1>
109
+
<div id="global-settings" class="pmpro_section" data-visibility="shown" data-activated="true">
110
+
<div class="pmpro_section_toggle">
111
+
<button class="pmpro_section-toggle-button" type="button" aria-expanded="true">
112
+
<span class="dashicons dashicons-arrow-up-alt2"></span>
113
+
<?php esc_html_e( 'Global Settings', 'paid-memberships-pro' ); ?>
114
+
</button>
115
+
</div>
116
+
<div class="pmpro_section_inside">
117
+
<table class="form-table">
118
+
<tbody>
119
+
<tr>
120
+
<th scope="row" valign="top">
121
+
<label for="gateway"><?php esc_html_e( 'Payment Gateway', 'paid-memberships-pro' );?></label>
122
+
</th>
123
+
<td>
124
+
<select id="gateway" name="gateway">
125
+
<?php
126
+
foreach ( $pmpro_gateways as $gateway_slug => $gateway_name ) {
127
+
?>
128
+
<option value="<?php echo esc_attr( $gateway_slug );?>" <?php selected( pmpro_getOption( 'gateway' ), $gateway_slug ); ?>><?php echo esc_html( $gateway_name );?></option>
129
+
<?php
130
+
}
131
+
?>
132
+
</select>
133
+
<p class="description"><?php esc_html_e( 'Select the primary payment gateway for membership checkouts on this site. Before switching, ensure the selected gateway is fully configured for the chosen environment (live or test).', 'paid-memberships-pro' ); ?></p>
134
+
</td>
135
+
</tr>
136
+
<tr>
137
+
<th scope="row" valign="top">
138
+
<label for="gateway_environment"><?php esc_html_e( 'Gateway Environment', 'paid-memberships-pro' );?></label>
139
+
</th>
140
+
<td>
141
+
<select id="gateway_environment" name="gateway_environment">
142
+
<option value="sandbox" <?php if( $gateway_environment == "sandbox") { ?>selected="selected"<?php } ?>><?php esc_html_e('Sandbox/Testing', 'paid-memberships-pro' );?></option>
143
+
<option value="live" <?php if( $gateway_environment == "live") { ?>selected="selected"<?php } ?>><?php esc_html_e('Live/Production', 'paid-memberships-pro' );?></option>
144
+
</select>
145
+
<p class="description">
146
+
<?php esc_html_e( 'Most gateways have a sandbox (test) and live environment. You can test transactions using the sandbox.', 'paid-memberships-pro' ); ?>
147
+
<?php
148
+
$gateway_testing_link = '<a title="' . esc_attr__( 'Paid Memberships Pro - Testing Your Payment Gateway', 'paid-memberships-pro' ) . '" target="_blank" rel="nofollow noopener" href="https://www.paidmembershipspro.com/payment-testing/?utm_source=plugin&utm_medium=pmpro-paymentsettings&utm_campaign=documentation&utm_content=testing-your-payment-gateway">' . esc_html__( 'testing your payment gateway for more information', 'paid-memberships-pro' ) . '</a>';
149
+
// translators: %s: Link to Testing Your Payment Gateway doc.
150
+
printf( esc_html__('Gateway settings must be configured for each environment. Refer to our guide on %s.', 'paid-memberships-pro' ), $gateway_testing_link ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
151
+
?>
152
+
</p>
153
+
</td>
154
+
</tr>
155
+
</tbody>
156
+
</table>
157
+
<p class="submit">
158
+
<input name="savesettings" type="submit" class="button button-primary" value="<?php esc_attr_e('Save All Settings', 'paid-memberships-pro' );?>" />
159
+
</p>
160
+
</div> <!-- end pmpro_section_inside -->
161
+
</div> <!-- end pmpro_section -->
162
+
<div id="choose-gateway" class="pmpro_section" data-visibility="shown" data-activated="true">
163
+
<div class="pmpro_section_toggle">
164
+
<button class="pmpro_section-toggle-button" type="button" aria-expanded="true">
165
+
<span class="dashicons dashicons-arrow-up-alt2"></span>
166
+
<?php esc_html_e( 'Payment Gateway Settings', 'paid-memberships-pro' ); ?>
167
+
</button>
168
+
</div>
169
+
<div class="pmpro_section_inside">
170
+
<p>
171
+
<?php esc_html_e( 'Installed payment gateways are listed below. Select a gateway to manage settings in live or sandbox (test) mode.', 'paid-memberships-pro' ); ?>
172
+
<?php
173
+
$gateway_settings_link = '<a title="' . esc_attr__( 'Paid Memberships Pro - Payment Gateway Settings', 'paid-memberships-pro' ) . '" target="_blank" rel="nofollow noopener" href="https://www.paidmembershipspro.com/documentation/admin/payment-gateway-settings/?utm_source=plugin&utm_medium=pmpro-paymentsettings&utm_campaign=documentation&utm_content=payment-gateway-settings">' . esc_html__( 'Payment Gateway Settings', 'paid-memberships-pro' ) . '</a>';
174
+
// translators: %s: Link to Payment Gateway Settings doc.
175
+
printf( esc_html__('Learn more about %s.', 'paid-memberships-pro' ), $gateway_settings_link ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
176
+
?>
177
+
</p>
178
+
<table class="wp-list-table widefat striped">
179
+
<thead>
180
+
<tr>
181
+
<th class="manage-column column-gateway" scope="col">
182
+
<?php esc_html_e( 'Gateway', 'paid-memberships-pro' ); ?>
183
+
</th>
184
+
<th class="manage-column column-status" scope="col">
185
+
<?php esc_html_e( 'Status', 'paid-memberships-pro' ); ?>
186
+
</th>
187
+
<th class="manage-column column-description" scope="col">
188
+
<?php esc_html_e( 'Description', 'paid-memberships-pro' ); ?>
189
+
</th>
190
+
<th class="manage-column column-edit" scope="col">
191
+
<span class="screen-reader-text"><?php esc_html_e( 'Actions', 'paid-memberships-pro' );?></span>
192
+
</th>
193
+
</tr>
194
+
</thead>
195
+
<tbody>
196
+
<?php
197
+
foreach ( $pmpro_gateways as $gateway_slug => $gateway_name ) {
198
+
// Get information about what the gateway 'supports'.
199
+
$gateway_class_name = 'PMProGateway_' . $gateway_slug;
200
+
if ( class_exists( $gateway_class_name ) && method_exists( $gateway_class_name, 'supports' ) ) {
201
+
$gateway_instance = new $gateway_class_name();
202
+
}
203
+
204
+
// Add a description for the default gateway.
205
+
$gateway_description = $gateway_slug === '' ? esc_html__( 'This gateway is for membership sites with Free levels or for sites that accept payment offline. The default gateway is not connected to a live gateway environment and cannot accept payments.', 'paid-memberships-pro' ) : $gateway_description;
206
+
?>
207
+
<tr class="gateway gateway_<?php echo esc_attr( $gateway_slug );?>">
208
+
<td class="column-gateway">
209
+
<?php echo ! empty( $gateway_instance ) ? '<a href="' . esc_url( add_query_arg( array( 'page' => 'pmpro-paymentsettings', 'edit_gateway' => esc_attr( $gateway_slug ) ), admin_url( 'admin.php' ) ) ) . '">' . esc_html( $gateway_name ) . '</a>' : esc_html( $gateway_name ); ?>
210
+
</td>
211
+
<td class="column-status">
212
+
<?php
213
+
$gateway_status_html = pmpro_getOption( 'gateway' ) === $gateway_slug ? '<span class="pmpro_tag pmpro_tag-has_icon pmpro_tag-info">' . esc_html__( 'Enabled (Primary Gateway)', 'paid-memberships-pro' ) . '</span>' : esc_html__( '—', 'paid-memberships-pro' );
214
+
215
+
// Special Cases for Add Ons that add secondary gateways. These will be removed when core natively supports multiple gateways.
216
+
if (
217
+
( function_exists( 'pmproappe_pmpro_valid_gateways' ) && $gateway_slug === 'paypalexpress' ) || // Add PayPal Express Add On.
218
+
( defined( 'PMPROPBC_VER' ) && $gateway_slug === 'check' ) // Pay by Check Add On.
219
+
) {
220
+
// The Add On is active for the gateway being shown.
221
+
if ( pmpro_getOption( 'gateway' ) === $gateway_slug ) {
222
+
// If this is the primary gateway, add an alert.
223
+
$gateway_status_html = '<span class="pmpro_tag pmpro_tag-has_icon pmpro_tag-info">' . esc_html__( 'Enabled (Primary Gateway & via Add On)', 'paid-memberships-pro' ) . '</span>';
224
+
} else {
225
+
// Show this as a secondary gateway.
226
+
$gateway_status_html = '<span class="pmpro_tag pmpro_tag-has_icon pmpro_tag-info">' . esc_html__( 'Enabled (via Add On)', 'paid-memberships-pro' ) . '</span>';
227
+
}
228
+
}
229
+
230
+
// Special case for deprecated gateways.
231
+
if ( in_array( $gateway_slug, $deprecated_gateways, true ) && $gateway_slug === pmpro_getOption( 'gateway' ) ) {
232
+
$gateway_status_html = '<span class="pmpro_tag pmpro_tag-has_icon pmpro_tag-error">' . esc_html__( 'Enabled (Not Supported)', 'paid-memberships-pro' ) . '</span>';
233
+
}
234
+
235
+
echo wp_kses_post( $gateway_status_html );
236
+
?>
237
+
</td>
238
+
<td class="column-description">
239
+
<?php echo ! empty( $gateway_instance ) ? esc_html( $gateway_instance->get_description_for_gateway_settings() ) : esc_html__( '—', 'paid-memberships-pro' ); ?>
240
+
</td>
241
+
<td class="column-edit">
242
+
<?php echo ! empty( $gateway_instance ) ? '<a class="button button-secondary" href="' . esc_url( add_query_arg( array( 'page' => 'pmpro-paymentsettings', 'edit_gateway' => esc_attr( $gateway_slug ) ), admin_url( 'admin.php' ) ) ) . '">' . esc_html__( 'Edit Settings', 'paid-memberships-pro' ) . '</a>' : esc_html__( '—', 'paid-memberships-pro' ); ?>
243
+
</td>
244
+
</tr>
245
+
<?php
246
+
$gateway_class_name = '';
247
+
}
248
+
?>
249
+
</tbody>
250
+
</table>
251
+
<br />
252
+
<p>
253
+
<a target="_blank" rel="nofollow noopener" href="https://www.paidmembershipspro.com/add-on-category/payment/?utm_source=plugin&utm_medium=pmpro-paymentsettings&utm_campaign=add-ons&utm_content=other-payment-gateways"><?php esc_html_e( 'Discover other payment gateways available as Paid Memberships Pro Add Ons', 'paid-memberships-pro' ); ?></a>
254
+
</p>
255
+
</div> <!-- end pmpro_section_inside -->
256
+
</div> <!-- end pmpro_section -->
257
+
<div id="other-settings" class="pmpro_section" data-visibility="shown" data-activated="true">
258
+
<div class="pmpro_section_toggle">
259
+
<button class="pmpro_section-toggle-button" type="button" aria-expanded="true">
260
+
<span class="dashicons dashicons-arrow-up-alt2"></span>
261
+
<?php esc_html_e( 'Other Settings', 'paid-memberships-pro' ); ?>
262
+
</button>
263
+
</div>
264
+
<div class="pmpro_section_inside">
265
+
<table class="form-table">
266
+
<tbody>
267
+
<tr>
268
+
<th scope="row" valign="top">
269
+
<label for="currency"><?php esc_html_e('Currency', 'paid-memberships-pro' );?></label>
270
+
</th>
271
+
<td>
272
+
<select name="currency">
273
+
<?php
274
+
global $pmpro_currencies;
275
+
$currency = get_option( 'pmpro_currency' );
276
+
foreach($pmpro_currencies as $ccode => $cdescription)
277
+
{
278
+
if(is_array($cdescription))
279
+
$cdescription = $cdescription['name'];
280
+
?>
281
+
<option value="<?php echo esc_attr( $ccode ) ?>" <?php if($currency == $ccode) { ?>selected="selected"<?php } ?>><?php echo esc_html( $cdescription ); ?></option>
282
+
<?php
283
+
}
284
+
?>
285
+
</select>
286
+
<p class="description"><?php esc_html_e( 'Not all currencies will be supported by every gateway. Please check with your gateway.', 'paid-memberships-pro' ); ?></p>
287
+
</td>
288
+
</tr>
289
+
<tr>
290
+
<th scope="row" valign="top">
291
+
<label for="tax"><?php esc_html_e('Sales Tax', 'paid-memberships-pro' );?> (<?php esc_html_e('optional', 'paid-memberships-pro' );?>)</label>
292
+
</th>
293
+
<td>
294
+
<?php esc_html_e('Tax State', 'paid-memberships-pro' );?>:
295
+
<input type="text" id="tax_state" name="tax_state" value="<?php echo esc_attr($tax_state)?>" class="small-text" /> (<?php esc_html_e('abbreviation, e.g. "PA"', 'paid-memberships-pro' );?>)
296
+
<?php esc_html_e('Tax Rate', 'paid-memberships-pro' ); ?>:
297
+
<input type="text" id="tax_rate" name="tax_rate" size="10" value="<?php echo esc_attr($tax_rate)?>" class="small-text" /> (<?php esc_html_e('decimal, e.g. "0.06"', 'paid-memberships-pro' );?>)
298
+
<p class="description">
299
+
<?php
300
+
$filter_link = '<a target="_blank" rel="nofollow noopener" href="https://www.paidmembershipspro.com/non-us-taxes-paid-memberships-pro/?utm_source=plugin&utm_medium=pmpro-paymentsettings&utm_campaign=blog&utm_content=non-us-taxes-paid-memberships-pro">pmpro_tax filter</a>';
301
+
// translators: %s: A link to the docs for the pmpro_tax filter.
302
+
printf( esc_html__('US only. If values are given, tax will be applied for any members ordering from the selected state. For non-US or more complex tax rules, use the %s.', 'paid-memberships-pro' ), $filter_link ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
303
+
?>
304
+
</p>
305
+
</td>
306
+
</tr>
307
+
</tbody>
308
+
</table>
309
+
<?php
310
+
/**
311
+
* Fires after the Payment Settings form fields.
312
+
*
313
+
* @since 3.5
314
+
*/
315
+
do_action( 'pmpro_after_payment_settings' );
316
+
?>
317
+
<p class="submit">
318
+
<input name="savesettings" type="submit" class="button button-primary" value="<?php esc_attr_e( 'Save All Settings', 'paid-memberships-pro' ); ?>" />
319
+
</p>
320
+
</div> <!-- end pmpro_section_inside -->
321
+
</div> <!-- end pmpro_section -->
322
+
323
+
<?php
324
+
} else {
325
+
// Show the settings for a specific gateway.
326
+
?>
327
+
<h1 class="wp-heading-inline">
328
+
<?php
329
+
echo sprintf(
330
+
// translators: %s is the Level ID.
331
+
esc_html__('Edit Payment Gateway: %s', 'paid-memberships-pro'),
332
+
esc_html( $pmpro_gateways[ $edit_gateway ] )
333
+
);
334
+
?>
335
+
</h1>
336
+
<?php
337
+
// If this gateway is deprecated, show a warning.
338
+
if ( in_array( $edit_gateway, $deprecated_gateways, true ) ) {
339
+
?>
340
+
<div class="pmpro_message pmpro_error">
341
+
<p><strong><?php esc_html_e('Notice: You Are Using a Deprecated Gateway', 'paid-memberships-pro' ); ?></strong></p>
342
+
<p>
343
+
<?php
344
+
// translators: %s is the gateway name.
345
+
printf(
346
+
esc_html__('The %s gateway has been deprecated and will not receive updates or support. To ensure your payments continue running smoothly, switch to a supported payment gateway.', 'paid-memberships-pro'),
347
+
esc_html( $pmpro_gateways[ $edit_gateway ] )
348
+
);
349
+
?>
350
+
</p>
351
+
<p>
352
+
<a class="button button-secondary" href="https://www.paidmembershipspro.com/documentation/compatibility/incompatible-deprecated-add-ons/?utm_source=plugin&utm_medium=pmpro-paymentsettings&utm_campaign=documentation&utm_content=deprecated-gateways#deprecated-payment-gateways" target="_blank" rel="nofollow noopener"><?php esc_html_e('About Deprecated Gateways', 'paid-memberships-pro' ); ?></a>
353
+
<a class="button" href="https://www.paidmembershipspro.com/switching-payment-gateways/?utm_source=plugin&utm_medium=pmpro-paymentsettings&utm_campaign=blog&utm_content=switching-payment-gateways" target="_blank" rel="nofollow noopener"><?php esc_html_e('How to Switch Payment Gateways', 'paid-memberships-pro' ); ?></a>
354
+
</p>
355
+
</div>
356
+
<?php
357
+
}
358
+
359
+
// Show the settings for the specific gateway.
360
+
call_user_func( array( $gateway_class_name, 'show_settings_fields' ) );
361
+
?>
362
+
<p class="submit">
363
+
<input name="savesettings" type="submit" class="button button-primary" value="<?php esc_attr_e('Save Settings', 'paid-memberships-pro' );?>" />
364
+
<a href="<?php echo esc_url( add_query_arg( array( 'page' => 'pmpro-paymentsettings' ), admin_url( 'admin.php' ) ) ); ?>" class="button button-secondary"><?php esc_html_e( 'Cancel', 'paid-memberships-pro' ); ?></a>
365
+
</p>
366
+
<?php
367
+
}
368
+
?>
369
+
</form>
370
+
371
+
<?php
372
+
require_once(dirname(__FILE__) . "/admin_footer.php");
373
+
?>
374
+