3namespace Sale\Handlers\PaySystem;
7use Bitrix\Main\Request;
8use Bitrix\Main\Type\DateTime;
9use Bitrix\Main\Localization\Loc;
11use Bitrix\Sale\PaymentCollection;
12use Bitrix\Sale\PaySystem;
13use Bitrix\Sale\Payment;
14use Bitrix\Sale\PriceMaths;
33 $busValues[
'LIQPAY_PATH_TO_RESULT_URL'] = $this->getPathResultUrl(
$payment);
36 <version>1.2</version>
37 <result_url>".$busValues[
'LIQPAY_PATH_TO_RESULT_URL'].
"</result_url>
38 <server_url>".$busValues[
'LIQPAY_PATH_TO_SERVER_URL'].
"</server_url>
39 <merchant_id>".$busValues[
'LIQPAY_MERCHANT_ID'].
"</merchant_id>
40 <order_id>PAYMENT_".$busValues[
'PAYMENT_ID'].
"</order_id>
41 <amount>".$busValues[
"PAYMENT_SHOULD_PAY"].
"</amount>
42 <currency>".$busValues[
'PAYMENT_CURRENCY'].
"</currency>
43 <description>".$this->getPaymentDescription(
$payment).
"</description>
44 <default_phone>".$busValues[
'BUYER_PERSON_PHONE'].
"</default_phone>
45 <pay_way>".$busValues[
'LIQPAY_PAY_METHOD'].
"</pay_way>
48 $signature = base64_encode(sha1($busValues[
'LIQPAY_SIGN'].$xml.$busValues[
'LIQPAY_SIGN'], 1));
52 'OPERATION_XML' => base64_encode($xml),
53 'SIGNATURE' => $signature,
56 if ($busValues[
'PAYMENT_CURRENCY'] ==
"RUB")
57 $params[
'PAYMENT_CURRENCY'] =
"RUR";
69 return array(
'operation_xml',
'signature');
72 protected static function isMyResponseExtended(Request
$request, $paySystemId)
74 $paymentId = self::getValueByTag(self::getOperationXml(
$request),
'order_id');
75 $paymentId = (int)str_replace(
"PAYMENT_",
"", $paymentId);
76 $payment = Sale\Repository\PaymentRepository::getInstance()->getById($paymentId);
78 $merchantId = Sale\BusinessValue::get(
79 'LIQPAY_MERCHANT_ID', PaySystem\Service::PAY_SYSTEM_PREFIX . $paySystemId,
$payment
81 $merchantIdFromRequest = self::getValueByTag(self::getOperationXml(
$request),
'merchant_id');
83 return $merchantId === $merchantIdFromRequest;
93 if (
$request->get(
'operation_xml') !==
null)
113 $sum = self::getValueByTag(self::getOperationXml(
$request),
'amount');
116 return PriceMaths::roundPrecision($paymentSum) === PriceMaths::roundPrecision(
$sum);
123 public function getPaymentIdFromRequest(Request
$request)
125 $orderId = self::getValueByTag(self::getOperationXml(
$request),
'order_id');
126 return str_replace(
"PAYMENT_",
"",
$orderId);
136 self::ACTIVE_URL =>
'https://www.liqpay.ua/?do=clickNbuy'
148 $result =
new PaySystem\ServiceResult();
150 if (
$request->get(
'signature') ===
null ||
$request->get(
'operation_xml') ===
null)
152 $errorMessage = Loc::getMessage(
'SALE_HPS_LIQPAY_POST_ERROR');
155 PaySystem\Logger::addError(
'LiqPay: processRequest: '.
$errorMessage);
158 $status = self::getValueByTag(self::getOperationXml(
$request),
'status');
169 return new PaySystem\ServiceResult();
174 PaySystem\Logger::addError(
'LiqPay: processRequest: Incorrect hash');
188 $result =
new PaySystem\ServiceResult();
196 $statusMessage =
'status: '.self::getValueByTag(
$response,
'status').
'; ';
197 $statusMessage .=
'transaction_id: '.self::getValueByTag(
$response,
'transaction_id').
'; ';
198 $statusMessage .=
'pay_way: '.self::getValueByTag(
$response,
'pay_way').
'; ';
199 $statusMessage .=
'payment_id: '.self::getValueByTag(
$response,
'order_id').
'; ';
204 "PS_STATUS_CODE" => mb_substr(self::getValueByTag(
$response,
'status'), 0, 5),
206 "PS_STATUS_MESSAGE" => $statusMessage,
207 "PS_SUM" => self::getValueByTag(
$response,
'amount'),
208 "PS_CURRENCY" => self::getValueByTag(
$response,
'currency'),
209 "PS_RESPONSE_DATE" =>
new DateTime(),
216 $result->setOperationType(PaySystem\ServiceResult::MONEY_COMING);
220 PaySystem\Logger::addError(
'LiqPay: processNoticeAction: Incorrect sum');
232 return [
'RUB',
'USD',
'EUR',
'UAH'];
240 private static function getValueByTag($string, $tag)
242 $string = str_replace(
"\n",
"", str_replace(
"\r",
"", $string));
243 $open =
'<'.$tag.
'>';
245 $start = mb_strpos($string, $open) + mb_strlen($open);
246 $end = mb_strpos($string, $close);
255 private static function getOperationXml(Request
$request)
257 static $operationXml =
'';
259 if ($operationXml ===
'')
260 $operationXml = base64_decode(
$request->get(
'operation_xml'));
262 return $operationXml;
272 private function getPaymentDescription(Payment
$payment)
275 $collection =
$payment->getCollection();
276 $order = $collection->getOrder();
277 $userEmail =
$order->getPropertyCollection()->getUserEmail();
288 $payment->getField(
'ACCOUNT_NUMBER'),
289 $order->getField(
'ACCOUNT_NUMBER'),
292 ($userEmail) ? $userEmail->getValue() :
''
294 $this->getBusinessValue(
$payment,
'LIQPAY_PAYMENT_DESCRIPTION')
302 private function getPathResultUrl(Payment
$payment)
306 return str_replace(
'&',
'&',
$url);
if(!Loader::includeModule('catalog')) if(!AccessController::getCurrent() ->check(ActionDictionary::ACTION_PRICE_EDIT)) if(!check_bitrix_sessid()) $request
getUrl(Payment $payment=null, $action)
showTemplate(Payment $payment=null, $template='')
getParamsBusValue(Payment $payment=null)
setExtraParams(array $values)
getBusinessValue(Payment $payment=null, $code)
static getIndicativeFields()
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
if(Loader::includeModule( 'bitrix24')) elseif(Loader::includeModule('intranet') &&CIntranetUtils::getPortalZone() !=='ru') $description
while($arParentIBlockProperty=$dbParentIBlockProperty->Fetch()) $errorMessage
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']