403Webshell
Server IP : 80.87.202.40  /  Your IP : 216.73.216.169
Web Server : Apache
System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64
User : bitrix ( 600)
PHP Version : 8.2.27
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : OFF |  Sudo : ON |  Pkexec : ON
Directory :  /home/bitrix/ext_www/ilovecveti.ru/bitrix/modules/vampirus.yandex/payment/yoomoneyvs/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/bitrix/ext_www/ilovecveti.ru/bitrix/modules/vampirus.yandex/payment/yoomoneyvs/handler.php
<?php

namespace Sale\Handlers\PaySystem;

use Bitrix\Main\Error;
use Bitrix\Main\Localization\Loc;
use Bitrix\Main\Request;
use Bitrix\Main\Type\DateTime;
use Bitrix\Sale\Payment;
use Bitrix\Sale\PaySystem;
use Bitrix\Sale\PriceMaths;

Loc::loadMessages(__FILE__);
\CModule::IncludeModule("vampirus.yandex");

class YoomoneyVSHandler extends PaySystem\ServiceHandler
{

	/**
	 * @param Payment $payment
	 * @param Request|null $request
	 * @return PaySystem\ServiceResult
	 */
	public function initiatePay(Payment $payment, Request $request = null)
	{

		$amount      = PriceMaths::roundPrecision($payment->getSum());
		$wallet      = $this->getBusinessValue($payment, 'YOOMONEY_WALLET');
		$orderId     = $payment->getOrderId();
		$paymentType = $this->getBusinessValue($payment, 'PAYMENT_TYPE');

		switch ($paymentType) {
			case '1':$paymentType = 'AC';
				break;
			case '2':$paymentType = 'MC';
				break;
			default:$paymentType = 'PC';
		}

		$notice = '';

		if ($amount > 15000 && $paymentType == 'AC') {
			$order = $payment->getOrder();
			$collection = $order->getPaymentCollection();
			while($amount > 15000) {
				$service = \Bitrix\Sale\PaySystem\Manager::getObjectById($this->service->getField('ID'));
				$newPayment = $collection->createItem($service);

				$newPayment->setField('SUM', 15000);

				$amount -= 15000;
			}
			$payment->setField('SUM', $amount);
			$order->save();
			$notice = Loc::getMessage('VAMPIRUS.YOOMONEY_ORDER_PAYMENT_SPLIT');
		}




		$order = \Bitrix\Sale\Order::load($orderId);

		$successUrl = $this->getSuccessUrl($payment);

		$rsSites = \CSite::GetByID(SITE_ID);
		$arSite  = $rsSites->Fetch();

		$orderNumber = $payment->getField("ACCOUNT_NUMBER");

		$params = array(
			'notice' => $notice,
			'form' => array(
				'receiver'      => $wallet,
				'sum'           => $amount,
				'successURL'    => $successUrl,
				'label'         => $payment->getId(),
				'formcomment'   => $arSite['SITE_NAME'],
				'short-dest'    => $orderNumber,
				'targets'       => Loc::getMessage('VAMPIRUS.YOOMONEY_ORDER_PAYMENT_MESSAGE') . $orderNumber,
				'paymentType'   => $paymentType,
				'need-fio'      => 'false',
				'need-email'    => 'false',
				'need-phone'    => 'false',
				'need-address'  => 'false',
				'quickpay-form' => 'shop',

			),
		);

		$this->setExtraParams($params);

		return $this->showTemplate($payment, "template");
	}

	/**
	 * @return array
	 */
	public static function getIndicativeFields()
	{
		return array('label', 'sha1_hash', 'notification_type');
	}

	/**
	 * @param Payment $payment
	 * @param $request
	 * @return bool
	 */
	private function isCorrectHash(Payment $payment, Request $request)
	{
		$str = $request->get('notification_type') . '&' .
		$request->get('operation_id') . '&' .
		$request->get('amount') . '&' .
		$request->get('currency') . '&' .
		$request->get('datetime') . '&' .
		$request->get('sender') . '&' .
		$request->get('codepro') . '&' .
		$this->getBusinessValue($payment, 'YOOMONEY_SECRET') . '&' .
		$request->get('label');
		return strcmp($request->get('sha1_hash'), sha1($str)) === 0;
	}

	/**
	 * @param Request $request
	 * @return mixed
	 */
	public function getPaymentIdFromRequest(Request $request)
	{
		return $request->get('label');
	}

	/**
	 * @return mixed
	 */
	protected function getUrlList()
	{
		return array(
			'pay' => array(
				self::ACTIVE_URL => 'https://yoomoney.ru/quickpay/confirm.xml',
			),
		);
	}

	/**
	 * @param Payment $payment
	 * @param Request $request
	 * @return PaySystem\ServiceResult
	 */
	public function processRequest(Payment $payment, Request $request)
	{
		$result = new PaySystem\ServiceResult();

		if ($this->isCorrectHash($payment, $request)) {
			return $this->processNoticeAction($payment, $request);
		} else {
			PaySystem\ErrorLog::add(array(
				'ACTION'  => 'processRequest',
				'MESSAGE' => 'Incorrect hash',
			));
			$result->addError(new Error('Incorrect hash'));
		}

		return $result;
	}

	/**
	 * @param Payment $payment
	 * @param Request $request
	 * @return PaySystem\ServiceResult
	 */
	private function processNoticeAction(Payment $payment, Request $request)
	{
		$result = new PaySystem\ServiceResult();

		$fields = array(
			"PS_STATUS"             => "Y",
			"PS_STATUS_CODE"        => $request->get('orderpayment_type'),
			"PS_STATUS_DESCRIPTION" => $request->get('operation_id'),
			"PS_STATUS_MESSAGE"     => Loc::getMessage('VAMPIRUS.YOOMONEY_PAYMENT_RECEIVED'),
			"PS_SUM"                => $request->get('amount'),
			"PS_RESPONSE_DATE"      => new DateTime(),
		);

		$result->setPsData($fields);

		$result->setOperationType(PaySystem\ServiceResult::MONEY_COMING);

		return $result;
	}

	/**
	 * @param Payment $payment
	 * @return bool
	 */
	protected function isTestMode(Payment $payment = null)
	{
		return false;
	}

	/**
	 * @return array
	 */
	public function getCurrencyList()
	{
		return array('RUB');
	}

	/**
	 * @param Payment $payment
	 * @return mixed|string
	 */
	private function getSuccessUrl(Payment $payment)
	{
		return $this->getBusinessValue($payment, 'SUCCESS_URL') ?: $this->service->getContext()->getUrl();
	}

}

Youez - 2016 - github.com/yon3zu
LinuXploit