updated plugin Easy Digital Downloads version 3.1.4

This commit is contained in:
2023-07-19 21:08:59 +00:00
committed by Gitium
parent a7f6efbebb
commit 9a42dc17d2
109 changed files with 12446 additions and 5563 deletions

View File

@ -506,7 +506,7 @@ function get_account_info() {
wp_send_json_success( array(
'status' => $status,
'account_status' => '<ul class="edd-paypal-account-status">' . $account_status . '</ul>',
'account_status' => '<ul class="edd-paypal-account-status edd-settings__list--disc">' . $account_status . '</ul>',
'webhook_object' => isset( $validator ) ? $validator->webhook : null,
'actions' => array_values( $actions ),
'disconnect_links' => array_values( $disconnect_links ),

View File

@ -3,7 +3,7 @@
* Plugin Name: Easy Digital Downloads - Stripe Pro Payment Gateway
* Plugin URI: https://easydigitaldownloads.com/downloads/stripe-gateway/
* Description: Adds support for pre-authorized credit card payments and removes additional transaction fees.
* Version: 2.9.5.1
* Version: 2.9.6
* Requires at least: 5.4
* Requires PHP: 7.1
* Author: Easy Digital Downloads
@ -44,7 +44,7 @@ function edd_stripe_core_bootstrap() {
}
if ( ! defined( 'EDD_STRIPE_VERSION' ) ) {
define( 'EDD_STRIPE_VERSION', '2.9.5.1' );
define( 'EDD_STRIPE_VERSION', '2.9.6' );
}
if ( ! defined( 'EDD_STRIPE_API_VERSION' ) ) {

View File

@ -161,8 +161,10 @@ function edds_add_settings( $settings ) {
'id' => 'stripe_allow_prepaid_elements_note',
'name' => __( 'Prepaid Cards', 'easy-digital-downloads' ),
'desc' => sprintf(
__( 'Prepaid card allowance can now be managed in your <a href="%s" target="_blank">Stripe Radar Rules</a>.', 'easy-digital-downloads' ),
$radar_rules_url
/* translators: %1$s Opening anchor tag, do not translate. %2$s Closing anchor tag, do not translate. */
__( 'Prepaid card allowance can now be managed in your %1$sStripe Radar Rules%2$s.', 'easy-digital-downloads' ),
'<a href="' . $radar_rules_url . '" target="_blank">',
'</a>'
),
'type' => 'descriptive_text',
'class' => 'payment-elements' === $elements_mode ? 'payment-elements-feature' : 'edd-hidden payment-elements-feature',
@ -188,8 +190,10 @@ function edds_add_settings( $settings ) {
'id' => 'stripe_use_existing_cards_elements_note',
'name' => __( 'Show Previously Used Cards', 'easy-digital-downloads' ),
'desc' => sprintf(
__( 'Previously used cards are now managed by <a href="%s" target="_blank">Link by Stripe</a>, for even better conversions and security.', 'easy-digital-downloads' ),
'https://link.co/'
/* translators: %1$s Opening anchor tag, do not translate. %2$s Closing anchor tag, do not translate. */
__( 'Previously used cards are now managed by %1$sLink by Stripe%2$s, for even better conversions and security.', 'easy-digital-downloads' ),
'<a href="https://link.co/" target="_blank">',
'</a>'
),
'type' => 'descriptive_text',
'class' => 'payment-elements' === $elements_mode ? 'payment-elements-feature' : 'edd-hidden payment-elements-feature',
@ -353,7 +357,7 @@ function edd_stripe_requirements_not_met_callback() {
echo '<p>';
echo wp_kses(
sprintf(
/* translators: %1$s Future PHP version requirement. %2$s Current PHP version. %3$s Opening strong tag, do not translate. %4$s Closing strong tag, do not translate. */
/* translators: %1$s PHP version requirement. %2$s Current PHP version. %3$s Opening strong tag, do not translate. %4$s Closing strong tag, do not translate. */
__(
'Processing credit cards with Stripe requires PHP version %1$s or higher. It looks like you\'re using version %2$s, which means you will need to %3$supgrade your version of PHP before acceping credit card payments%4$s.',
'easy-digital-downloads'

View File

@ -568,9 +568,9 @@ function edds_stripe_connect_account_info_ajax_response() {
)
. ' ' .
sprintf(
/** Translators: Replacements are for the html wrappers for the phrse Upgrade to Pro and should not be translated. */
esc_html__(
'%sUpgrade to Pro%s and install the Stripe Pro Gateway to remove transaction fees.', 'easy-digital-downloads'
/* Translators: Replacements are for the html wrappers for the phrase Upgrade to Pro and should not be translated. */
'%1$sUpgrade to Pro%2$s and install the Stripe Pro Gateway to remove transaction fees.', 'easy-digital-downloads'
),
'<span class="edd-pro-upgrade"><a href="' . edd_link_helper( 'https://easydigitaldownloads.com/pricing/', array( 'utm_medium' => 'stripe-settings', 'utm_content' => 'upgrade-to-pro' ) ) . '" target="_blank">',
'</a></span>'
@ -772,94 +772,3 @@ function edds_stripe_connect_admin_notices_print() {
} catch( Exception $e ) {}
}
add_action( 'admin_notices', 'edds_stripe_connect_admin_notices_print' );
/**
* Adds a Stripe Connect site health test.
*
* @since 2.9.3
* @param array $tests The array of Site Health tests.
* @return array
*/
function edds_stripe_connect_site_health_test( $tests ) {
$active_gateways = edd_get_enabled_payment_gateways();
if ( ! empty( $active_gateways['stripe'] ) && current_user_can( 'manage_shop_settings' ) ) {
$tests['direct']['edds_stripe_connect'] = array(
'label' => __( 'Stripe Connect', 'easy-digital-downloads' ),
'test' => 'edds_get_test_stripe_connect',
);
}
return $tests;
}
add_filter( 'site_status_tests', 'edds_stripe_connect_site_health_test' );
/**
* Adds the Stripe Connect Site Health test.
*
* @since 2.9.3
* @return array
*/
function edds_get_test_stripe_connect() {
$result = array(
'label' => __( 'You are securely connected to Stripe', 'easy-digital-downloads' ),
'status' => 'good',
'badge' => array(
'label' => __( 'Easy Digital Downloads: Stripe', 'easy-digital-downloads' ),
'color' => 'blue',
),
'description' => sprintf(
'<p>%s</p>',
__( 'Stripe Connect helps ensure easy setup and security.', 'easy-digital-downloads' )
),
'actions' => '',
'test' => 'edds_stripe_connect',
);
$elements_mode = edds_get_elements_mode();
if ( edd_stripe()->connect()->is_connected ) {
if ( 'payment-elements' === $elements_mode ) {
return $result;
}
// User is connected but on the Card Elements, we should give them a recommendation to use the Payment Elements.
$result['label'] = __( 'You are using the legacy Card Elements fields', 'easy-digital-downloads' );
$result['status'] = 'recommended';
$result['badge']['color'] = 'orange';
$result['description'] = sprintf(
'<p>%s</p>',
esc_html__( 'Increase conversions, security, and reliability by using the Payment Elements integration for Stripe.', 'easy-digital-downloads' )
);
$result['actions'] = sprintf(
'<a href="%s" class="button button-primary"><span>%s</span></a>',
esc_url(
edd_get_admin_url(
array(
'page' => 'edd-settings',
'tab' => 'gateways',
'section' => 'edd-stripe',
)
)
),
esc_html__( 'Switch to Payment Elements', 'easy-digital-downloads' )
);
} else {
$result['label'] = __( 'You are using manually managed Stripe API keys', 'easy-digital-downloads' );
$result['status'] = 'critical';
$result['badge']['color'] = 'red';
$result['description'] = sprintf(
'<p>%s</p>',
esc_html__( 'By securely connecting your Easy Digital Downloads store with Stripe Connect, you\'ll get access to more reliable payments and use managed API keys which are more secure.', 'easy-digital-downloads' )
);
$result['actions'] = sprintf(
'<a href="%s" class="edd-stripe-connect"><span>%s</span></a>',
esc_url( edds_stripe_connect_url() ),
esc_html__( 'Connect with Stripe', 'easy-digital-downloads' )
);
}
edd_stripe_connect_admin_style();
return $result;
}

View File

@ -0,0 +1,144 @@
<?php
/*
* Site Health
*
* @package EDD_Stripe\Admin\SiteHealth
* @copyright Copyright (c) 2023, Easy Digital Downloads
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
* @since 2.9.6
*/
defined( 'ABSPATH' ) || exit;
/**
* Adds a Stripe Connect site health test.
*
* @since 2.9.3
* @param array $tests The array of Site Health tests.
* @return array
*/
function edds_stripe_connect_site_health_test( $tests ) {
$active_gateways = edd_get_enabled_payment_gateways();
if ( ! empty( $active_gateways['stripe'] ) && current_user_can( 'manage_shop_settings' ) ) {
$tests['direct']['edds_stripe_connect'] = array(
'label' => __( 'Stripe Connect', 'easy-digital-downloads' ),
'test' => 'edds_get_test_stripe_connect',
);
}
return $tests;
}
add_filter( 'site_status_tests', 'edds_stripe_connect_site_health_test' );
/**
* Adds the Stripe Connect Site Health test.
*
* @since 2.9.3
* @return array
*/
function edds_get_test_stripe_connect() {
$result = array(
'label' => __( 'You are securely connected to Stripe', 'easy-digital-downloads' ),
'status' => 'good',
'badge' => array(
'label' => __( 'Easy Digital Downloads: Stripe', 'easy-digital-downloads' ),
'color' => 'blue',
),
'description' => sprintf(
'<p>%s</p>',
__( 'Stripe Connect helps ensure easy setup and security.', 'easy-digital-downloads' )
),
'actions' => '',
'test' => 'edds_stripe_connect',
);
$elements_mode = edds_get_elements_mode();
if ( edd_stripe()->connect()->is_connected ) {
if ( 'payment-elements' === $elements_mode ) {
return $result;
}
// User is connected but on the Card Elements, we should give them a recommendation to use the Payment Elements.
$result['label'] = __( 'You are using the legacy Card Elements fields', 'easy-digital-downloads' );
$result['status'] = 'recommended';
$result['badge']['color'] = 'orange';
$result['description'] = sprintf(
'<p>%s</p>',
esc_html__( 'Increase conversions, security, and reliability by using the Payment Elements integration for Stripe.', 'easy-digital-downloads' )
);
$result['actions'] = sprintf(
'<a href="%s" class="button button-primary"><span>%s</span></a>',
esc_url(
edd_get_admin_url(
array(
'page' => 'edd-settings',
'tab' => 'gateways',
'section' => 'edd-stripe',
)
)
),
esc_html__( 'Switch to Payment Elements', 'easy-digital-downloads' )
);
} else {
$result['label'] = __( 'You are using manually managed Stripe API keys', 'easy-digital-downloads' );
$result['status'] = 'critical';
$result['badge']['color'] = 'red';
$result['description'] = sprintf(
'<p>%s</p>',
esc_html__( 'By securely connecting your Easy Digital Downloads store with Stripe Connect, you\'ll get access to more reliable payments and use managed API keys which are more secure.', 'easy-digital-downloads' )
);
$result['actions'] = sprintf(
'<a href="%s" class="edd-stripe-connect"><span>%s</span></a>',
esc_url( edds_stripe_connect_url() ),
esc_html__( 'Connect with Stripe', 'easy-digital-downloads' )
);
}
edd_stripe_connect_admin_style();
return $result;
}
add_filter( 'edd_debug_information', 'edds_debug_information' );
/**
* Add Stripe debugging information to the EDD information.
*
* @since 2.9.6
* @param array $information The EDD debug information.
* @return array
*/
function edds_debug_information( $information ) {
$stripe = array(
'edd_stripe' => array(
'label' => __( 'Easy Digital Downloads &mdash; Stripe', 'easy-digital-downloads' ),
'fields' => array(
'connect' => array(
'label' => 'Stripe Connect',
'value' => edd_stripe()->connect()->is_connected ? 'Connected' : 'Not Connected',
),
'mode' => array(
'label' => 'Elements Mode',
'value' => 'payment-elements' === edds_get_elements_mode() ? 'Payment Elements' : 'Legacy Card Elements',
),
'preapproved_payments' => array(
'label' => 'Preapproved Payments',
'value' => edds_is_preapprove_enabled() ? 'Enabled' : 'Disabled',
),
'assets' => array(
'label' => 'Stripe Assets',
'value' => edd_get_option( 'stripe_restrict_assets', false ) ? 'Limited' : 'Global',
),
),
),
);
$position = array_search( 'edd_gateways', array_keys( $information ), true );
return array_merge(
array_slice( $information, 0, $position + 1 ),
$stripe,
array_slice( $information, $position + 1 )
);
}

View File

@ -74,18 +74,6 @@ class EDD_Stripe {
self::$instance->setup_classes();
self::$instance->actions();
self::$instance->filters();
if ( true === edds_is_pro() ) {
add_action( 'edd_extension_license_init', function( \EDD\Extensions\ExtensionRegistry $registry ) {
$registry->addExtension(
EDD_STRIPE_PLUGIN_FILE,
'Stripe Pro Payment Gateway',
167,
EDD_STRIPE_VERSION,
'stripe_license_key'
);
} );
}
}
return self::$instance;
@ -170,6 +158,7 @@ class EDD_Stripe {
require_once EDDS_PLUGIN_DIR . '/includes/admin/settings/stripe-connect.php';
require_once EDDS_PLUGIN_DIR . '/includes/admin/settings.php';
require_once EDDS_PLUGIN_DIR . '/includes/admin/upgrade-functions.php';
require_once EDDS_PLUGIN_DIR . '/includes/admin/site-health.php';
}
if ( defined( 'WP_CLI' ) && WP_CLI ) {

View File

@ -616,6 +616,8 @@ function edds_stripe_connect_account_country_supports_application_fees() {
$blocked_countries = array(
'br',
'in',
'mx',
);
return ! in_array( $account_country, $blocked_countries, true );
@ -776,4 +778,4 @@ function edds_get_tokenizer_input( $custom_id = '' ) {
esc_attr( $timestamp ),
esc_attr( \EDD\Utils\Tokenizer::tokenize( $timestamp ) )
);
}
}

View File

@ -68,29 +68,30 @@ function edds_process_purchase_form( $purchase_data ) {
*/
do_action( 'edds_pre_process_purchase_form', $purchase_data );
if ( edds_is_zero_decimal_currency() ) {
$amount = $purchase_data['price'];
} else {
$amount = round( $purchase_data['price'] * 100, 0 );
}
/**
* We need to unhook some of the Recurring Payments actions here as we're handling captures ourselves.
*
* We're also going to attempt to restrict this to a single subscription and no mixed carts, for the time being.
*/
$cart_contains_subscription = false;
$cart_contains_subscription = (bool) ( function_exists( 'edd_recurring' ) && edd_recurring()->cart_contains_recurring() );
if ( function_exists( 'edd_recurring' ) ) {
$cart_contains_subscription = edd_recurring()->cart_contains_recurring();
if ( ( count( edd_get_cart_contents() ) > 1 && $cart_contains_subscription ) || edd_recurring()->cart_is_mixed() ) {
if ( $cart_contains_subscription ) {
if ( count( edd_get_cart_contents() ) > 1 || edd_recurring()->cart_is_mixed() ) {
throw new \EDD_Stripe_Gateway_Exception( edds_get_single_subscription_cart_error() );
}
if ( edd_recurring()->cart_has_free_trial() ) {
$amount = 0;
}
global $edd_recurring_stripe;
remove_filter( 'edds_create_payment_intent_args', array( $edd_recurring_stripe, 'create_payment_intent_args' ), 10, 2 );
remove_filter( 'edds_capture_payment_intent', array( $edd_recurring_stripe, 'capture_payment_intent' ) );
}
if ( edds_is_zero_decimal_currency() ) {
$amount = $purchase_data['price'];
} else {
$amount = round( $purchase_data['price'] * 100, 0 );
}
$existing_intent = false;
@ -477,6 +478,8 @@ function edds_create_and_complete_order() {
// Retrieve the relevant Intent.
if ( 'setup_intent' === $intent->object ) {
$order_transaction_id = false;
$intent = edds_api_request( 'SetupIntent', 'update', $intent->id, array(
'metadata' => array(
'edd_payment_id' => $order->id,
@ -518,20 +521,20 @@ function edds_create_and_complete_order() {
'_edds_stripe_payment_intent_id',
$intent->id
);
}
// Use Intent ID for temporary transaction ID.
// It will be updated when a charge is available.
$order_transaction_id = edd_add_order_transaction(
array(
'object_id' => $order->id,
'object_type' => 'order',
'transaction_id' => sanitize_text_field( $intent->id ),
'gateway' => 'stripe',
'status' => 'pending',
'total' => $order->total,
)
);
// Use Intent ID for temporary transaction ID.
// It will be updated when a charge is available.
$order_transaction_id = edd_add_order_transaction(
array(
'object_id' => $order->id,
'object_type' => 'order',
'transaction_id' => sanitize_text_field( $intent->id ),
'gateway' => 'stripe',
'status' => 'pending',
'total' => $order->total,
)
);
}
// Retrieves or creates a Stripe Customer.
edd_update_order_meta( $order->id, '_edds_stripe_customer_id', $intent->customer );
@ -627,15 +630,14 @@ function edds_create_and_complete_order() {
)
);
edd_update_order_transaction(
$order_transaction_id,
array(
'transaction_id' => sanitize_text_field( $charge_id ),
'gateway' => 'stripe',
'status' => 'complete',
'total' => $order->total,
)
);
if ( ! empty( $order_transaction_id ) ) {
edd_update_order_transaction(
$order_transaction_id,
array(
'transaction_id' => sanitize_text_field( $charge_id ),
)
);
}
}
if ( has_action( 'edds_payment_complete' ) ) {

View File

@ -50,7 +50,7 @@ function edds_prb_add_settings( $settings ) {
'desc' => wp_kses(
(
sprintf(
/* translators: %1$s Opening anchor tag, do not translate. %2$s Opening anchor tag, do not translate. %3$s Closing anchor tag, do not translate. */
/* translators: %1$s Opening anchor tag, do not translate. %2$s Closing anchor tag, do not translate. %3$s Closing anchor tag, do not translate. */
__( '"Express Checkout" via Apple Pay, Google Pay, or Microsoft Pay digital wallets. By using Apple Pay, you agree to %1$sStripe%3$s and %2$sApple\'s%3$s terms of service.', 'easy-digital-downloads' ),
'<a href="https://stripe.com/apple-pay/legal" target="_blank" rel="noopener noreferrer">',
'<a href="https://developer.apple.com/apple-pay/acceptable-use-guidelines-for-websites/" target="_blank" rel="noopener noreferrer">',
@ -58,7 +58,7 @@ function edds_prb_add_settings( $settings ) {
) . (
edd_is_test_mode()
? '<br /><strong>' . __( 'Apple Pay is not available in Test Mode.', 'easy-digital-downloads' ) . '</strong> ' . sprintf(
/* translators: %1$s Opening anchor tag, do not translate. %2$s Opening anchor tag, do not translate. */
/* translators: %1$s Opening anchor tag, do not translate. %2$s Closing anchor tag, do not translate. */
__( 'See our %1$sdocumentation%2$s for more information.', 'easy-digital-downloads' ),
'<a href="' . esc_url( edds_documentation_route( 'stripe-express-checkout-apple-pay-google-pay' ) ) . '" target="_blank" rel="noopener noreferrer">',
'</a>'
@ -78,15 +78,16 @@ function edds_prb_add_settings( $settings ) {
),
'type' => 'multicheck',
'options' => array(
/** translators: %s Download noun */
'single' => sprintf(
/* translators: %s Download noun */
__( 'Single %s', 'easy-digital-downloads' ),
edd_get_label_singular()
),
/** translators: %s Download noun */
'archive' => sprintf(
__( '%s Archive (includes <code>[downloads]</code> shortcode)', 'easy-digital-downloads' ),
edd_get_label_singular()
/* translators: 1. Download noun; 2. shortcode tag wrapped in <code> span */
__( '%1$s Archive (includes %2$s shortcode)', 'easy-digital-downloads' ),
edd_get_label_singular(),
'<code>[downloads]</code>'
),
'checkout' => __( 'Checkout', 'easy-digital-downloads' ),
),

View File

@ -162,6 +162,7 @@ function edds_prb_get_download_data( $download_id, $price_id = false, $quantity
'label' => sprintf(
'%s%s',
strip_tags( $name ),
/* translators: %d: Quantity.*/
( $quantity > 1 ? sprintf( __( ' × %d', 'easy-digital-downloads' ), $quantity ) : '' )
),
'amount' => $price,

View File

@ -110,6 +110,7 @@ abstract class EDD_Stripe_Region_Base {
<p>
<?php
printf(
/* translators: %s: The country name. */
esc_html__( 'Based on your store\'s base country of %s, it is recommended to set your Billing Address Display to use the "Full Address" option to ensure payments are completed successfully.', 'easy-digital-downloads' ),
edd_get_country_name( edd_get_option( 'base_country', 'US' ) )
);