/** * Process the renewal purchase requirement from the checkout screen. * * @since 1.0 */ public function process_purchase_requirement_renewal_checkout() { if (!isset($_POST['itelic_renew_keys_checkout']) || !isset($_POST['_wpnonce']) || empty($_POST['itelic_key'])) { return; } if (!wp_verify_nonce($_POST['_wpnonce'], 'itelic-renew-keys-checkout')) { it_exchange_add_message('error', __("Sorry this request has expired. Please refresh and try again.", Plugin::SLUG)); return; } $session = $this->get_cache_data(); $keys = $_POST['itelic_key']; foreach ($session as $product => $key) { $product = str_replace('p', '', $product); if ($key === null) { if (isset($keys[$product])) { $session["p{$product}"] = $keys[$product]; } } } $this->set_cache_data($session); }
/** * When a renewal purchase is made, renew the renewed key. * * @internal * * @since 1.0 * * @param int $transaction_id */ function renew_key_on_renewal_purchase($transaction_id) { $transaction = it_exchange_get_transaction($transaction_id); foreach ($transaction->get_products() as $product) { if (isset($product['renewed_key']) && $product['renewed_key']) { $key = itelic_get_key($product['renewed_key']); if ($key) { try { $key->renew($transaction); } catch (\UnexpectedValueException $e) { it_exchange_add_message('error', $e->getMessage()); } } } } }