/** * Process an update card form request * * @access private * @since 2.6 */ function rcp_paypal_update_billing_card($member_id = 0, $member_obj) { global $rcp_options; if (empty($member_id)) { return; } if (!is_a($member_obj, 'RCP_Member')) { return; } if (!rcp_is_paypal_subscriber($member_id)) { return; } if (rcp_is_sandbox()) { $api_endpoint = 'https://api-3t.sandbox.paypal.com/nvp'; } else { $api_endpoint = 'https://api-3t.paypal.com/nvp'; } $error = ''; $customer_id = $member_obj->get_payment_profile_id(); $credentials = rcp_get_paypal_api_credentials(); $card_number = isset($_POST['rcp_card_number']) && is_numeric($_POST['rcp_card_number']) ? $_POST['rcp_card_number'] : ''; $card_exp_month = isset($_POST['rcp_card_exp_month']) && is_numeric($_POST['rcp_card_exp_month']) ? $_POST['rcp_card_exp_month'] : ''; $card_exp_year = isset($_POST['rcp_card_exp_year']) && is_numeric($_POST['rcp_card_exp_year']) ? $_POST['rcp_card_exp_year'] : ''; $card_cvc = isset($_POST['rcp_card_cvc']) && is_numeric($_POST['rcp_card_cvc']) ? $_POST['rcp_card_cvc'] : ''; $card_zip = isset($_POST['rcp_card_zip']) ? sanitize_text_field($_POST['rcp_card_zip']) : ''; if (empty($card_number) || empty($card_exp_month) || empty($card_exp_year) || empty($card_cvc) || empty($card_zip)) { $error = __('Please enter all required fields.', 'rcp'); } if (empty($error)) { $args = array('USER' => $credentials['username'], 'PWD' => $credentials['password'], 'SIGNATURE' => $credentials['signature'], 'VERSION' => '124', 'METHOD' => 'UpdateRecurringPaymentsProfile', 'PROFILEID' => $customer_id, 'ACCT' => $card_number, 'EXPDATE' => $card_exp_month . $card_exp_year, 'CVV2' => $card_cvc, 'ZIP' => $card_zip, 'BUTTONSOURCE' => 'EasyDigitalDownloads_SP'); $request = wp_remote_post($api_endpoint, array('timeout' => 45, 'sslverify' => false, 'body' => $args, 'httpversion' => '1.1')); $body = wp_remote_retrieve_body($request); $code = wp_remote_retrieve_response_code($request); $message = wp_remote_retrieve_response_message($request); if (is_wp_error($request)) { $error = $request->get_error_message(); } elseif (200 == $code && 'OK' == $message) { if (is_string($body)) { $body = wp_parse_str($body, $body); } if ('failure' === strtolower($body['ACK'])) { $error = $body['L_ERRORCODE0'] . ': ' . $body['L_LONGMESSAGE0']; } else { // Request was successful, but verify the profile ID that came back matches if ($customer_id !== $body['PROFILEID']) { $error = __('Error updating subscription', 'rcp'); } } } else { $error = __('Something has gone wrong, please try again', 'rcp'); } } if (!empty($error)) { wp_redirect(add_query_arg(array('card' => 'not-updated', 'msg' => urlencode($error)))); exit; } wp_redirect(add_query_arg(array('card' => 'updated', 'msg' => ''))); exit; }
/** * Cancel a 2checkout subscriber * * @access private * @since 2.4 */ function rcp_2checkout_cancel_member($member_id = 0) { global $rcp_options; $user_name = defined('TWOCHECKOUT_ADMIN_USER') ? TWOCHECKOUT_ADMIN_USER : ''; $password = defined('TWOCHECKOUT_ADMIN_PASSWORD') ? TWOCHECKOUT_ADMIN_PASSWORD : ''; if (empty($user_name) || empty($password)) { return new WP_Error('missing_username_or_password', __('The 2Checkout API username and password must be defined', 'rcp')); } if (!class_exists('Twocheckout')) { require_once RCP_PLUGIN_DIR . 'includes/libraries/twocheckout/Twocheckout.php'; } $secret_word = rcp_is_sandbox() ? trim($rcp_options['twocheckout_secret_word']) : ''; $test_mode = rcp_is_sandbox(); if ($test_mode) { $secret_key = isset($rcp_options['twocheckout_test_private']) ? trim($rcp_options['twocheckout_test_private']) : ''; $publishable_key = isset($rcp_options['twocheckout_test_publishable']) ? trim($rcp_options['twocheckout_test_publishable']) : ''; $seller_id = isset($rcp_options['twocheckout_test_seller_id']) ? trim($rcp_options['twocheckout_test_seller_id']) : ''; $environment = 'sandbox'; } else { $secret_key = isset($rcp_options['twocheckout_live_private']) ? trim($rcp_options['twocheckout_live_private']) : ''; $publishable_key = isset($rcp_options['twocheckout_live_publishable']) ? trim($rcp_options['twocheckout_live_publishable']) : ''; $seller_id = isset($rcp_options['twocheckout_live_seller_id']) ? trim($rcp_options['twocheckout_live_seller_id']) : ''; $environment = 'production'; } try { Twocheckout::privateKey($secret_key); Twocheckout::sellerId($seller_id); Twocheckout::username(TWOCHECKOUT_ADMIN_USER); Twocheckout::password(TWOCHECKOUT_ADMIN_PASSWORD); Twocheckout::sandbox($test_mode); $member = new RCP_Member($member_id); $sale_id = str_replace('2co_', '', $member->get_payment_profile_id()); $cancelled = Twocheckout_Sale::stop(array('sale_id' => $sale_id)); if ($cancelled['response_code'] == 'OK') { return true; } } catch (Twocheckout_Error $e) { return new WP_Error('2checkout_cancel_failed', $e->getMessage()); } }
public function __construct($subscription_data = array()) { $this->test_mode = rcp_is_sandbox(); $this->init(); if (!empty($subscription_data)) { $this->email = $subscription_data['user_email']; $this->user_id = $subscription_data['user_id']; $this->user_name = $subscription_data['user_name']; $this->currency = $subscription_data['currency']; $this->amount = $subscription_data['price']; $this->initial_amount = $subscription_data['price'] + $subscription_data['fee']; $this->discount = $subscription_data['discount']; $this->discount_code = $subscription_data['discount_code']; $this->length = $subscription_data['length']; $this->length_unit = $subscription_data['length_unit']; $this->signup_fee = $this->supports('fees') ? $subscription_data['fee'] : 0; $this->subscription_key = $subscription_data['key']; $this->subscription_id = $subscription_data['subscription_id']; $this->subscription_name = $subscription_data['subscription_name']; $this->auto_renew = $this->supports('recurring') ? $subscription_data['auto_renew'] : false; $this->return_url = $subscription_data['return_url']; } }
/** * Cancel a member's payment profile * * @access public * @since 2.1 */ function rcp_cancel_member_payment_profile($member_id = 0, $set_status = true) { global $rcp_options; $success = false; $member = new RCP_Member($member_id); if (!rcp_can_member_cancel($member_id)) { return $success; } if (rcp_is_stripe_subscriber($member_id)) { if (!class_exists('Stripe\\Stripe')) { require_once RCP_PLUGIN_DIR . 'includes/libraries/stripe/init.php'; } if (rcp_is_sandbox()) { $secret_key = trim($rcp_options['stripe_test_secret']); } else { $secret_key = trim($rcp_options['stripe_live_secret']); } \Stripe\Stripe::setApiKey($secret_key); try { $subscription_id = $member->get_merchant_subscription_id(); $customer = \Stripe\Customer::retrieve($member->get_payment_profile_id()); if (!empty($subscription_id)) { $customer->subscriptions->retrieve($subscription_id)->cancel(array('at_period_end' => false)); } else { $customer->cancelSubscription(array('at_period_end' => false)); } $success = true; } catch (\Stripe\Error\InvalidRequest $e) { // Invalid parameters were supplied to Stripe's API $body = $e->getJsonBody(); $err = $body['error']; $error = "<h4>" . __('An error occurred', 'rcp') . "</h4>"; if (isset($err['code'])) { $error .= "<p>" . __('Error code:', 'rcp') . " " . $err['code'] . "</p>"; } $error .= "<p>Status: " . $e->getHttpStatus() . "</p>"; $error .= "<p>Message: " . $err['message'] . "</p>"; wp_die($error, __('Error', 'rcp'), array('response' => 401)); } catch (\Stripe\Error\Authentication $e) { // Authentication with Stripe's API failed // (maybe you changed API keys recently) $body = $e->getJsonBody(); $err = $body['error']; $error = "<h4>" . __('An error occurred', 'rcp') . "</h4>"; if (isset($err['code'])) { $error .= "<p>" . __('Error code:', 'rcp') . " " . $err['code'] . "</p>"; } $error .= "<p>Status: " . $e->getHttpStatus() . "</p>"; $error .= "<p>Message: " . $err['message'] . "</p>"; wp_die($error, __('Error', 'rcp'), array('response' => 401)); } catch (\Stripe\Error\ApiConnection $e) { // Network communication with Stripe failed $body = $e->getJsonBody(); $err = $body['error']; $error = "<h4>" . __('An error occurred', 'rcp') . "</h4>"; if (isset($err['code'])) { $error .= "<p>" . __('Error code:', 'rcp') . " " . $err['code'] . "</p>"; } $error .= "<p>Status: " . $e->getHttpStatus() . "</p>"; $error .= "<p>Message: " . $err['message'] . "</p>"; wp_die($error, __('Error', 'rcp'), array('response' => 401)); } catch (\Stripe\Error\Base $e) { // Display a very generic error to the user $body = $e->getJsonBody(); $err = $body['error']; $error = "<h4>" . __('An error occurred', 'rcp') . "</h4>"; if (isset($err['code'])) { $error .= "<p>" . __('Error code:', 'rcp') . " " . $err['code'] . "</p>"; } $error .= "<p>Status: " . $e->getHttpStatus() . "</p>"; $error .= "<p>Message: " . $err['message'] . "</p>"; wp_die($error, __('Error', 'rcp'), array('response' => 401)); } catch (Exception $e) { // Something else happened, completely unrelated to Stripe $error = "<h4>" . __('An error occurred', 'rcp') . "</h4>"; $error .= print_r($e, true); wp_die($error, __('Error', 'rcp'), array('response' => 401)); } } elseif (rcp_is_paypal_subscriber($member_id)) { if (rcp_has_paypal_api_access() && $member->get_payment_profile_id()) { // Set PayPal API key credentials. $api_username = rcp_is_sandbox() ? 'test_paypal_api_username' : 'live_paypal_api_username'; $api_password = rcp_is_sandbox() ? 'test_paypal_api_password' : 'live_paypal_api_password'; $api_signature = rcp_is_sandbox() ? 'test_paypal_api_signature' : 'live_paypal_api_signature'; $api_endpoint = rcp_is_sandbox() ? 'https://api-3t.sandbox.paypal.com/nvp' : 'https://api-3t.paypal.com/nvp'; $args = array('USER' => trim($rcp_options[$api_username]), 'PWD' => trim($rcp_options[$api_password]), 'SIGNATURE' => trim($rcp_options[$api_signature]), 'VERSION' => '124', 'METHOD' => 'ManageRecurringPaymentsProfileStatus', 'PROFILEID' => $member->get_payment_profile_id(), 'ACTION' => 'Cancel'); $error_msg = ''; $request = wp_remote_post($api_endpoint, array('body' => $args, 'timeout' => 30, 'httpversion' => '1.1')); if (is_wp_error($request)) { $success = false; $error_msg = $request->get_error_message(); } else { $body = wp_remote_retrieve_body($request); $code = wp_remote_retrieve_response_code($request); $message = wp_remote_retrieve_response_message($request); if (is_string($body)) { wp_parse_str($body, $body); } if (200 !== (int) $code) { $success = false; } if ('OK' !== $message) { $success = false; } if (isset($body['ACK']) && 'success' === strtolower($body['ACK'])) { $success = true; } else { $success = false; if (isset($body['L_LONGMESSAGE0'])) { $error_msg = $body['L_LONGMESSAGE0']; } } } if (!$success) { wp_die(sprintf(__('There was a problem cancelling the subscription, please contact customer support. Error: %s', 'rcp'), $error_msg), array('response' => 400)); } } } elseif (rcp_is_2checkout_subscriber($member_id)) { $cancelled = rcp_2checkout_cancel_member($member_id); if (is_wp_error($cancelled)) { wp_die($cancelled->get_error_message(), __('Error', 'rcp'), array('response' => 401)); } else { $success = true; } } if ($success && $set_status) { $member->cancel(); } return $success; }
/** * Displays stripe checkout form * * @since 2.5 * @access public * * @param $atts * @return mixed|void */ function rcp_register_form_stripe_checkout($atts) { global $rcp_options; if (empty($atts['id'])) { return ''; } // button is an alias for data-label if (isset($atts['button'])) { $atts['data-label'] = $atts['button']; } $key = rcp_is_sandbox() ? $rcp_options['stripe_test_publishable'] : $rcp_options['stripe_live_publishable']; $member = new RCP_Member(wp_get_current_user()->ID); $subscription = rcp_get_subscription_details($atts['id']); $amount = $subscription->price + $subscription->fee; if ($member->ID > 0) { $amount -= $member->get_prorate_credit_amount(); } if ($amount < 0) { $amount = 0; } $data = wp_parse_args($atts, array('id' => 0, 'data-key' => $key, 'data-name' => get_option('blogname'), 'data-description' => $subscription->description, 'data-label' => sprintf(__('Join %s', 'rcp'), $subscription->name), 'data-panel-label' => __('Register - {{amount}}', 'rcp'), 'data-amount' => $amount * rcp_stripe_get_currency_multiplier(), 'data-locale' => 'auto', 'data-allow-remember-me' => true, 'data-currency' => rcp_get_currency(), 'data-alipay' => isset($rcp_options['stripe_alipay']) && '1' === $rcp_options['stripe_alipay'] && 'USD' === rcp_get_currency() ? 'true' : 'false')); if (empty($data['data-email']) && !empty($member->user_email)) { $data['data-email'] = $member->user_email; } if (empty($data['data-image']) && ($image = get_site_icon_url())) { $data['data-image'] = $image; } $data = apply_filters('rcp_stripe_checkout_data', $data); if ('USD' !== rcp_get_currency()) { unset($data['data-alipay']); } ob_start(); if ($member->ID > 0 && $member->get_subscription_id() == $subscription->id && $member->is_active()) { ?> <div class="rcp-stripe-checkout-notice"><?php _e('You are already subscribed.', 'rcp'); ?> </div> <?php } else { ?> <form action="" method="post"> <?php do_action('register_form_stripe_fields', $data); ?> <script src="https://checkout.stripe.com/checkout.js" class="stripe-button" <?php foreach ($data as $label => $value) { printf(' %s="%s" ', esc_attr($label), esc_attr($value)); } ?> ></script> <input type="hidden" name="rcp_level" value="<?php echo $subscription->id; ?> " /> <input type="hidden" name="rcp_register_nonce" value="<?php echo wp_create_nonce('rcp-register-nonce'); ?> "/> <input type="hidden" name="rcp_gateway" value="stripe_checkout"/> <input type="hidden" name="rcp_stripe_checkout" value="1"/> </form> <?php } return apply_filters('register_form_stripe', ob_get_clean(), $atts); }
/** * Query Stripe API to get customer's card details * * @param $card array * @param $member_id int * @param $member object * * @since 2.5 * @return array */ function rcp_stripe_get_card_details($cards, $member_id, $member) { global $rcp_options; if (!rcp_is_stripe_subscriber($member_id)) { return $cards; } if (!class_exists('Stripe\\Stripe')) { require_once RCP_PLUGIN_DIR . 'includes/libraries/stripe/init.php'; } if (rcp_is_sandbox()) { $secret_key = trim($rcp_options['stripe_test_secret']); } else { $secret_key = trim($rcp_options['stripe_live_secret']); } \Stripe\Stripe::setApiKey($secret_key); try { $customer = \Stripe\Customer::retrieve($member->get_payment_profile_id()); $default = $customer->sources->retrieve($customer->default_source); $cards['stripe']['name'] = $default->name; $cards['stripe']['type'] = $default->brand; $cards['stripe']['zip'] = $default->address_zip; $cards['stripe']['exp_month'] = $default->exp_month; $cards['stripe']['exp_year'] = $default->exp_year; $cards['stripe']['last4'] = $default->last4; } catch (Exception $e) { } return $cards; }
/** * Displays the system info report * * @since 2.5 * @return string $return The compiled system info report. */ function rcp_tools_system_info_report() { global $rcp_options, $wpdb; // Get theme info $theme_data = wp_get_theme(); $theme = $theme_data->Name . ' ' . $theme_data->Version; $return = '### Begin System Info ###' . "\n\n"; // Start with the basics... $return .= '-- Site Info' . "\n\n"; $return .= 'Site URL: ' . site_url() . "\n"; $return .= 'Home URL: ' . home_url() . "\n"; $return .= 'Multisite: ' . (is_multisite() ? 'Yes' : 'No') . "\n"; // WordPress configuration $return .= "\n" . '-- WordPress Configuration' . "\n\n"; $return .= 'Version: ' . get_bloginfo('version') . "\n"; $return .= 'Language: ' . (defined('WPLANG') && WPLANG ? WPLANG : 'en_US') . "\n"; $return .= 'Permalink Structure: ' . (get_option('permalink_structure') ? get_option('permalink_structure') : 'Default') . "\n"; $return .= 'Active Theme: ' . $theme . "\n"; $return .= 'Show On Front: ' . get_option('show_on_front') . "\n"; // Only show page specs if frontpage is set to 'page' if (get_option('show_on_front') === 'page') { $front_page_id = get_option('page_on_front'); $blog_page_id = get_option('page_for_posts'); $return .= 'Page On Front: ' . ($front_page_id != 0 ? get_the_title($front_page_id) . ' (#' . $front_page_id . ')' : 'Unset') . "\n"; $return .= 'Page For Posts: ' . ($blog_page_id != 0 ? get_the_title($blog_page_id) . ' (#' . $blog_page_id . ')' : 'Unset') . "\n"; } $return .= 'ABSPATH: ' . ABSPATH . "\n"; $return .= 'Table Prefix: ' . 'Length: ' . strlen($wpdb->prefix) . ' Status: ' . (strlen($wpdb->prefix) > 16 ? 'ERROR: Too long' : 'Acceptable') . "\n"; $return .= 'WP_DEBUG: ' . (defined('WP_DEBUG') ? WP_DEBUG ? 'Enabled' : 'Disabled' : 'Not set') . "\n"; $return .= 'Memory Limit: ' . WP_MEMORY_LIMIT . "\n"; $return .= 'Registered Post Stati: ' . implode(', ', get_post_stati()) . "\n"; // RCP Config $auto_renew_options = array(1 => 'Always auto renew', 2 => 'Never auto renew', 3 => 'Let customer choose whether to auto renew'); $return .= "\n" . '-- RCP Configuration' . "\n\n"; $return .= 'Version: ' . RCP_PLUGIN_VERSION . "\n"; $return .= 'License Key: ' . (!empty($rcp_options['license_key']) ? $rcp_options['license_key'] . "\n" : "Not set\n"); $return .= 'Auto Renew: ' . (!empty($rcp_options['auto_renew']) && array_key_exists($rcp_options['auto_renew'], $auto_renew_options) ? $auto_renew_options[$rcp_options['auto_renew']] . "\n" : "Invalid Configuration\n"); $return .= 'Currency: ' . (!empty($rcp_options['currency']) ? $rcp_options['currency'] . "\n" : "Invalid Configuration\n"); $return .= 'Currency Position: ' . (!empty($rcp_options['currency_position']) ? $rcp_options['currency_position'] . "\n" : "Invalid Configuration\n"); $return .= 'Sandbox Mode: ' . (rcp_is_sandbox() ? "True" . "\n" : "False\n"); // RCP pages $return .= "\n" . '-- RCP Page Configuration' . "\n\n"; $return .= 'Registration Page: ' . (!empty($rcp_options['registration_page']) ? get_permalink($rcp_options['registration_page']) . "\n" : "Unset\n"); $return .= 'Success Page: ' . (!empty($rcp_options['redirect']) ? get_permalink($rcp_options['redirect']) . "\n" : "Unset\n"); $return .= 'Account Page: ' . (!empty($rcp_options['account_page']) ? get_permalink($rcp_options['account_page']) . "\n" : "Unset\n"); $return .= 'Edit Profile Page: ' . (!empty($rcp_options['edit_profile']) ? get_permalink($rcp_options['edit_profile']) . "\n" : "Unset\n"); $return .= 'Update Billing Card Page: ' . (!empty($rcp_options['update_card']) ? get_permalink($rcp_options['update_card']) . "\n" : "Unset\n"); // RCP gateways $return .= "\n" . '-- RCP Gateway Configuration' . "\n\n"; $active_gateways = rcp_get_enabled_payment_gateways(); if ($active_gateways) { $gateways = array(); foreach ($active_gateways as $key => $label) { $gateways[] = $label . ' (' . $key . ')'; } $return .= 'Enabled Gateways: ' . implode(', ', $gateways) . "\n"; } else { $return .= 'Enabled Gateways: None' . "\n"; } // RCP Misc Settings $return .= "\n" . '-- RCP Misc Settings' . "\n\n"; $return .= 'Hide Premium Posts: ' . (!empty($rcp_options['hide_premium']) ? "True\n" : "False\n"); $return .= 'Redirect Page: ' . (!empty($rcp_options['redirect_from_premium']) ? get_permalink($rcp_options['redirect_from_premium']) . "\n" : "Unset\n"); $return .= 'Redirect Default Login URL ' . (!empty($rcp_options['hijack_login_url']) ? "True\n" : "False\n"); $return .= 'Login Page: ' . (!empty($rcp_options['login_redirect']) ? get_permalink($rcp_options['login_redirect']) . "\n" : "Unset\n"); $return .= 'Prevent Account Sharing: ' . (!empty($rcp_options['no_login_sharing']) ? "True\n" : "False\n"); $return .= 'Email IPN Reports: ' . (!empty($rcp_options['email_ipn_reports']) ? "True\n" : "False\n"); $return .= 'Disable Form CSS: ' . (!empty($rcp_options['disable_css']) ? "True\n" : "False\n"); $return .= 'Enable reCaptcha: ' . (!empty($rcp_options['enable_recaptcha']) ? "True\n" : "False\n"); $return .= 'reCaptcha Site Key: ' . (!empty($rcp_options['recaptcha_public_key']) ? "Set\n" : "Unset\n"); $return .= 'reCaptcha Secret Key: ' . (!empty($rcp_options['recaptcha_private_key']) ? "Set\n" : "Unset\n"); // RCP Templates $dir = get_stylesheet_directory() . '/rcp/'; if (is_dir($dir) && count(glob("{$dir}/*")) !== 0) { $return .= "\n" . '-- RCP Template Overrides' . "\n\n"; foreach (glob($dir . '/*') as $file) { $return .= 'Filename: ' . basename($file) . "\n"; } } // Get plugins that have an update $updates = get_plugin_updates(); // Must-use plugins // NOTE: MU plugins can't show updates! $muplugins = get_mu_plugins(); if (count($muplugins > 0)) { $return .= "\n" . '-- Must-Use Plugins' . "\n\n"; foreach ($muplugins as $plugin => $plugin_data) { $return .= $plugin_data['Name'] . ': ' . $plugin_data['Version'] . "\n"; } } // WordPress active plugins $return .= "\n" . '-- WordPress Active Plugins' . "\n\n"; $plugins = get_plugins(); $active_plugins = get_option('active_plugins', array()); foreach ($plugins as $plugin_path => $plugin) { if (!in_array($plugin_path, $active_plugins)) { continue; } $update = array_key_exists($plugin_path, $updates) ? ' (needs update - ' . $updates[$plugin_path]->update->new_version . ')' : ''; $return .= $plugin['Name'] . ': ' . $plugin['Version'] . $update . "\n"; } // WordPress inactive plugins $return .= "\n" . '-- WordPress Inactive Plugins' . "\n\n"; foreach ($plugins as $plugin_path => $plugin) { if (in_array($plugin_path, $active_plugins)) { continue; } $update = array_key_exists($plugin_path, $updates) ? ' (needs update - ' . $updates[$plugin_path]->update->new_version . ')' : ''; $return .= $plugin['Name'] . ': ' . $plugin['Version'] . $update . "\n"; } if (is_multisite()) { // WordPress Multisite active plugins $return .= "\n" . '-- Network Active Plugins' . "\n\n"; $plugins = wp_get_active_network_plugins(); $active_plugins = get_site_option('active_sitewide_plugins', array()); foreach ($plugins as $plugin_path) { $plugin_base = plugin_basename($plugin_path); if (!array_key_exists($plugin_base, $active_plugins)) { continue; } $update = array_key_exists($plugin_path, $updates) ? ' (needs update - ' . $updates[$plugin_path]->update->new_version . ')' : ''; $plugin = get_plugin_data($plugin_path); $return .= $plugin['Name'] . ': ' . $plugin['Version'] . $update . "\n"; } } // Server configuration (really just versioning) $return .= "\n" . '-- Webserver Configuration' . "\n\n"; $return .= 'PHP Version: ' . PHP_VERSION . "\n"; $return .= 'MySQL Version: ' . $wpdb->db_version() . "\n"; $return .= 'Webserver Info: ' . $_SERVER['SERVER_SOFTWARE'] . "\n"; // PHP configuration $return .= "\n" . '-- PHP Configuration' . "\n\n"; $return .= 'Safe Mode: ' . (ini_get('safe_mode') ? 'Enabled' : 'Disabled' . "\n"); $return .= 'Memory Limit: ' . ini_get('memory_limit') . "\n"; $return .= 'Upload Max Size: ' . ini_get('upload_max_filesize') . "\n"; $return .= 'Post Max Size: ' . ini_get('post_max_size') . "\n"; $return .= 'Upload Max Filesize: ' . ini_get('upload_max_filesize') . "\n"; $return .= 'Time Limit: ' . ini_get('max_execution_time') . "\n"; $return .= 'Max Input Vars: ' . ini_get('max_input_vars') . "\n"; $return .= 'Display Errors: ' . (ini_get('display_errors') ? 'On (' . ini_get('display_errors') . ')' : 'N/A') . "\n"; // PHP extensions and such $return .= "\n" . '-- PHP Extensions' . "\n\n"; $return .= 'cURL: ' . (function_exists('curl_init') ? 'Supported' : 'Not Supported') . "\n"; $return .= 'fsockopen: ' . (function_exists('fsockopen') ? 'Supported' : 'Not Supported') . "\n"; $return .= 'SOAP Client: ' . (class_exists('SoapClient') ? 'Installed' : 'Not Installed') . "\n"; $return .= 'Suhosin: ' . (extension_loaded('suhosin') ? 'Installed' : 'Not Installed') . "\n"; $return .= "\n" . '### End System Info ###'; return $return; }
function test_rcp_is_sandbox() { $this->assertFalse(rcp_is_sandbox()); add_filter('rcp_is_sandbox', '__return_true'); $this->assertTrue(rcp_is_sandbox()); }
/** * Retrieve the full HTML link for the transaction ID on the merchant site * * @access public * @param $payment Payment object * @since 2.6 */ function rcp_get_merchant_transaction_id_link($payment) { global $rcp_options; $url = ''; $link = $payment->transaction_id; $test = rcp_is_sandbox(); if (!empty($payment->transaction_id)) { $type = strtolower($payment->payment_type); switch ($type) { case 'web_accept': case 'paypal express one time': case 'recurring_payment': case 'subscr_payment': case 'recurring_payment_profile_created': // PayPal $mode = $test ? 'sandbox.' : ''; $url = 'https://www.' . $mode . 'paypal.com/webscr?cmd=_history-details-from-hub&id=' . $payment->transaction_id; break; case 'credit card': case 'credit card one time': if (false !== strpos($payment->transaction_id, 'ch_')) { // Stripe $mode = $test ? 'test/' : ''; $url = 'https://dashboard.stripe.com/' . $mode . 'payments/' . $payment->transaction_id; } else { if (is_numeric($payment->transaction_id)) { // 2Checkout $mode = $test ? 'sandbox.' : ''; $url = 'https://' . $mode . '2checkout.com/sandbox/sales/detail?sale_id=' . $payment->transaction_id; } } break; } if (!empty($url)) { $link = '<a href="' . esc_url($url) . '" class="rcp-payment-txn-id-link" target="_blank">' . $payment->transaction_id . '</a>'; } } return apply_filters('rcp_merchant_transaction_id_link', $link, $payment); }