updated plugin Easy Digital Downloads
version 3.1.2
This commit is contained in:
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1 +1 @@
|
||||
!function(e){var n={};function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:r})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,n){if(1&n&&(e=t(e)),8&n)return e;if(4&n&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(t.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&n&&"string"!=typeof e)for(var o in e)t.d(r,o,function(n){return e[n]}.bind(null,o));return r},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},t.p="",t(t.s=109)}({109:function(e,n,t){(function(e){jQuery((function(){jQuery(".edds-admin-notice").each((function(){var n=e(this),t=n.data("id"),r=n.data("nonce");n.on("click",".notice-dismiss",(function(e){return e.preventDefault(),e.stopPropagation(),wp.ajax.post("edds_admin_notices_dismiss_ajax",{id:t,nonce:r})}))}))}))}).call(this,t(6))},6:function(e,n){e.exports=jQuery}});
|
||||
!function(e){var n={};function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:r})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,n){if(1&n&&(e=t(e)),8&n)return e;if(4&n&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(t.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&n&&"string"!=typeof e)for(var o in e)t.d(r,o,function(n){return e[n]}.bind(null,o));return r},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},t.p="",t(t.s=113)}({113:function(e,n,t){(function(e){jQuery((function(){jQuery(".edds-admin-notice").each((function(){var n=e(this),t=n.data("id"),r=n.data("nonce");n.on("click",".notice-dismiss",(function(e){return e.preventDefault(),e.stopPropagation(),wp.ajax.post("edds_admin_notices_dismiss_ajax",{id:t,nonce:r})}))}))}))}).call(this,t(6))},6:function(e,n){e.exports=jQuery}});
|
File diff suppressed because one or more lines are too long
@ -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.2.2
|
||||
* Version: 2.9.5.1
|
||||
* 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.2.2' );
|
||||
define( 'EDD_STRIPE_VERSION', '2.9.5.1' );
|
||||
}
|
||||
|
||||
if ( ! defined( 'EDD_STRIPE_API_VERSION' ) ) {
|
||||
|
@ -214,3 +214,64 @@ function edds_show_refund_checkbox( \EDD\Orders\Order $order ) {
|
||||
<?php
|
||||
}
|
||||
add_action( 'edd_after_submit_refund_table', 'edds_show_refund_checkbox' );
|
||||
|
||||
/**
|
||||
* Allows processing flags for the EDD Stripe settings.
|
||||
*
|
||||
* As we transition settings like the Card Elements, we need a way to be able to toggle
|
||||
* these things back on for some people. Enabling debug mode, setting flags, and then disabling
|
||||
* debug mode allows us to handle this.
|
||||
*
|
||||
* @since 2.9.4
|
||||
*/
|
||||
function edds_process_settings_flags() {
|
||||
// If we're not on the settings page, bail.
|
||||
if ( ! edd_is_admin_page( 'settings', 'gateways' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If it isn't the Stripe section, bail.
|
||||
if ( ! isset( $_GET['section'] ) || 'edd-stripe' !== $_GET['section'] ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Gather the flag we're trying to set.
|
||||
$flag = isset( $_GET['flag'] ) ? $_GET['flag'] : false;
|
||||
|
||||
if ( false === $flag ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! current_user_can( 'manage_shop_settings' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$nonce = isset( $_GET['_wpnonce'] ) ? $_GET['_wpnonce'] : false;
|
||||
if ( empty( $nonce ) || ! wp_verify_nonce( $nonce, $flag ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch( $flag ) {
|
||||
case 'disable-card-elements':
|
||||
delete_option( '_edds_legacy_elements_enabled' );
|
||||
break;
|
||||
|
||||
case 'enable-card-elements':
|
||||
add_option( '_edds_legacy_elements_enabled', 1, false );
|
||||
break;
|
||||
}
|
||||
|
||||
// Redirect to the settings page.
|
||||
wp_safe_redirect(
|
||||
edd_get_admin_url(
|
||||
array(
|
||||
'page' => 'edd-settings',
|
||||
'tab' => 'gateways',
|
||||
'section' => 'edd-stripe',
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
exit;
|
||||
}
|
||||
add_action( 'admin_init', 'edds_process_settings_flags', 1 );
|
@ -198,6 +198,47 @@ function edds_add_settings( $settings ) {
|
||||
|
||||
$settings['edd-stripe'] = $stripe_settings;
|
||||
|
||||
// If EDD is in Debug Mode, add some 'hidden' settings to the Stripe settings.
|
||||
if ( edd_is_debug_mode() ) {
|
||||
$card_elements_enabled = get_option( '_edds_legacy_elements_enabled', false );
|
||||
|
||||
$debug_settings = array(
|
||||
'stripe_debug' => array(
|
||||
'id' => 'stripe_debug',
|
||||
'name' => __( 'Debugging Settings', 'easy-digital-downloads' ),
|
||||
'desc' => '<div class="notice inline notice-warning">' .
|
||||
'<p>' . __( 'The following settings are available while Easy Digital Downloads is in debug mode. They are not designed to be primary settings and should be used only while debugging or when instructed to be used by the Easy Digital Downloads Team.', 'easy-digital-downloads' ) . '</p>' .
|
||||
'<p>' . __( 'There is no guarantee that these settings will remain available in future versions of Easy Digital Downloads. Easy Digital Downloads Debug Mode should be disabled once changes to these settings have been made.', 'easy-digital-downloads' ) . '</p>' .
|
||||
'</p></div>',
|
||||
'type' => 'descriptive_text',
|
||||
),
|
||||
);
|
||||
|
||||
$card_elements_action = $card_elements_enabled ? 'disable-card-elements' : 'enable-card-elements';
|
||||
$card_elements_button_label = $card_elements_enabled ? __( 'Disable access to Card Elements', 'easy-digital-downloads' ) : __( 'Enable access to Card Elements', 'easy-digital-downloads' );
|
||||
$card_elements_state_label = $card_elements_enabled ? __( 'Access to Legacy Card Elements is Enabled', 'easy-digital-downloads' ) : __( 'Access to Legacy Card Elements is Disabled', 'easy-digital-downloads' );
|
||||
|
||||
$link_class = $card_elements_enabled ? 'edd-button__toggle--enabled' : 'edd-button__toggle--disabled';
|
||||
|
||||
$debug_settings['toggle_card_elements'] = array(
|
||||
'id' => 'stripe_toggle_card_elements',
|
||||
'name' => __( 'Toggle Card Elements', 'easy-digital-downloads' ),
|
||||
'type' => 'descriptive_text',
|
||||
'desc' => sprintf(
|
||||
'%1$s<span class="screen-reader-text">' . $card_elements_button_label . '</span>%2$s',
|
||||
'<a class="edd-button__toggle ' . $link_class . '" href="' . wp_nonce_url( edd_get_admin_url( array(
|
||||
'page' => 'edd-settings',
|
||||
'tab' => 'gateways',
|
||||
'section' => 'edd-stripe',
|
||||
'flag' => $card_elements_action,
|
||||
) ), $card_elements_action ) . '">',
|
||||
'</a>'
|
||||
) .'<strong>' . $card_elements_state_label . '</strong><br />' . __( 'Card Elements is the legacy Stripe integration. Easy Digital Downloads has updated to use the more secure and reliable Payment Elements feature of Stripe. This toggle allows sites without access to Card Elements to enable or disable it.', 'easy-digital-downloads' ),
|
||||
);
|
||||
|
||||
$settings['edd-stripe'] = array_merge( $settings['edd-stripe'], $debug_settings );
|
||||
}
|
||||
|
||||
// Set up the new setting field for the Test Mode toggle notice.
|
||||
$notice = array(
|
||||
'stripe_connect_test_mode_toggle_notice' => array(
|
||||
|
@ -242,6 +242,11 @@ function edds_stripe_connect_process_disconnect() {
|
||||
edd_delete_option( $option );
|
||||
}
|
||||
|
||||
// Remove Stripe from the enabled gateways.
|
||||
$gateways = edd_get_option( 'gateways', array() );
|
||||
unset( $gateways['stripe'] );
|
||||
edd_update_option( 'gateways', $gateways );
|
||||
|
||||
$redirect = remove_query_arg(
|
||||
array(
|
||||
'_wpnonce',
|
||||
@ -265,9 +270,9 @@ function edds_stripe_connect_maybe_refresh_account_country() {
|
||||
return;
|
||||
}
|
||||
|
||||
// Stripe Connect has not been used, bail.
|
||||
$account_id = edd_get_option( 'stripe_connect_account_id', '' );
|
||||
$account_id = edd_stripe()->connect()->get_connect_id();
|
||||
|
||||
// Stripe Connect has not been used, bail.
|
||||
if ( empty( $account_id ) ) {
|
||||
return;
|
||||
}
|
||||
@ -307,10 +312,10 @@ add_action( 'admin_init', 'edds_stripe_connect_maybe_refresh_account_country' );
|
||||
* @since 2.8.0
|
||||
*/
|
||||
function edds_stripe_connect_setting_field() {
|
||||
$stripe_connect_url = edds_stripe_connect_url();
|
||||
$stripe_disconnect_url = edds_stripe_connect_disconnect_url();
|
||||
$stripe_connect_url = edds_stripe_connect_url();
|
||||
$stripe_disconnect_url = edds_stripe_connect_disconnect_url();
|
||||
|
||||
$stripe_connect_account_id = edd_get_option( 'stripe_connect_account_id' );
|
||||
$stripe_connect_account_id = edd_stripe()->connect()->get_connect_id();
|
||||
|
||||
$api_key = edd_is_test_mode()
|
||||
? edd_get_option( 'test_publishable_key' )
|
||||
@ -678,20 +683,6 @@ function edds_stripe_connect_admin_notices_register() {
|
||||
);
|
||||
|
||||
try {
|
||||
// Stripe Connect - Manually managed keys.
|
||||
$registry->add(
|
||||
'stripe-connect-manual',
|
||||
array(
|
||||
'message' => sprintf(
|
||||
'<p>%s</p><p>%s</p>',
|
||||
esc_html__( 'Your current Stripe payment connection is out of date. Enable more secure and reliable payments by clicking the button below to enable Stripe Connect.', 'easy-digital-downloads' ),
|
||||
$connect_button
|
||||
),
|
||||
'type' => 'error',
|
||||
'dismissible' => true,
|
||||
)
|
||||
);
|
||||
|
||||
// Stripe Connect.
|
||||
$registry->add(
|
||||
'stripe-connect',
|
||||
@ -768,20 +759,11 @@ function edds_stripe_connect_admin_notices_print() {
|
||||
$mode_toggle = isset( $_GET['edd-message'] ) && 'connect-to-stripe' === $_GET['edd-message'];
|
||||
|
||||
if ( array_key_exists( 'stripe', $enabled_gateways ) && empty( $api_key ) ) {
|
||||
wp_enqueue_style(
|
||||
'edd-stripe-admin-styles',
|
||||
EDDSTRIPE_PLUGIN_URL . 'assets/css/build/admin.min.css',
|
||||
array(),
|
||||
EDD_STRIPE_VERSION
|
||||
);
|
||||
edd_stripe_connect_admin_style();
|
||||
|
||||
// Stripe Connect.
|
||||
if ( false === $mode_toggle ) {
|
||||
if ( edds_stripe_connect_can_manage_keys() ) {
|
||||
$notices->output( 'stripe-connect-manual' );
|
||||
} else {
|
||||
$notices->output( 'stripe-connect' );
|
||||
}
|
||||
$notices->output( 'stripe-connect' );
|
||||
// Stripe Connect reconnect.
|
||||
} else {
|
||||
$notices->output( 'stripe-connect-reconnect' );
|
||||
@ -790,3 +772,94 @@ 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;
|
||||
}
|
||||
|
@ -40,19 +40,17 @@ add_action( 'admin_init', function() {
|
||||
}
|
||||
|
||||
$elements_mode = 'payment-elements';
|
||||
$connect = edd_stripe()->connect();
|
||||
|
||||
if (
|
||||
edds_stripe_connect_can_manage_keys() ||
|
||||
! empty( edd_get_option( 'stripe_connect_account_id', false ) )
|
||||
! empty( $connect->get_connect_id() ) ||
|
||||
edds_stripe_connect_can_manage_keys()
|
||||
) {
|
||||
$elements_mode = 'card-elements';
|
||||
add_option( '_edds_legacy_elements_enabled', 1, false );
|
||||
}
|
||||
|
||||
edd_update_option( 'stripe_elements_mode', $elements_mode );
|
||||
|
||||
if ( 'card-elements' === $elements_mode ) {
|
||||
add_option( '_edds_legacy_elements_enabled', 1, false );
|
||||
}
|
||||
} );
|
||||
|
||||
/**
|
||||
|
@ -52,6 +52,14 @@ class EDD_Stripe {
|
||||
*/
|
||||
public $regional_support;
|
||||
|
||||
/**
|
||||
* Stripe Connect status class.
|
||||
*
|
||||
* @since 2.9.3
|
||||
* @var \EDD\Stripe\Connect
|
||||
*/
|
||||
public $connect;
|
||||
|
||||
/**
|
||||
* Instantiates or returns the singleton instance.
|
||||
*
|
||||
@ -93,6 +101,7 @@ class EDD_Stripe {
|
||||
require_once EDDS_PLUGIN_DIR . '/vendor/autoload.php';
|
||||
}
|
||||
|
||||
require_once EDDS_PLUGIN_DIR . '/includes/functions.php';
|
||||
require_once EDDS_PLUGIN_DIR . '/includes/class-stripe-api.php';
|
||||
|
||||
// We need this one to load early so we can use it in the upcoming includes.
|
||||
@ -107,7 +116,6 @@ class EDD_Stripe {
|
||||
require_once EDDS_PLUGIN_DIR . '/includes/utils/class-registry.php';
|
||||
require_once EDDS_PLUGIN_DIR . '/includes/utils/modal.php';
|
||||
|
||||
require_once EDDS_PLUGIN_DIR . '/includes/functions.php';
|
||||
require_once EDDS_PLUGIN_DIR . '/includes/deprecated.php';
|
||||
require_once EDDS_PLUGIN_DIR . '/includes/compat.php';
|
||||
require_once EDDS_PLUGIN_DIR . '/includes/i18n.php';
|
||||
@ -137,7 +145,6 @@ class EDD_Stripe {
|
||||
// Load Apple Pay functions.
|
||||
require_once EDDS_PLUGIN_DIR . '/includes/payment-methods/apple-pay.php';
|
||||
|
||||
|
||||
// Stripe Elements, separated by elements type.
|
||||
switch ( $elements_mode ) {
|
||||
case 'card-elements':
|
||||
@ -216,6 +223,21 @@ class EDD_Stripe {
|
||||
$this->rate_limiting = new EDD_Stripe_Rate_Limiting();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Stripe Connect utility class.
|
||||
*
|
||||
* @since 2.9.3
|
||||
*/
|
||||
public function connect() {
|
||||
if ( ! is_null( $this->connect ) ) {
|
||||
return $this->connect;
|
||||
}
|
||||
require_once EDDS_PLUGIN_DIR . '/includes/class-stripe-connect.php';
|
||||
$this->connect = new EDD\Stripe\Connect();
|
||||
|
||||
return $this->connect;
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs database upgrades.
|
||||
*
|
||||
|
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace EDD\Stripe;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* The class to manage the Stripe Connect properties.
|
||||
*/
|
||||
class Connect {
|
||||
|
||||
/**
|
||||
* Whether the site is connected to Stripe with Stripe Connect.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $is_connected;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->is_connected = ! empty( $this->get_connect_id() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the connect ID.
|
||||
*
|
||||
* @return string|false
|
||||
*/
|
||||
public function get_connect_id() {
|
||||
return edd_get_option( 'stripe_connect_account_id', false );
|
||||
}
|
||||
}
|
@ -9,10 +9,9 @@
|
||||
*/
|
||||
function edds_stripe_connect_can_manage_keys() {
|
||||
|
||||
$stripe_connect_account_id = edd_get_option( 'stripe_connect_account_id', false );
|
||||
$secret = edd_is_test_mode() ? edd_get_option( 'test_secret_key' ) : edd_get_option( 'live_secret_key' );
|
||||
$secret = edd_is_test_mode() ? edd_get_option( 'test_secret_key' ) : edd_get_option( 'live_secret_key' );
|
||||
|
||||
return empty( $stripe_connect_account_id ) && $secret;
|
||||
return $secret && empty( edd_stripe()->connect()->get_connect_id() );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -21,6 +20,7 @@ function edds_stripe_connect_can_manage_keys() {
|
||||
* If the user is gated into the legacy mode, set the default to card-elements.
|
||||
*
|
||||
* @since 2.9.0
|
||||
* @since 2.9.5.1 We're now listening for an elements_mode flag in POST requests.
|
||||
*
|
||||
* @return string The elements mode string.
|
||||
*/
|
||||
@ -43,6 +43,17 @@ function edds_get_elements_mode() {
|
||||
( isset( $_GET['action'] ) && 'update' === $_GET['action'] ) &&
|
||||
( isset( $_GET['subscription_id'] ) && is_numeric( $_GET['subscription_id'] ) )
|
||||
) {
|
||||
add_filter( 'edd_get_option_stripe_split_payment_fields', '__return_false' );
|
||||
return 'card-elements';
|
||||
}
|
||||
|
||||
/**
|
||||
* Card elements does a lot with AJAX requests, which will lose the context of being on the Subscription update form, so
|
||||
* we are sending in a flag for using card elements with the elements_mode equal to 'card-elements' in those POST requests.
|
||||
*
|
||||
* @since 2.9.5.1
|
||||
*/
|
||||
if ( isset( $_POST['elements_mode'] ) && 'card-elements' === $_POST['elements_mode'] ) {
|
||||
return 'card-elements';
|
||||
}
|
||||
|
||||
|
@ -250,6 +250,28 @@ function edds_get_stripe_payment_elements_fields() {
|
||||
return apply_filters( 'edds_stripe_payment_elements_fields', $default_fields );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of terms for the payment elements.
|
||||
*
|
||||
* @since 2.9.4
|
||||
*
|
||||
* @return array The terms array by payment method.
|
||||
*/
|
||||
function edds_get_stripe_payment_elements_terms() {
|
||||
$terms = array( 'card' => 'auto' );
|
||||
|
||||
/**
|
||||
* Allows filtering the payment elements terms.
|
||||
*
|
||||
* @see https://stripe.com/docs/js/elements_object/create_payment_element#payment_element_create-options-terms
|
||||
*
|
||||
* @since 2.9.4
|
||||
* @param array The terms array by payment method.
|
||||
*/
|
||||
|
||||
return apply_filters( 'edds_stripe_payment_elements_terms', $terms );
|
||||
}
|
||||
|
||||
/**
|
||||
* Gathers all the possible customizations for the Stripe Payment Elements.
|
||||
*
|
||||
@ -273,6 +295,7 @@ function edds_gather_payment_element_customizations() {
|
||||
'fonts' => edds_get_stripe_payment_elements_fonts(),
|
||||
'paymentMethodTypes' => edds_payment_element_payment_method_types(),
|
||||
'fields' => edds_get_stripe_payment_elements_fields(),
|
||||
'terms' => edds_get_stripe_payment_elements_terms(),
|
||||
'i18n' => array(
|
||||
'errorMessages' => edds_get_localized_error_messages(),
|
||||
),
|
||||
|
@ -283,10 +283,8 @@ function edds_process_purchase_form( $purchase_data ) {
|
||||
$intent_args
|
||||
);
|
||||
|
||||
$stripe_connect_account_id = edd_get_option( 'stripe_connect_account_id' );
|
||||
|
||||
if (
|
||||
! empty( $stripe_connect_account_id ) &&
|
||||
! empty( edd_stripe()->connect()->get_connect_id() ) &&
|
||||
true === edds_stripe_connect_account_country_supports_application_fees()
|
||||
) {
|
||||
$intent_args['application_fee_amount'] = round( $amount * 0.02 );
|
||||
|
@ -234,10 +234,10 @@ function edds_process_purchase_form( $purchase_data ) {
|
||||
$intent_args
|
||||
);
|
||||
|
||||
$stripe_connect_account_id = edd_get_option( 'stripe_connect_account_id' );
|
||||
$intent_type = 'PaymentIntent';
|
||||
|
||||
if (
|
||||
! empty( $stripe_connect_account_id ) &&
|
||||
! empty( edd_stripe()->connect()->get_connect_id() ) &&
|
||||
true === edds_stripe_connect_account_country_supports_application_fees()
|
||||
) {
|
||||
$intent_args['application_fee_amount'] = round( $amount * 0.02 );
|
||||
|
@ -78,11 +78,10 @@ function edds_apple_pay_admin_notices_print() {
|
||||
wp_enqueue_script( 'edds-admin-notices' );
|
||||
|
||||
try {
|
||||
$is_connected = edd_get_option( 'stripe_connect_account_id', '' );
|
||||
$error = edd_get_option( 'stripe_apple_pay_domain_error', '' );
|
||||
$test_mode = edd_is_test_mode();
|
||||
$error = edd_get_option( 'stripe_apple_pay_domain_error', '' );
|
||||
$test_mode = edd_is_test_mode();
|
||||
|
||||
if ( ! empty( $is_connected ) && ! empty( $error ) && false === $test_mode ) {
|
||||
if ( ! empty( edd_stripe()->connect()->is_connected ) && ! empty( $error ) && false === $test_mode ) {
|
||||
$notices->output( 'apple-pay-' . $_SERVER['HTTP_HOST'] );
|
||||
}
|
||||
} catch( Exception $e ) {}
|
||||
@ -189,8 +188,7 @@ function edds_apple_pay_create_directory_and_move_file() {
|
||||
* @since 2.8.0
|
||||
*/
|
||||
function edds_apple_pay_check_domain() {
|
||||
$is_connected = edd_get_option( 'stripe_connect_account_id', '' );
|
||||
if ( empty( $is_connected ) ) {
|
||||
if ( empty( edd_stripe()->connect()->is_connected ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -221,7 +219,7 @@ add_action( 'admin_init', 'edds_apple_pay_check_domain', 10 );
|
||||
*/
|
||||
function edds_apple_pay_verify_domain() {
|
||||
// If Stripe isn't connected, just return.
|
||||
if ( empty( edd_get_option( 'stripe_connect_account_id', '' ) ) ) {
|
||||
if ( empty( edd_stripe()->connect()->is_connected ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -258,7 +256,7 @@ function edds_apple_pay_verify_domain() {
|
||||
// Create directory and move file if needed.
|
||||
edds_apple_pay_create_directory_and_move_file();
|
||||
|
||||
$stripe_connect_account_id = edd_get_option( 'stripe_connect_account_id', '' );
|
||||
$stripe_connect_account_id = edd_stripe()->connect()->get_connect_id();
|
||||
|
||||
if (
|
||||
empty( $stripe_connect_account_id ) || // If we don't have a stripe connect account ID
|
||||
|
@ -160,7 +160,7 @@ function edd_stripe_connect_admin_script( $hook ) {
|
||||
return;
|
||||
}
|
||||
|
||||
wp_enqueue_style( 'edd-stripe-admin-styles', EDDSTRIPE_PLUGIN_URL . 'assets/css/build/admin.min.css', array(), EDD_STRIPE_VERSION );
|
||||
edd_stripe_connect_admin_style();
|
||||
|
||||
wp_enqueue_script( 'edd-stripe-admin-scripts', EDDSTRIPE_PLUGIN_URL . 'assets/js/build/admin.min.js', array( 'jquery' ), EDD_STRIPE_VERSION );
|
||||
|
||||
@ -180,3 +180,19 @@ function edd_stripe_connect_admin_script( $hook ) {
|
||||
);
|
||||
}
|
||||
add_action( 'admin_enqueue_scripts', 'edd_stripe_connect_admin_script' );
|
||||
|
||||
/**
|
||||
* Enqueues the Stripe admin style.
|
||||
*
|
||||
* @since 2.9.3
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function edd_stripe_connect_admin_style() {
|
||||
wp_enqueue_style(
|
||||
'edd-stripe-admin-styles',
|
||||
EDDSTRIPE_PLUGIN_URL . 'assets/css/build/admin.min.css',
|
||||
array(),
|
||||
EDD_STRIPE_VERSION
|
||||
);
|
||||
}
|
||||
|
@ -120,6 +120,7 @@ function edds_output_payment_elements_form() {
|
||||
// Payment Elements needs to not allow checking out with mixed carts or multiple subscriptions.
|
||||
if ( function_exists( 'edd_recurring' ) ) {
|
||||
if ( ( count( edd_get_cart_contents() ) > 1 && edd_recurring()->cart_contains_recurring() ) || edd_recurring()->cart_is_mixed() ) {
|
||||
add_filter( 'edd_checkout_button_purchase', '__return_empty_string', 999 );
|
||||
?>
|
||||
<div class="edd_errors edd-alert edd-alert-info">
|
||||
<p class="edd_error" id="edd_error_edd-stripe-incompatible-cart"><?php echo edds_get_single_subscription_cart_error(); ?></p>
|
||||
|
@ -98,7 +98,7 @@ class InstalledVersions
|
||||
{
|
||||
foreach (self::getInstalled() as $installed) {
|
||||
if (isset($installed['versions'][$packageName])) {
|
||||
return $includeDevRequirements || !isset($installed['versions'][$packageName]['dev_requirement']) || $installed['versions'][$packageName]['dev_requirement'] === false;
|
||||
return $includeDevRequirements || empty($installed['versions'][$packageName]['dev_requirement']);
|
||||
}
|
||||
}
|
||||
|
||||
@ -119,7 +119,7 @@ class InstalledVersions
|
||||
*/
|
||||
public static function satisfies(VersionParser $parser, $packageName, $constraint)
|
||||
{
|
||||
$constraint = $parser->parseConstraints((string) $constraint);
|
||||
$constraint = $parser->parseConstraints($constraint);
|
||||
$provided = $parser->parseConstraints(self::getVersionRanges($packageName));
|
||||
|
||||
return $provided->matches($constraint);
|
||||
@ -328,9 +328,7 @@ class InstalledVersions
|
||||
if (isset(self::$installedByVendor[$vendorDir])) {
|
||||
$installed[] = self::$installedByVendor[$vendorDir];
|
||||
} elseif (is_file($vendorDir.'/composer/installed.php')) {
|
||||
/** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
|
||||
$required = require $vendorDir.'/composer/installed.php';
|
||||
$installed[] = self::$installedByVendor[$vendorDir] = $required;
|
||||
$installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php';
|
||||
if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) {
|
||||
self::$installed = $installed[count($installed) - 1];
|
||||
}
|
||||
@ -342,17 +340,12 @@ class InstalledVersions
|
||||
// only require the installed.php file if this file is loaded from its dumped location,
|
||||
// and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
|
||||
if (substr(__DIR__, -8, 1) !== 'C') {
|
||||
/** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
|
||||
$required = require __DIR__ . '/installed.php';
|
||||
self::$installed = $required;
|
||||
self::$installed = require __DIR__ . '/installed.php';
|
||||
} else {
|
||||
self::$installed = array();
|
||||
}
|
||||
}
|
||||
|
||||
if (self::$installed !== array()) {
|
||||
$installed[] = self::$installed;
|
||||
}
|
||||
$installed[] = self::$installed;
|
||||
|
||||
return $installed;
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
<?php return array(
|
||||
'root' => array(
|
||||
'name' => 'easy-digital-downloads/edd-stripe',
|
||||
'pretty_version' => '2.9.2.2',
|
||||
'version' => '2.9.2.2',
|
||||
'reference' => '7e59ac4f4357cb3b388182e0601056f60f0b2407',
|
||||
'pretty_version' => 'dev-master',
|
||||
'version' => 'dev-master',
|
||||
'reference' => '53b4520542b33c13127f604da77f09f7cf9cf902',
|
||||
'type' => 'wordpress-plugin',
|
||||
'install_path' => __DIR__ . '/../../',
|
||||
'aliases' => array(),
|
||||
@ -11,9 +11,9 @@
|
||||
),
|
||||
'versions' => array(
|
||||
'easy-digital-downloads/edd-stripe' => array(
|
||||
'pretty_version' => '2.9.2.2',
|
||||
'version' => '2.9.2.2',
|
||||
'reference' => '7e59ac4f4357cb3b388182e0601056f60f0b2407',
|
||||
'pretty_version' => 'dev-master',
|
||||
'version' => 'dev-master',
|
||||
'reference' => '53b4520542b33c13127f604da77f09f7cf9cf902',
|
||||
'type' => 'wordpress-plugin',
|
||||
'install_path' => __DIR__ . '/../../',
|
||||
'aliases' => array(),
|
||||
|
Reference in New Issue
Block a user