updated plugin Easy Digital Downloads
version 3.1.0.4
This commit is contained in:
@ -280,8 +280,12 @@ function get_order_items( $purchase_data ) {
|
||||
if ( $item_amount <= 0 ) {
|
||||
$item_amount = 0;
|
||||
}
|
||||
|
||||
$substr_func = function_exists( 'mb_substr' ) ? 'mb_substr' : 'substr';
|
||||
$name = $substr_func( edd_get_cart_item_name( $item ), 0, 127 );
|
||||
|
||||
$items[ $i ] = array(
|
||||
'name' => stripslashes_deep( html_entity_decode( substr( edd_get_cart_item_name( $item ), 0, 127 ), ENT_COMPAT, 'UTF-8' ) ),
|
||||
'name' => stripslashes_deep( html_entity_decode( $name, ENT_COMPAT, 'UTF-8' ) ),
|
||||
'quantity' => $item['quantity'],
|
||||
'unit_amount' => array(
|
||||
'currency_code' => edd_get_currency(),
|
||||
|
@ -13,6 +13,7 @@
|
||||
|
||||
namespace EDD\Gateways\PayPal\IPN;
|
||||
|
||||
use EDD\Gateways\PayPal;
|
||||
/**
|
||||
* Listens for an IPN call from PayPal
|
||||
*
|
||||
@ -25,6 +26,11 @@ function listen_for_ipn() {
|
||||
return;
|
||||
}
|
||||
|
||||
// If PayPal is not connected, we don't need to run here.
|
||||
if ( ! PayPal\has_rest_api_connection() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
ipn_debug_log( 'IPN Backup Loaded' );
|
||||
|
||||
// Moving this up in the load order so we can check some things before even getting to verification.
|
||||
@ -174,7 +180,7 @@ function listen_for_ipn() {
|
||||
|
||||
|
||||
// Bail if this is the very first payment.
|
||||
if ( date( 'Y-n-d', strtotime( $subscription->created ) ) == date( 'Y-n-d', strtotime( $posted['payment_date'] ) ) ) {
|
||||
if ( ! empty( $posted['payment_date'] ) && date( 'Y-n-d', strtotime( $subscription->created ) ) == date( 'Y-n-d', strtotime( $posted['payment_date'] ) ) ) {
|
||||
ipn_debug_log( 'IPN for subscription ' . $subscription->id . ': processing stopped because this is the initial payment.' );
|
||||
return;
|
||||
}
|
||||
|
File diff suppressed because one or more lines are too long
@ -8,10 +8,19 @@ domReady( () => {
|
||||
const containerEl = document.getElementById( 'edds-stripe-connect-account' );
|
||||
const actionsEl = document.getElementById( 'edds-stripe-disconnect-reconnect' );
|
||||
|
||||
|
||||
if ( ! containerEl ) {
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Do not make a request, if we are inside Onboarding Wizard.
|
||||
* Onboarding Wizard will make it's own call.
|
||||
*/
|
||||
if ( containerEl.hasAttribute('data-onboarding-wizard') ) {
|
||||
return;
|
||||
}
|
||||
|
||||
return apiRequest( 'edds_stripe_connect_account_info', {
|
||||
...containerEl.dataset,
|
||||
} )
|
||||
|
@ -3,8 +3,8 @@
|
||||
* Plugin Name: Easy Digital Downloads - Stripe Pro Payment Gateway
|
||||
* Plugin URI: https://easydigitaldownloads.com/downloads/stripe-gateway/
|
||||
* Description: Adds a payment gateway for Stripe.com
|
||||
* Version: 2.8.13
|
||||
* Requires at least: 4.4
|
||||
* Version: 2.8.13.1
|
||||
* Requires at least: 4.9
|
||||
* Requires PHP: 5.6
|
||||
* Author: Easy Digital Downloads
|
||||
* Author URI: https://easydigitaldownloads.com
|
||||
@ -44,7 +44,7 @@ function edd_stripe_core_bootstrap() {
|
||||
}
|
||||
|
||||
if ( ! defined( 'EDD_STRIPE_VERSION' ) ) {
|
||||
define( 'EDD_STRIPE_VERSION', '2.8.13' );
|
||||
define( 'EDD_STRIPE_VERSION', '2.8.13.1' );
|
||||
}
|
||||
|
||||
if ( ! defined( 'EDD_STRIPE_API_VERSION' ) ) {
|
||||
|
@ -83,27 +83,57 @@ function edds_stripe_connect_url() {
|
||||
*/
|
||||
function edds_process_gateway_connect_completion() {
|
||||
|
||||
if( ! isset( $_GET['edd_gateway_connect_completion'] ) || 'stripe_connect' !== $_GET['edd_gateway_connect_completion'] || ! isset( $_GET['state'] ) ) {
|
||||
$redirect_screen = ! empty( $_GET['redirect_screen'] ) ? sanitize_text_field( $_GET['redirect_screen'] ) : '';
|
||||
|
||||
// A cancelled connection doesn't contain the completion or state values, but we do need to listen for the redirect_screen for the wizard.
|
||||
if (
|
||||
isset( $_GET['edd_gateway_connect_error'] ) &&
|
||||
filter_var( $_GET['edd_gateway_connect_error'], FILTER_VALIDATE_BOOLEAN ) &&
|
||||
! empty( $redirect_screen )
|
||||
) {
|
||||
$error_redirect = '';
|
||||
|
||||
switch ( $redirect_screen ) {
|
||||
case 'onboarding-wizard':
|
||||
$error_redirect = admin_url( 'edit.php?post_type=download&page=edd-onboarding-wizard¤t_step=payment_methods' );
|
||||
break;
|
||||
}
|
||||
|
||||
if ( ! empty( $error_redirect ) ) {
|
||||
wp_safe_redirect( esc_url_raw( $error_redirect ) );
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! isset( $_GET['edd_gateway_connect_completion'] ) || 'stripe_connect' !== $_GET['edd_gateway_connect_completion'] || ! isset( $_GET['state'] ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if( ! current_user_can( 'manage_shop_settings' ) ) {
|
||||
if ( ! current_user_can( 'manage_shop_settings' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if( headers_sent() ) {
|
||||
if ( headers_sent() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$edd_credentials_url = add_query_arg( array(
|
||||
'live_mode' => (int) ! edd_is_test_mode(),
|
||||
'state' => sanitize_text_field( $_GET['state'] ),
|
||||
'customer_site_url' => admin_url( 'edit.php?post_type=download' ),
|
||||
), 'https://easydigitaldownloads.com/?edd_gateway_connect_credentials=stripe_connect' );
|
||||
$customer_site_url = admin_url( 'edit.php?post_type=download' );
|
||||
if ( ! empty( $redirect_screen ) ) {
|
||||
$customer_site_url = add_query_arg( 'redirect_screen', $redirect_screen, $customer_site_url );
|
||||
}
|
||||
|
||||
$edd_credentials_url = add_query_arg(
|
||||
array(
|
||||
'live_mode' => (int) ! edd_is_test_mode(),
|
||||
'state' => sanitize_text_field( $_GET['state'] ),
|
||||
'customer_site_url' => urlencode( $customer_site_url ),
|
||||
),
|
||||
'https://easydigitaldownloads.com/?edd_gateway_connect_credentials=stripe_connect'
|
||||
);
|
||||
|
||||
$response = wp_remote_get( esc_url_raw( $edd_credentials_url ) );
|
||||
|
||||
if( is_wp_error( $response ) || 200 !== wp_remote_retrieve_response_code( $response ) ) {
|
||||
if ( is_wp_error( $response ) || 200 !== wp_remote_retrieve_response_code( $response ) ) {
|
||||
$message = '<p>' . sprintf(
|
||||
/* translators: %1$s Opening anchor tag, do not translate. %2$s Closing anchor tag, do not translate. */
|
||||
__( 'There was an error getting your Stripe credentials. Please %1$stry again%2$s. If you continue to have this problem, please contact support.', 'easy-digital-downloads' ),
|
||||
@ -116,7 +146,7 @@ function edds_process_gateway_connect_completion() {
|
||||
$data = json_decode( $response['body'], true );
|
||||
$data = $data['data'];
|
||||
|
||||
if( edd_is_test_mode() ) {
|
||||
if ( edd_is_test_mode() ) {
|
||||
edd_update_option( 'test_publishable_key', sanitize_text_field( $data['publishable_key'] ) );
|
||||
edd_update_option( 'test_secret_key', sanitize_text_field( $data['secret_key'] ) );
|
||||
} else {
|
||||
@ -125,7 +155,18 @@ function edds_process_gateway_connect_completion() {
|
||||
}
|
||||
|
||||
edd_update_option( 'stripe_connect_account_id', sanitize_text_field( $data['stripe_user_id'] ) );
|
||||
wp_redirect( esc_url_raw( admin_url( 'edit.php?post_type=download&page=edd-settings&tab=gateways§ion=edd-stripe' ) ) );
|
||||
|
||||
$redirect_url = admin_url( 'edit.php?post_type=download&page=edd-settings&tab=gateways§ion=edd-stripe' );
|
||||
|
||||
if ( ! empty( $redirect_screen ) ) {
|
||||
switch ( $redirect_screen ) {
|
||||
case 'onboarding-wizard':
|
||||
$redirect_url = admin_url( 'edit.php?post_type=download&page=edd-onboarding-wizard¤t_step=payment_methods' );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
wp_safe_redirect( esc_url_raw( $redirect_url ) );
|
||||
exit;
|
||||
|
||||
}
|
||||
@ -178,7 +219,7 @@ function edds_stripe_connect_disconnect_url() {
|
||||
function edds_stripe_connect_process_disconnect() {
|
||||
// Do not need to handle this request, bail.
|
||||
if (
|
||||
! ( isset( $_GET['page'] ) && 'edd-settings' === $_GET['page'] ) ||
|
||||
! ( isset( $_GET['page'] ) && ( 'edd-settings' === $_GET['page'] || 'edd-onboarding-wizard' === $_GET['page'] ) ) ||
|
||||
! isset( $_GET['edds-stripe-disconnect'] )
|
||||
) {
|
||||
return;
|
||||
@ -337,7 +378,7 @@ function edds_stripe_connect_setting_field() {
|
||||
class="edds-stripe-connect-acount-info notice inline"
|
||||
data-account-id="<?php echo esc_attr( $stripe_connect_account_id ); ?>"
|
||||
data-nonce="<?php echo wp_create_nonce( 'edds-stripe-connect-account-information' ); ?>"
|
||||
>
|
||||
<?php echo ( ! empty( $_GET['page'] ) && 'edd-onboarding-wizard' === $_GET['page'] ) ? ' data-onboarding-wizard="true"' : ''; ?>>
|
||||
<p><span class="spinner is-active"></span>
|
||||
<em><?php esc_html_e( 'Retrieving account information...', 'easy-digital-downloads' ); ?></em>
|
||||
</div>
|
||||
|
@ -357,13 +357,21 @@ function edds_add_payment_method() {
|
||||
}
|
||||
|
||||
$stripe_customer_id = edds_get_stripe_customer_id( get_current_user_id() );
|
||||
$stripe_customer = edds_get_stripe_customer(
|
||||
|
||||
$customer_name = '';
|
||||
if ( ! empty( $edd_customer->name ) ) {
|
||||
$customer_name = $edd_customer->name;
|
||||
}
|
||||
|
||||
$stripe_customer = edds_get_stripe_customer(
|
||||
$stripe_customer_id,
|
||||
array(
|
||||
'email' => $edd_customer->email,
|
||||
'description' => $edd_customer->email,
|
||||
'name' => $customer_name,
|
||||
)
|
||||
);
|
||||
|
||||
if ( false === $stripe_customer ) {
|
||||
wp_send_json_error(
|
||||
array(
|
||||
|
@ -88,7 +88,7 @@ function edds_has_met_requirements( $requirement = false ) {
|
||||
: true
|
||||
),
|
||||
'wp' => (
|
||||
version_compare( get_bloginfo( 'version' ), '4.4', '>=' )
|
||||
version_compare( get_bloginfo( 'version' ), '4.9', '>=' )
|
||||
),
|
||||
);
|
||||
|
||||
|
@ -1175,10 +1175,22 @@ function edds_checkout_setup_customer( $purchase_data ) {
|
||||
// No customer ID found, let's look one up based on the email.
|
||||
$stripe_customer_id = edds_get_stripe_customer_id( $purchase_data['user_email'], false );
|
||||
}
|
||||
|
||||
$customer_name = '';
|
||||
if ( ! empty( $purchase_data['user_info']['first_name'] ) ) {
|
||||
$customer_name .= sanitize_text_field( $purchase_data['user_info']['first_name'] );
|
||||
}
|
||||
|
||||
if ( ! empty( $purchase_data['user_info']['last_name'] ) ) {
|
||||
$customer_name .= ' ' . sanitize_text_field( $purchase_data['user_info']['last_name'] );
|
||||
}
|
||||
|
||||
$customer_args = array(
|
||||
'email' => $purchase_data['user_email'],
|
||||
'description' => $purchase_data['user_email'],
|
||||
'name' => $customer_name,
|
||||
);
|
||||
|
||||
/**
|
||||
* Filters the arguments used to create a Customer in Stripe.
|
||||
*
|
||||
|
@ -32,10 +32,9 @@ function edds_buy_now_modal() {
|
||||
edd_localize_scripts();
|
||||
} else {
|
||||
edd_load_scripts();
|
||||
edd_agree_to_terms_js();
|
||||
}
|
||||
|
||||
edd_agree_to_terms_js();
|
||||
|
||||
remove_filter( 'edd_is_checkout', '__return_true' );
|
||||
|
||||
// Enqueue scripts.
|
||||
|
@ -42,6 +42,9 @@ namespace Composer\Autoload;
|
||||
*/
|
||||
class ClassLoader
|
||||
{
|
||||
/** @var \Closure(string):void */
|
||||
private static $includeFile;
|
||||
|
||||
/** @var ?string */
|
||||
private $vendorDir;
|
||||
|
||||
@ -106,6 +109,7 @@ class ClassLoader
|
||||
public function __construct($vendorDir = null)
|
||||
{
|
||||
$this->vendorDir = $vendorDir;
|
||||
self::initializeIncludeClosure();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -425,7 +429,7 @@ class ClassLoader
|
||||
public function loadClass($class)
|
||||
{
|
||||
if ($file = $this->findFile($class)) {
|
||||
includeFile($file);
|
||||
(self::$includeFile)($file);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -555,18 +559,23 @@ class ClassLoader
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope isolated include.
|
||||
*
|
||||
* Prevents access to $this/self from included files.
|
||||
*
|
||||
* @param string $file
|
||||
* @return void
|
||||
* @private
|
||||
*/
|
||||
function includeFile($file)
|
||||
{
|
||||
include $file;
|
||||
private static function initializeIncludeClosure(): void
|
||||
{
|
||||
if (self::$includeFile !== null) {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope isolated include.
|
||||
*
|
||||
* Prevents access to $this/self from included files.
|
||||
*
|
||||
* @param string $file
|
||||
* @return void
|
||||
*/
|
||||
self::$includeFile = static function($file) {
|
||||
include $file;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
'name' => 'easy-digital-downloads/edd-stripe',
|
||||
'pretty_version' => 'dev-master',
|
||||
'version' => 'dev-master',
|
||||
'reference' => '829e436e3e0b91ab69528aebcee3344aa2e91eca',
|
||||
'reference' => '24964d034941e0d3d07390ecc39570bfc64e7369',
|
||||
'type' => 'wordpress-plugin',
|
||||
'install_path' => __DIR__ . '/../../',
|
||||
'aliases' => array(),
|
||||
@ -13,7 +13,7 @@
|
||||
'easy-digital-downloads/edd-stripe' => array(
|
||||
'pretty_version' => 'dev-master',
|
||||
'version' => 'dev-master',
|
||||
'reference' => '829e436e3e0b91ab69528aebcee3344aa2e91eca',
|
||||
'reference' => '24964d034941e0d3d07390ecc39570bfc64e7369',
|
||||
'type' => 'wordpress-plugin',
|
||||
'install_path' => __DIR__ . '/../../',
|
||||
'aliases' => array(),
|
||||
|
Reference in New Issue
Block a user