awesomemotive / easy-digital-downloads

Sell digital downloads through WordPress
https://easydigitaldownloads.com
GNU General Public License v2.0
863 stars 474 forks source link

EDD Software Licenses Uses Payment Date to generate license instead of Payment Completion Date #9709

Open sharmashivanand opened 8 months ago

sharmashivanand commented 8 months ago

Bug Report

Apparently EDD Software Licenses uses Payment Date instead of Payment Completion Date to generate license keys.

includes/classes/class-edd-software-licensing.php
...
$license->create( $args['download_id'], $args['payment_id'], $price_id, $args['cart_index'], $options );

And...

includes/classes/class-sl-license.php
...
// Get the purchase date so we can set the correct license expiration date.
    $payment_meta  = $payment->get_meta();
    $purchase_date = null;
    if ( ! empty( $payment_meta['date'] ) ) {
        $purchase_date = strtotime( $payment_meta['date'], current_time( 'timestamp' ) );
    }
...
$expiration_date = strtotime( $license_length, $purchase_date );

Expected behaviour

It's expected that the license key use payment completion date so that they don't get expired unexpectedly.

Actual behaviour

If a customer completes an ancient order, the license key is generated for a back-date which is expired.

Steps to reproduce the behaviour

1) Create an order older than 1 year ago 2) Complete this order. 3) The license keys are expired. etc, etc

Information (if a specific version is affected):

PHP Version: 8*

EDD Version (or branch): 3*

WordPress Version: 6*

Any other relevant information:

sharmashivanand commented 8 months ago

Apparently filter 'edd_sl_license_creation_options' can be engaged to correct this but still it would be better to have sane defaults.