Changeset 3026682
- Timestamp:
- 01/25/2024 10:00:03 AM (2 years ago)
- Location:
- robokassa/trunk
- Files:
-
- 5 edited
-
classes/Robokassa/Payment/RobokassaPayAPI.php (modified) (22 diffs)
-
labelsClasses.php (modified) (1 diff)
-
payment-widget.php (modified) (4 diffs)
-
readme.txt (modified) (1 diff)
-
wp_robokassa.php (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
robokassa/trunk/classes/Robokassa/Payment/RobokassaPayAPI.php
r2988879 r3026682 6 6 7 7 /** 8 * @varstring8 *@varstring 9 9 */ 10 10 private $mrh_login; 11 11 12 12 /** 13 * @varstring13 *@varstring 14 14 */ 15 15 private $mrh_pass1; 16 16 17 17 /** 18 * @varstring18 *@varstring 19 19 */ 20 20 private $mrh_pass2; 21 21 22 22 /** 23 * @varstring23 *@varstring 24 24 */ 25 25 private $method; 26 26 27 27 /** 28 * @varstring28 *@varstring 29 29 */ 30 30 private $apiUrl; 31 31 32 32 /** 33 * @varstring33 *@varstring 34 34 */ 35 35 private $reply = ''; 36 36 37 37 /** 38 * @varstring38 *@varstring 39 39 */ 40 40 private $request = ''; 41 41 42 42 /** 43 * @returnstring43 *@returnstring 44 44 */ 45 45 public function getReply() { … … 48 48 49 49 /** 50 * @returnstring50 *@returnstring 51 51 */ 52 52 public function getRequest() { … … 55 55 56 56 /** 57 * @returnstring57 *@returnstring 58 58 */ 59 59 public function getSendResult() { … … 65 65 66 66 /** 67 * @param string$login68 * @param string$pass169 * @param string$pass270 * @param string$method67 *@paramstring$login 68 *@paramstring$pass1 69 *@paramstring$pass2 70 *@paramstring$method 71 71 */ 72 72 public function __construct($login, $pass1, $pass2, $method = 'md5') { … … 80 80 81 81 /** 82 * @param string$mthd83 * @param array$data84 * 85 * @returnarray82 *@paramstring$mthd 83 *@paramarray$data 84 * 85 *@returnarray 86 86 */ 87 87 private function sendRequest($mthd, $data) { … … 93 93 * он не использоваться, а если не пустой - используем его json-представление 94 94 * 95 * @param string$sum96 * @param string$invId97 * @param string$receiptJson98 * 99 * @returnstring95 *@paramstring$sum 96 *@paramstring$invId 97 *@paramstring$receiptJson 98 * 99 *@returnstring 100 100 */ 101 101 private function getSignatureString($sum, $invId, $receiptJson, $recurring = false) 102 102 { 103 104 105 103 $outCurrency = get_option('robokassa_out_currency'); 104 $holdPaymentParam = (get_option('robokassa_payment_hold_onoff') == 'true') ? 'true' : ''; 106 105 107 106 return \implode( … … 114 113 $outCurrency, 115 114 $receiptJson, 115 $holdPaymentParam, 116 urlencode((site_url('/?robokassa=result'))), 116 117 $this->mrh_pass1, 117 118 'shp_label=official_wordpress', … … 129 130 * Генерирует хеш для строки $string с помощью метода $method 130 131 * 131 * @param string$string132 * @param string$method133 * 134 * @returnstring135 * 136 * @throws\Exception132 *@paramstring$string 133 *@paramstring$method 134 * 135 *@returnstring 136 * 137 *@throws\Exception 137 138 */ 138 139 public function getSignature($string, $method = 'md5') { … … 147 148 * Генерирует форму, в Opencart модуле НЕ ИСПОЛЬЗУЕТСЯ! 148 149 * 149 * @param float$sum150 * @param int$invId151 * @param string$invDesc152 * @param string$test153 * @param string$incCurrLabel154 * @param array$receipt155 * 156 * @param null$email157 * @returnstring158 * 159 * @throws\Exception150 *@paramfloat$sum 151 *@paramint$invId 152 *@paramstring$invDesc 153 *@paramstring$test 154 *@paramstring$incCurrLabel 155 *@paramarray$receipt 156 * 157 *@paramnull$email 158 *@returnstring 159 * 160 *@throws\Exception 160 161 */ 161 162 public function createForm( … … 188 189 'OutSum' => $sum, 189 190 'InvId' => $invId, 191 'ResultUrl2' => urlencode(site_url('/?robokassa=result')), 190 192 'Desc' => $invDesc, 191 193 'shp_label' => 'official_wordpress', … … 193 195 'SignatureValue' => $this->getSignature($this->getSignatureString($sum, $invId, $receiptJson)), 194 196 ); 197 198 if (get_option('robokassa_payment_hold_onoff') == 'true') { 199 $formData['StepByStep'] = 'true'; 200 } 195 201 196 202 $formData['OutSumCurrency'] = get_option('robokassa_out_currency'); … … 233 239 234 240 /** 235 * @param string$formUrl236 * @param array$formData237 * 238 * @returnstring241 *@paramstring$formUrl 242 *@paramarray$formData 243 * 244 *@returnstring 239 245 */ 240 246 private function renderForm($formUrl, array $formData) { … … 255 261 foreach ($formData as $inputName => $inputValue){ 256 262 if($inputName != 'IsTest'){ 257 $value = htmlspecialchars($inputValue, ENT_COMPAT, 'UTF-8');263 $value = htmlspecialchars($inputValue,ENT_COMPAT, 'UTF-8'); 258 264 259 265 if($lastParam == $inputValue){ … … 276 282 foreach ($formData as $inputName => $inputValue){ 277 283 if($inputName != 'IsTest'){ 278 $value = htmlspecialchars($inputValue, ENT_COMPAT, 'UTF-8');284 $value = htmlspecialchars($inputValue,ENT_COMPAT, 'UTF-8'); 279 285 280 286 if($lastParam == $inputValue){ … … 296 302 foreach ($formData as $inputName => $inputValue){ 297 303 if($inputName != 'IsTest'){ 298 $value = htmlspecialchars($inputValue, ENT_COMPAT, 'UTF-8');304 $value = htmlspecialchars($inputValue,ENT_COMPAT, 'UTF-8'); 299 305 300 306 if($lastParam == $inputValue){ … … 310 316 }else { 311 317 $form = '<div class="preloader"> 312 <svg class="preloader__image" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">313 <path fill="currentColor"314 d="M304 48c0 26.51-21.49 48-48 48s-48-21.49-48-48 21.49-48 48-48 48 21.49 48 48zm-48 368c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.49-48-48-48zm208-208c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.49-48-48-48zM96 256c0-26.51-21.49-48-48-48S0 229.49 0 256s21.49 48 48 48 48-21.49 48-48zm12.922 99.078c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48c0-26.509-21.491-48-48-48zm294.156 0c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48c0-26.509-21.49-48-48-48zM108.922 60.922c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.491-48-48-48z">315 </path>316 </svg>317 </div>318 <style>319 .preloader {320 position: fixed;321 left: 0;322 top: 0;323 right: 0;324 bottom: 0;325 overflow: hidden;326 /* фоновый цвет */327 background: #e0e0e0;328 z-index: 1001;329 }330 331 .preloader__image {332 position: relative;333 top: 50%;334 left: 50%;335 width: 70px;336 height: 70px;337 margin-top: -35px;338 margin-left: -35px;339 text-align: center;340 animation: preloader-rotate 2s infinite linear;341 }342 343 @keyframes preloader-rotate {344 100% {345 transform: rotate(360deg);346 }347 }348 349 .loaded_hiding .preloader {350 transition: 0.3s opacity;351 opacity: 0;352 }353 354 .loaded .preloader {355 display: none;356 }357 </style>358 <script>359 window.onload = function () {360 document.body.classList.add("loaded_hiding");361 window.setTimeout(function () {362 document.body.classList.add("loaded");363 document.body.classList.remove("loaded_hiding");364 }, 1000);365 }366 </script>';318 <svg class="preloader__image" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"> 319 <path fill="currentColor" 320 d="M304 48c0 26.51-21.49 48-48 48s-48-21.49-48-48 21.49-48 48-48 48 21.49 48 48zm-48 368c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.49-48-48-48zm208-208c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.49-48-48-48zM96 256c0-26.51-21.49-48-48-48S0 229.49 0 256s21.49 48 48 48 48-21.49 48-48zm12.922 99.078c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48c0-26.509-21.491-48-48-48zm294.156 0c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48c0-26.509-21.49-48-48-48zM108.922 60.922c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.491-48-48-48z"> 321 </path> 322 </svg> 323 </div> 324 <style> 325 .preloader { 326 position: fixed; 327 left: 0; 328 top: 0; 329 right: 0; 330 bottom: 0; 331 overflow: hidden; 332 /* фоновый цвет */ 333 background: #e0e0e0; 334 z-index: 1001; 335 } 336 337 .preloader__image { 338 position: relative; 339 top: 50%; 340 left: 50%; 341 width: 70px; 342 height: 70px; 343 margin-top: -35px; 344 margin-left: -35px; 345 text-align: center; 346 animation: preloader-rotate 2s infinite linear; 347 } 348 349 @keyframes preloader-rotate { 350 100% { 351 transform: rotate(360deg); 352 } 353 } 354 355 .loaded_hiding .preloader { 356 transition: 0.3s opacity; 357 opacity: 0; 358 } 359 360 .loaded .preloader { 361 display: none; 362 } 363 </style> 364 <script> 365 window.onload = function () { 366 document.body.classList.add("loaded_hiding"); 367 window.setTimeout(function () { 368 document.body.classList.add("loaded"); 369 document.body.classList.remove("loaded_hiding"); 370 }, 1000); 371 } 372 </script>'; 367 373 $form .= "<form action=\"$formUrl\" method=\"POST\">"; 368 374 369 375 foreach ($formData as $inputName => $inputValue) { 370 $value = htmlspecialchars($inputValue, ENT_COMPAT, 'UTF-8');376 $value = htmlspecialchars($inputValue,ENT_COMPAT, 'UTF-8'); 371 377 372 378 $form .= "<input type=\"hidden\" name=\"$inputName\" value=\"$value\">"; … … 383 389 * Отправляет СМС с помощью GET-запроса на робокассу 384 390 * 385 * @param string$phone386 * @param string$message387 * 388 * @returnbool389 * @throws\Exception391 *@paramstring$phone 392 *@paramstring$message 393 * 394 *@returnbool 395 *@throws\Exception 390 396 */ 391 397 public function sendSms($phone, $message) { … … 411 417 * Запрашиват размер комиссии в процентах для конкретного способа оплаты 412 418 * 413 * @param string $incCurrLabelКодовое имя метода оплаты414 * @param int $sumСтоимость товара415 * 416 * @returnfloat Комиссия метода в %419 *@paramstring$incCurrLabelКодовое имя метода оплаты 420 *@paramint$sumСтоимость товара 421 * 422 *@returnfloat Комиссия метода в % 417 423 */ 418 424 public function getCommission($incCurrLabel, $sum = 10000) { … … 437 443 * Возвращает сумму к оплате с учетом комиссий. 438 444 * 439 * @param string $incCurrLabelКодовое имя метода оплаты440 * @param int $sumСтоимость товара441 * 442 * @returnfloat Стоимость, которую необходимо передавать в Робокассу.445 *@paramstring$incCurrLabelКодовое имя метода оплаты 446 *@paramint$sumСтоимость товара 447 * 448 *@returnfloat Стоимость, которую необходимо передавать в Робокассу. 443 449 */ 444 450 public function getCommissionSum($incCurrLabel, $sum) { … … 455 461 * Запрашивает и парсит в массив все возможные способы оплаты для данного магазина 456 462 * 457 * @returnarray463 *@returnarray 458 464 */ 459 465 public function getCurrLabels() … … 468 474 * Парсит XML в JSON 469 475 * 470 * @param string$url471 * 472 * @returnstring476 *@paramstring$url 477 * 478 *@returnstring 473 479 */ 474 480 public function parseXmlAndConvertToJson($url) { … … 483 489 * Запрашивает у робокассы подтверждение платежа 484 490 * 485 * @param int$invId486 * 487 * @returnbool491 *@paramint$invId 492 * 493 *@returnbool 488 494 */ 489 495 public function reCheck($invId) { -
robokassa/trunk/labelsClasses.php
r2983991 r3026682 53 53 function robokassa_payment_add_WC_WP_robokassa_class($methods = null) { 54 54 $methods[] = 'payment_robokassa_pay_method_request_all'; 55 if (get_option('robokassa_podeli') == '1' && WC()->cart !== null && isset(WC()->cart->total) && WC()->cart->total >= 300 && WC()->cart->total <= 3 0000) {55 if (get_option('robokassa_podeli') == '1' && WC()->cart !== null && isset(WC()->cart->total) && WC()->cart->total >= 300 && WC()->cart->total <= 35000) { 56 56 $methods[] = 'payment_robokassa_pay_method_request_Podeli'; 57 57 } -
robokassa/trunk/payment-widget.php
r3002256 r3026682 12 12 $podeli_6w_date = strftime('%d %b', strtotime('+6 weeks')); 13 13 14 if (get_option('robokassa_payment_podeli_widget_onoff') === 'true' && $price > 300 && $price < 3 0000) {14 if (get_option('robokassa_payment_podeli_widget_onoff') === 'true' && $price > 300 && $price < 35000) { 15 15 if (get_option('robokassa_podeli_widget_style') == 0) { 16 16 echo ' … … 628 628 $podeli_6w_date = strftime('%d %b', strtotime('+6 weeks')); 629 629 630 if (get_option('robokassa_payment_podeli_widget_onoff') === 'true' && $price > 300 && $price < 3 0000) {630 if (get_option('robokassa_payment_podeli_widget_onoff') === 'true' && $price > 300 && $price < 35000) { 631 631 echo ' 632 632 <div class="wiget-block-wrapper"> … … 732 732 $podeli_6w_date = strftime('%d %b', strtotime('+6 weeks')); 733 733 734 if (get_option('robokassa_payment_podeli_widget_onoff') === 'true' && $price > 300 && $price < 3 0000) {734 if (get_option('robokassa_payment_podeli_widget_onoff') === 'true' && $price > 300 && $price < 35000) { 735 735 echo ' 736 736 <div class="wiget-block__prompt"> … … 798 798 $monthlyPayment = round($monthlyPayment); 799 799 800 if (get_option('robokassa_payment_podeli_widget_onoff') === 'true' && $price > 300 && $price < 3 0000) {800 if (get_option('robokassa_payment_podeli_widget_onoff') === 'true' && $price > 300 && $price < 35000) { 801 801 echo ' 802 802 <div class="wiget-block" style="margin-bottom: 0px"> -
robokassa/trunk/readme.txt
r3002256 r3026682 78 78 == Changelog == 79 79 80 = 1.5.8 = 81 * Добавлена функционал отложенных платежей (холдирование) 82 * Изменена максимальная сумма корзины для "Подели" 83 * Переработана логика работы параметра OutSumCurrency 84 80 85 = 1.5.7 = 81 86 * Добавлена возможность установить валюту по умолчанию из настроек WooCommerce 82 87 * Устранены ошибки 83 84 88 85 89 = 1.5.6 = -
robokassa/trunk/wp_robokassa.php
r3002256 r3026682 6 6 * Author: Robokassa 7 7 * Author URI: https://robokassa.com 8 * Version: 1.5. 78 * Version: 1.5.8 9 9 */ 10 10 … … 41 41 \spl_autoload_register( 42 42 function ($className) { 43 $file = __DIR__. '/classes/' . \str_replace('\\', '/', $className) . '.php';43 $file =__DIR__. '/classes/' . \str_replace('\\', '/', $className) . '.php'; 44 44 45 45 if (file_exists($file)) … … 97 97 98 98 add_action('woocommerce_order_status_changed', 'robokassa_2check_send', 10, 3); 99 add_action('woocommerce_order_status_changed', 'robokassa_hold_confirm', 10, 4); 100 add_action('woocommerce_order_status_changed', 'robokassa_hold_cancel', 10, 4); 101 add_action('robokassa_cancel_payment_event', 'robokassa_hold_cancel_after5', 10, 1); 99 102 100 103 … … 171 174 $debug .= "order_id = $order_id \r\n"; 172 175 173 $roboDataBase = new RoboDataBase(mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD,DB_NAME));176 $roboDataBase = new RoboDataBase(mysqli_connect(DB_HOST,DB_USER,DB_PASSWORD,DB_NAME)); 174 177 $robokassa = new RobokassaPayAPI($mrhLogin, get_option('robokassa_payment_shoppass1'), get_option('robokassa_payment_shoppass2')); 175 178 … … 309 312 310 313 (new RobokassaSms( 311 (new RoboDataBase(mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD,DB_NAME))),314 (new RoboDataBase(mysqli_connect(DB_HOST,DB_USER,DB_PASSWORD,DB_NAME))), 312 315 (new RobokassaPayAPI( 313 316 get_option('robokassa_payment_MerchantLogin'), … … 325 328 } 326 329 } 330 } elseif ((get_option('robokassa_payment_hold_onoff') == 'true') && 331 strpos($_SERVER['CONTENT_TYPE'], 'application/json') !== false) { 332 333 $input_data = file_get_contents('php://input'); 334 335 // Разбиваем JWT на три части 336 $token_parts = explode('.', $input_data); 337 338 // Проверяем, что есть три части 339 if (count($token_parts) === 3) { 340 // Декодируем вторую часть (полезные данные) 341 $json_data = json_decode(base64_decode($token_parts[1]), true); 342 343 // Проверяем наличие ключевого поля "state" со значением "HOLD" 344 if (isset($json_data['data']['state']) && $json_data['data']['state'] === 'HOLD') { 345 // Изменяем статус заказа 346 $order = new WC_Order($json_data['data']['invId']); 347 $date_in_five_days = date('Y-m-d H:i:s', strtotime('+5 days')); 348 $order->add_order_note("Robokassa: Платеж успешно подтвержден. Он ожидает подтверждения до {$date_in_five_days}, после чего автоматически отменится"); 349 $order->update_status('on-hold'); 350 351 // Добавляем событие, которое делает unhold через 5 дней 352 wp_schedule_single_event(strtotime('+5 days'), 'robokassa_cancel_payment_event', array($order->get_id())); 353 } 354 if (isset($json_data['data']['state']) && $json_data['data']['state'] === 'OK') { 355 // Изменяем статус заказа 356 $order = new WC_Order($json_data['data']['invId']); 357 $order->add_order_note("Robokassa: Платеж успешно подтвержден"); 358 $order->update_status('processing'); 359 360 } 361 http_response_code(200); 362 } else { 363 http_response_code(400); 364 } 327 365 } else { 328 329 366 $order = new WC_Order($_REQUEST['InvId']); 330 367 $order->add_order_note('Bad CRC'); … … 1107 1144 1108 1145 $curl = curl_init('https://ws.roboxchange.com/RoboFiscal/Receipt/Attach'); 1109 curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");1110 curl_setopt($curl, CURLOPT_POSTFIELDS, $startupHash . '.' . $sign);1111 curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);1112 curl_setopt($curl, CURLOPT_HTTPHEADER, array(1146 curl_setopt($curl,CURLOPT_CUSTOMREQUEST, "POST"); 1147 curl_setopt($curl,CURLOPT_POSTFIELDS, $startupHash . '.' . $sign); 1148 curl_setopt($curl,CURLOPT_RETURNTRANSFER, true); 1149 curl_setopt($curl,CURLOPT_HTTPHEADER, array( 1113 1150 'Content-Type: application/json', 1114 1151 'Content-Length: ' . strlen($startupHash . '.' . $sign)) … … 1120 1157 } 1121 1158 } 1159 1160 function robokassa_hold_confirm($order_id, $old_status, $new_status, $order) { 1161 // Проверяем, что статус был изменен с "on-hold" на "processing" (обработка) 1162 if ((get_option('robokassa_payment_hold_onoff') == 'true') 1163 && $old_status === 'on-hold' && $new_status === 'processing') { 1164 1165 $order = wc_get_order($order_id); 1166 $order_items = $order->get_items(); 1167 $shipping_total = $order->get_shipping_total(); 1168 1169 $receipt_items = array(); 1170 foreach ($order_items as $item) { 1171 $item_name = $item->get_name(); 1172 $item_quantity = $item->get_quantity(); 1173 $item_sum = $item->get_total(); 1174 $receipt_items[] = array( 1175 'name' => $item_name, 1176 'quantity' => $item_quantity, 1177 'sum' => $item_sum, 1178 'tax' => get_option('robokassa_payment_tax'), 1179 'payment_method' => \get_option('robokassa_payment_paymentMethod'), 1180 'payment_object' => \get_option('robokassa_payment_paymentObject'), 1181 'tax' => get_option('robokassa_payment_tax'), 1182 ); 1183 } 1184 1185 if ($shipping_total > 0) { 1186 $receipt_items[] = array( 1187 'name' => 'Доставка', 1188 'quantity' => 1, 1189 'cost' => $shipping_total, 1190 'sum' => $shipping_total * 1, 1191 'tax' => get_option('robokassa_payment_tax'), 1192 'payment_method' => 'full_payment', 1193 'payment_object' => get_option('robokassa_payment_paymentObject'), 1194 ); 1195 } 1196 1197 $request_data = array( 1198 'MerchantLogin' => get_option('robokassa_payment_MerchantLogin'), 1199 'InvoiceID' => $order_id, 1200 'OutSum' => $order->get_total(), 1201 'Receipt' => json_encode(array('items' => $receipt_items)), 1202 ); 1203 1204 $merchant_login = get_option('robokassa_payment_MerchantLogin'); 1205 $password1 = get_option('robokassa_payment_shoppass1'); 1206 1207 $signature_value = md5("{$merchant_login}:{$request_data['OutSum']}:{$request_data['InvoiceID']}:{$request_data['Receipt']}:{$password1}"); 1208 $request_data['SignatureValue'] = $signature_value; 1209 1210 $response = wp_remote_post('https://auth.robokassa.ru/Merchant/Payment/Confirm', array( 1211 'body' => $request_data, 1212 )); 1213 1214 /* if (is_wp_error($response)) { 1215 error_log('Error sending payment request: ' . $response->get_error_message()); 1216 $order->add_order_note('Error sending payment request: ' . $response->get_error_message()); 1217 } else { 1218 $body = wp_remote_retrieve_body($response); 1219 $order->add_order_note('Robokassa: ошибка проведения платежа' . json_encode($request_data) . $body); 1220 }*/ 1221 } 1222 } 1223 1224 function robokassa_hold_cancel($order_id, $old_status, $new_status, $order) { 1225 // Проверяем, что статус был изменен с "on-hold" на "Canceled" 1226 if ((get_option('robokassa_payment_hold_onoff') == 'true') && 1227 $old_status === 'on-hold' && $new_status === 'cancelled') { 1228 1229 $request_data = array( 1230 'MerchantLogin' => get_option('robokassa_payment_MerchantLogin'), 1231 'InvoiceID' => $order_id, 1232 'OutSum' => $order->get_total(), 1233 ); 1234 1235 $merchant_login = get_option('robokassa_payment_MerchantLogin'); 1236 $password1 = get_option('robokassa_payment_shoppass1'); 1237 1238 $signature_value = md5("{$merchant_login}::{$request_data['InvoiceID']}:{$password1}"); 1239 $request_data['SignatureValue'] = $signature_value; 1240 1241 $response = wp_remote_post('https://auth.robokassa.ru/Merchant/Payment/Cancel', array( 1242 'body' => $request_data, 1243 )); 1244 1245 if (is_wp_error($response)) { 1246 $order->add_order_note('Error sending payment request: ' . $response->get_error_message()); 1247 } else { 1248 $order->add_order_note('Robokassa: холдирование было отменено вами, либо автоматически после 5 дней ожидания'); 1249 } 1250 } 1251 } 1252 1253 function robokassa_hold_cancel_after5($order_id) { 1254 // Проверяем, что заказ существует 1255 $order = wc_get_order($order_id); 1256 if ($order) { 1257 // Проверяем текущий статус заказа 1258 if ($order->get_status() === 'on-hold') { 1259 // Отменяем заказ и добавляем соответствующее уведомление 1260 $request_data = array( 1261 'MerchantLogin' => get_option('robokassa_payment_MerchantLogin'), 1262 'InvoiceID' => $order_id, 1263 'OutSum' => $order->get_total(), 1264 ); 1265 1266 $merchant_login = get_option('robokassa_payment_MerchantLogin'); 1267 $password1 = get_option('robokassa_payment_shoppass1'); 1268 1269 $signature_value = md5("{$merchant_login}::{$request_data['InvoiceID']}:{$password1}"); 1270 $request_data['SignatureValue'] = $signature_value; 1271 1272 $response = wp_remote_post('https://auth.robokassa.ru/Merchant/Payment/Cancel', array( 1273 'body' => $request_data, 1274 )); 1275 1276 if (is_wp_error($response)) { 1277 $order->add_order_note('Error sending payment request: ' . $response->get_error_message()); 1278 } 1279 1280 $order->update_status('cancelled'); 1281 } 1282 } 1283 } 1284
Note: See TracChangeset
for help on using the changeset viewer.