3namespace Sale\Handlers\PaySystem;
5use Bitrix\Main\Application;
7use Bitrix\Main\Localization\Loc;
8use Bitrix\Main\Request;
9use Bitrix\Main\Type\DateTime;
10use Bitrix\Main\Web\HttpClient;
11use Bitrix\Sale\PaySystem;
12use Bitrix\Sale\Payment;
13use Bitrix\Sale\PaySystem\ServiceResult;
15Loc::loadMessages(__FILE__);
33 if (
$request->get(
'ccard_num') !==
null)
35 $serviceResult =
new ServiceResult();
44 $queryString =
"x_version=3.1";
45 $queryString .=
"&x_login=".urlencode(
$params[
"AUTHORIZE_LOGIN"]);
46 $queryString .=
"&x_tran_key=".urlencode(
$params[
"AUTHORIZE_TRANSACTION_KEY"]);
47 $queryString .=
"&x_test_request=".($this->isTestMode(
$payment) ?
"TRUE" :
"FALSE");
49 $queryString .=
"&x_delim_data=True";
50 $queryString .=
"&x_relay_response=False";
51 $queryString .=
"&x_delim_char=,";
52 $queryString .=
"&x_encap_char=|";
55 "x_first_name" =>
"BUYER_PERSON_NAME_FIRST",
"x_last_name" =>
"BUYER_PERSON_LAST_NAME",
56 "x_company" =>
"BUYER_PERSON_COMPANY",
"x_address" =>
"BUYER_PERSON_ADDRESS",
"x_city" =>
"BUYER_PERSON_CITY",
57 "x_state" =>
"BUYER_PERSON_STATE",
"x_zip" =>
"BUYER_PERSON_ZIP",
"x_country" =>
"BUYER_PERSON_COUNTRY",
58 "x_phone" =>
"BUYER_PERSON_PHONE",
"x_fax" =>
"BUYER_PERSON_FAX"
62 if (array_key_exists($value,
$params))
63 $queryString .=
"&".$key.
"=".urlencode(
$params[
$key]);
66 $queryString .=
"&x_cust_id=".urlencode(
$GLOBALS[
"SALE_INPUT_PARAMS"][
"ORDER"][
"USER_ID"]);
67 $queryString .=
"&x_customer_ip=".urlencode(
$_SERVER[
"REMOTE_ADDR"]);
69 if (array_key_exists(
'BUYER_PERSON_EMAIL',
$params))
70 $queryString .=
"&x_email=".urlencode(
$params[
'BUYER_PERSON_EMAIL']);
72 $queryString .=
"&x_email_customer=FALSE";
73 $queryString .=
"&x_merchant_email=".urlencode(\COption::GetOptionString(
"sale",
"order_email",
""));
75 $queryString .=
"&x_invoice_num=".urlencode(
$params[
'PAYMENT_ID']);
76 $queryString .=
"&x_description=".urlencode(
$payment->getField(
'DATE_BILL'));
79 "x_ship_to_first_name" =>
"SHIP_BUYER_PERSON_NAME_FIRST",
"x_ship_to_last_name" =>
"SHIP_BUYER_PERSON_NAME_LAST",
80 "x_ship_to_company" =>
"SHIP_BUYER_PERSON_COMPANY",
"x_ship_to_address" =>
"SHIP_BUYER_PERSON_ADDRESS",
81 "x_ship_to_city" =>
"SHIP_BUYER_PERSON_CITY",
"x_ship_to_state" =>
"SHIP_BUYER_PERSON_STATE",
82 "x_ship_to_zip" =>
"SHIP_BUYER_PERSON_ZIP",
"x_ship_to_country" =>
"SHIP_BUYER_PERSON_COUNTRY"
86 if (array_key_exists($value,
$params))
87 $queryString .=
"&".$key.
"=".urlencode(
$params[
$key]);
90 $queryString .=
"&x_amount=".urlencode(
$params[
"PAYMENT_SHOULD_PAY"]);
91 $queryString .=
"&x_currency_code=".urlencode(
$payment->getField(
"CURRENCY"));
92 $queryString .=
"&x_method=CC";
93 $queryString .=
"&x_type=AUTH_CAPTURE";
94 $queryString .=
"&x_recurring_billing=NO";
95 $queryString .=
"&x_card_num=".urlencode(
$request->get(
'ccard_num'));
96 $queryString .=
"&x_exp_date=".urlencode(
$request->get(
'ccard_date1').$request->get(
'ccard_date2'));
97 $queryString .=
"&x_card_code=".urlencode(
$request->get(
'ccard_code'));
99 $queryString .=
"&x_tax=".urlencode(
$order->getTaxValue());
100 $queryString .=
"&x_freight=".urlencode(
$order->getDeliveryPrice());
102 $http =
new HttpClient();
106 $mass = explode(
"|,|",
"|,".
$result);
108 $hashValue =
$params[
"AUTHORIZE_SECRET_KEY"];
109 if ($hashValue <>
'')
111 if (md5($hashValue.($params[
"AUTHORIZE_LOGIN"]).$mass[7].sprintf(
"%.2f",
$params[
"PAYMENT_SHOULD_PAY"])) != mb_strtolower($mass[38]))
115 $mass[4] =
"MD5 transaction signature is incorrect!";
121 $psStatus = ((int)$mass[1] == 1) ?
"Y" :
"N";
122 $psStatusCode = $mass[3];
123 if ($psStatus ==
"Y")
125 $psStatusDescription =
"Approval Code: ".$mass[5].(!empty($mass[7]) ?
"; Transaction ID: ".$mass[7] :
"");
129 $psStatusDescription = (int)($mass[1]) == 2 ?
"Declined" :
"Error";
130 $psStatusDescription .=
": ".$mass[4].
" (Reason Code ".$mass[3].
" / Sub ".$mass[2].
")";
132 $errorMsg = ((int)$mass[1] == 2) ?
"Transaction was declined" :
"Error while processing transaction";
133 $errorMsg .=
": ".$mass[4].
" (".$mass[3].
"/".$mass[2].
")";
139 if (!empty($mass[6]))
140 $psStatusMsg .=
"\nAVS Result: [".$mass[6].
"] ".Loc::getMessage(
"AN_AVS_".$mass[6]).
";";
142 if (!empty($mass[39]))
143 $psStatusMsg .=
"\nCard Code Result: [".$mass[39].
"] ".Loc::getMessage(
'AN_CVV_'.$mass[39]).
";";
145 if (!empty($mass[40]))
146 $psStatusMsg .=
"\nCAVV: [".$mass[40].
"] ".Loc::getMessage(
'AN_CAVV_'.$mass[40]).
";";
149 "PS_STATUS" => $psStatus,
150 "PS_STATUS_CODE" => $psStatusCode,
151 "PS_STATUS_DESCRIPTION" => $psStatusDescription,
152 "PS_STATUS_MESSAGE" => $psStatusMsg,
153 "PS_SUM" => $mass[10],
154 "PS_CURRENCY" =>
$GLOBALS[
"SALE_INPUT_PARAMS"][
"ORDER"][
"CURRENCY"],
155 "PS_RESPONSE_DATE" =>
new DateTime()
157 $serviceResult->setPsData($psData);
165 return $serviceResult;
170 'PAYSYSTEM_ID' => $this->service->getField(
'ID'),
189 'pay' =>
'https://secure.authorize.net/gateway/transact.dll'
if(!Loader::includeModule('catalog')) if(!AccessController::getCurrent() ->check(ActionDictionary::ACTION_PRICE_EDIT)) if(!check_bitrix_sessid()) $request
getUrl(Payment $payment=null, $action)
initiatePay(Payment $payment, Request $request=null)
showTemplate(Payment $payment=null, $template='')
getParamsBusValue(Payment $payment=null)
setExtraParams(array $values)
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
$_SERVER["DOCUMENT_ROOT"]
if(!is_null($config))($config as $configItem)(! $configItem->isVisible()) $code
$GLOBALS['____1690880296']
if(intval($iTestTransaction) > 0) $arTmp
if(empty($signedUserToken)) $key
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']