Plugin Directory

Changeset 3036869


Ignore:
Timestamp:
02/16/2024 01:42:38 PM (2 years ago)
Author:
paygine
Message:

updated to ver. 2.2.0

Location:
paygine
Files:
38 added
6 edited

Legend:

Unmodified
Added
Removed
  • paygine/trunk/languages/paygine-payment_method-ru_RU.po

    r3011342 r3036869  
    66"Report-Msgid-Bugs-To: \n"
    77"POT-Creation-Date: 2023-11-20T20:39:42+03:00\n"
    8 "PO-Revision-Date: 2023-11-20T20:39:42+03:00\n"
     8"PO-Revision-Date: 2024-02-07T15:58:00+03:00\n"
    99"Last-Translator: Paygine\n"
    1010"Language-Team: ru_RU <[email protected]>\n"
     
    1919
    2020#. Plugin Name of the plugin
    21 msgid "Paygine payment method (Visa/MasterCard/MIR)"
    22 msgstr "Оплата с Paygine (Visa/MasterCard/МИР)"
     21msgid "Paygine payment module"
     22msgstr "Модуль оплаты Paygine"
    2323
    2424#. Plugin URI of the plugin
     
    3131
    3232#. Author of the plugin
    33 #: paygine-payment_method.php:110
    34 #: paygine-payment_method.php:111
    35 #: paygine-payment_method.php:855
     33#: paygine-payment_method.php:117
     34#: paygine-payment_method.php:1063
    3635msgid "Paygine"
    3736msgstr "Paygine"
    3837
     38#: paygine-payment_method.php:119
    3939msgid "To accept payments through the plugin, you need to apply to connect to Paygine on the website <a href=\"%1$s\" target=\"_blank\">%1$s</a> and enter into an agreement with the company.<br/>Support email: <a href=\"mailto:%2$s\">%2$s</a>"
    4040msgstr ""
     
    4242"<a href=\"%1$s\" target=\"_blank\">%1$s</a> и заключить договор с компанией.<br/>Электронная почта службы поддержки: <a href=\"mailto:%2$s\">%2$s</a>"
    4343
    44 #: paygine-payment_method.php:112
    45 #: paygine-payment_method.php:856
     44#: paygine-payment_method.php:137
     45#: paygine-payment_method.php:1064
    4646msgid "Payments with bank cards via the <a href=\"%s\" target=\"_blank\">Paygine</a> payment system."
    4747msgstr ""
     
    4949"href=\"%s\" target=\"_blank\">Paygine</a>."
    5050
    51 #: paygine-payment_method.php:145
     51#: paygine-payment_method.php:166
    5252msgid "Pay for your order in installments"
    5353msgstr "Оплатите заказ частями"
    5454
    55 #: paygine-payment_method.php:152
    56 msgid "Pay by QR"
    57 msgstr "Оплата по QR"
    58 
    59 #: paygine-payment_method.php:177
     55#: paygine-payment_method.php:221
     56msgid "Remove logo"
     57msgstr "Удалить логотип"
     58
     59#: paygine-payment_method.php:241
    6060msgid "Enable/Disable"
    6161msgstr "Включить/Выключить"
    6262
    63 #: paygine-payment_method.php:179
     63#: paygine-payment_method.php:243
    6464msgid "Enable Paygine checkout method"
    6565msgstr "Включить использование метода платежа Paygine"
    6666
    67 #: paygine-payment_method.php:184
     67#: paygine-payment_method.php:247
     68msgid "Title"
     69msgstr "Название"
     70
     71#: paygine-payment_method.php:249
     72msgid "Custom title for payment type"
     73msgstr "Свое название для типа платежа"
     74
     75#: paygine-payment_method.php:255
     76msgid "Description"
     77msgstr "Описание"
     78
     79#: paygine-payment_method.php:257
     80msgid "Custom description for payment type"
     81msgstr "Свое описание для типа платежа"
     82
     83#: paygine-payment_method.php:263
     84msgid "Logo"
     85msgstr "Логотип"
     86
     87#: paygine-payment_method.php:265
     88msgid "Custom logo for payment type"
     89msgstr "Свой логотип для типа платежа"
     90
     91#: paygine-payment_method.php:270
    6892msgid "Sector ID"
    6993msgstr "Sector ID"
    7094
    71 #: paygine-payment_method.php:186
     95#: paygine-payment_method.php:272
    7296msgid "Your shop identifier at Paygine"
    7397msgstr "Идентификатор вашего магазина в системе Paygine"
    7498
    75 #: paygine-payment_method.php:192
     99#: paygine-payment_method.php:277
    76100msgid "Password"
    77101msgstr "Пароль"
    78102
    79 #: paygine-payment_method.php:194
     103#: paygine-payment_method.php:279
    80104msgid "Password to use for digital signature"
    81105msgstr "Пароль для цифровой подписи"
    82106
    83 #: paygine-payment_method.php:200
     107#: paygine-payment_method.php:284
    84108msgid "Test Mode"
    85109msgstr "Тестовый режим"
    86110
    87 #: paygine-payment_method.php:203
     111#: paygine-payment_method.php:287
    88112msgid "Test mode - real payments will not be processed"
    89113msgstr "Тестовый режим - средства с карты не списываются"
    90114
    91 #: paygine-payment_method.php:204
     115#: paygine-payment_method.php:288
    92116msgid "Production mode - payments will be processed"
    93117msgstr "Рабочий режим - средства списываются с карты"
    94118
    95 #: paygine-payment_method.php:206
     119#: paygine-payment_method.php:290
    96120msgid "Select test or live mode"
    97121msgstr "Выберите тестовый или рабочий режим"
    98122
    99 #: paygine-payment_method.php:211
     123#: paygine-payment_method.php:294
    100124msgid "Payment method"
    101125msgstr "Способ оплаты"
    102126
    103 #: paygine-payment_method.php:214
     127#: paygine-payment_method.php:297
    104128msgid "Standard acquiring (one-stage payment)"
    105129msgstr "Стандартный эквайринг (одностадийная оплата)"
    106130
    107 #: paygine-payment_method.php:215
     131#: paygine-payment_method.php:298
    108132msgid "Standard acquiring (two-stage payment)"
    109133msgstr "Стандартный эквайринг (двухстадийная оплата)"
    110134
    111 #: paygine-payment_method.php:216
    112 msgid "Halva Chastyami (one-stage payment)"
     135#: paygine-payment_method.php:299
     136msgid "Plait (one-stage payment)"
    113137msgstr "Только Халва Частями (одностадийная оплата)"
    114138
    115 #: paygine-payment_method.php:217
    116 msgid "Halva Chastyami (two-stage payment)"
     139#: paygine-payment_method.php:300
     140msgid "Plait (two-stage payment)"
    117141msgstr "Только Халва Частями (двухстадийная оплата)"
    118142
    119 #: paygine-payment_method.php:218
     143#: paygine-payment_method.php:301
    120144msgid "Fast Payment System"
    121145msgstr "Система Быстрых Платежей (СБП)"
    122146
    123 #: paygine-payment_method.php:219
     147#: paygine-payment_method.php:302
    124148msgid "Loan"
    125149msgstr "Кредитование"
    126150
    127 #: paygine-payment_method.php:221
     151#: paygine-payment_method.php:304
    128152msgid "Payment occurs after confirmation by the manager in the personal account"
    129153msgstr "Оплата происходит после подтверждения менеджером в ЛК"
    130154
    131 #: paygine-payment_method.php:226
     155#: paygine-payment_method.php:308
    132156msgid "TAX"
    133157msgstr "Налог"
    134158
    135 #: paygine-payment_method.php:229
     159#: paygine-payment_method.php:311
    136160msgid "VAT rate 20%"
    137161msgstr "ставка НДС 20%"
    138162
    139 #: paygine-payment_method.php:230
     163#: paygine-payment_method.php:312
    140164msgid "VAT rate 10%"
    141165msgstr "ставка НДС 10%"
    142166
    143 #: paygine-payment_method.php:231
     167#: paygine-payment_method.php:313
    144168msgid "VAT rate calc. 20/120"
    145169msgstr "ставка НДС расч. 20/120"
    146170
    147 #: paygine-payment_method.php:232
     171#: paygine-payment_method.php:314
    148172msgid "VAT rate calc. 10/110"
    149173msgstr "ставка НДС расч. 10/110"
    150174
    151 #: paygine-payment_method.php:233
     175#: paygine-payment_method.php:315
    152176msgid "VAT rate 0%"
    153177msgstr "ставка НДС 0%"
    154178
    155 #: paygine-payment_method.php:234
     179#: paygine-payment_method.php:316
    156180msgid "Not subject to VAT"
    157181msgstr "НДС не облагается"
    158182
    159 #: paygine-payment_method.php:240
     183#: paygine-payment_method.php:321
    160184msgid "Notify URL"
    161185msgstr "URL для уведомлений"
    162186
    163 #: paygine-payment_method.php:242
     187#: paygine-payment_method.php:323
    164188msgid "Report this URL to Paygine technical support to receive payment notifications"
    165189msgstr "Сообщите в службу технической поддержки Paygine этот URL для получения уведомлений о платеже"
    166190
    167 #: paygine-payment_method.php:251
     191#: paygine-payment_method.php:331
    168192msgid "Data encryption algorithm"
    169193msgstr "Алгоритм шифрования данных"
    170194
    171 #: paygine-payment_method.php:257
     195#: paygine-payment_method.php:337
    172196msgid "Must match your sector encryption settings in your personal account"
    173197msgstr "Должен соответствовать настройкам шифрования вашего сектора в личном кабинете"
    174198
    175 #: paygine-payment_method.php:263
     199#: paygine-payment_method.php:342
    176200msgid "Custom statuses for orders"
    177201msgstr "Настраиваемые статусы для заказов"
    178202
    179 #: paygine-payment_method.php:269
     203#: paygine-payment_method.php:346
    180204msgid "Order registered"
    181205msgstr "Заказ зарегистрирован"
    182206
    183 #: paygine-payment_method.php:274
     207#: paygine-payment_method.php:351
    184208msgid "Order authorized"
    185209msgstr "Средства захолдированы"
    186210
    187 #: paygine-payment_method.php:279
     211#: paygine-payment_method.php:356
    188212msgid "Loan agreement approved but not signed"
    189213msgstr "Кредитный договор одобрен, но не подписан"
    190214
    191 #: paygine-payment_method.php:284
     215#: paygine-payment_method.php:361
    192216msgid "Order successfully paid"
    193217msgstr "Заказ успешно оплачен"
    194218
    195 #: paygine-payment_method.php:289
     219#: paygine-payment_method.php:366
    196220msgid "Order canceled"
    197221msgstr "Платеж отменен"
    198222
    199 #: paygine-payment_method.php:317
     223#: paygine-payment_method.php:371
     224msgid "Issuing an invoice for payment"
     225msgstr "Выставление счёта на оплату"
     226
     227#: paygine-payment_method.php:373
     228msgid "Enable issuing an invoice for payment by email of the payer"
     229msgstr "Включить выставление счёта на оплату на email плательщика"
     230
     231#: paygine-payment_method.php:377
     232msgid "Order agreement"
     233msgstr "Заказ на согласовании"
     234
     235#: paygine-payment_method.php:383
     236msgid "Payment expected"
     237msgstr "Ожидается оплата"
     238
     239#: paygine-payment_method.php:409
    200240msgid "Order #%s"
    201241msgstr "Заказ №%s"
    202242
    203 #: paygine-payment_method.php:333
     243#: paygine-payment_method.php:431
    204244msgid "Failed to register order"
    205245msgstr "Не удалось зарегистрировать заказ"
    206246
    207 #: paygine-payment_method.php:345
     247#: paygine-payment_method.php:444
    208248msgid "Order registered successfully"
    209249msgstr "Заказ успешно зарегистрирован"
    210250
    211 #: paygine-payment_method.php:378
    212 #: paygine-payment_method.php:545
    213 msgid "Failed to get Best2pay order ID"
    214 msgstr "Не удалось получить ID заказа Best2pay"
    215 
    216 #: paygine-payment_method.php:381
    217 msgid "Failed to get Best2pay operation ID"
    218 msgstr "Не удалось получить ID операции Best2pay"
    219 
    220 #: paygine-payment_method.php:384
    221 #: paygine-payment_method.php:452
    222 #: paygine-payment_method.php:539
     251#: paygine-payment_method.php:520
     252msgid "Order successfully create"
     253msgstr "Заказ успешно создан"
     254
     255#: paygine-payment_method.php:559
     256#: paygine-payment_method.php:741
     257msgid "Failed to get Paygine order ID"
     258msgstr "Не удалось получить ID заказа Paygine"
     259
     260#: paygine-payment_method.php:563
     261msgid "Failed to get Paygine operation ID"
     262msgstr "Не удалось получить ID операции Paygine"
     263
     264#: paygine-payment_method.php:567
     265#: paygine-payment_method.php:647
     266#: paygine-payment_method.php:733
    223267msgid "Undefined order ID"
    224268msgstr "Неопределенный ID заказа"
    225269
    226 #: paygine-payment_method.php:387
    227 #: paygine-payment_method.php:455
    228 #: paygine-payment_method.php:542
     270#: paygine-payment_method.php:571
     271#: paygine-payment_method.php:651
     272#: paygine-payment_method.php:737
    229273msgid "Failed to get order information"
    230274msgstr "Не удалось получить информацию о заказе"
    231275
    232 #: paygine-payment_method.php:400
     276#: paygine-payment_method.php:575
     277msgid "Request data is not valid"
     278msgstr "Данные запроса не валидны"
     279
     280#: paygine-payment_method.php:588
    233281msgid "Could not find operation"
    234282msgstr "Не удалось найти операцию"
    235283
    236 #: paygine-payment_method.php:409
     284#: paygine-payment_method.php:599
    237285msgid "Failed to pay for the order"
    238286msgstr "Не удалось оплатить заказ"
    239287
    240 #: paygine-payment_method.php:431
     288#: paygine-payment_method.php:623
    241289msgid "Payment completed successfully"
    242290msgstr "Платеж успешно завершен"
    243291
    244 #: paygine-payment_method.php:461
     292#: paygine-payment_method.php:655
    245293msgid "The order has already been %s"
    246294msgstr "Заказ уже %s"
    247295
    248 #: paygine-payment_method.php:474
     296#: paygine-payment_method.php:667
    249297msgid "Failed to complete request for operation %s from the processing center"
    250298msgstr "Не удалось выполнить запрос операции %s от процессингового центра"
    251299
    252 #: paygine-payment_method.php:493
     300#: paygine-payment_method.php:687
    253301msgid "Request for operation %s from the processing center was completed successfully"
    254302msgstr "Запрос операции %s от процессингового центра выполнен успешно"
    255303
    256 #: paygine-payment_method.php:535
     304#: paygine-payment_method.php:729
    257305msgid "Operation failed. Please refresh the page"
    258306msgstr "Не удалось выполнить операцию. Обновите страницу"
    259307
    260 #: paygine-payment_method.php:552
     308#: paygine-payment_method.php:747
    261309msgid "Failed to get operation request path"
    262310msgstr "Не удалось получить путь запроса операции"
    263311
    264 #: paygine-payment_method.php:556
     312#: paygine-payment_method.php:751
    265313msgid "For orders with AUTHORIZED status, only full refunds are available"
    266314msgstr "Для заказов со статусом AUTHORIZED возможен только полный возврат средств"
    267315
    268 #: paygine-payment_method.php:577
     316#: paygine-payment_method.php:775
    269317msgid "Operation type and action type are not equal"
    270318msgstr "Тип операции и тип действия не совпадают"
    271319
    272 #: paygine-payment_method.php:616
     320#: paygine-payment_method.php:817
    273321msgid "Complete payment"
    274322msgstr "Списать средства"
    275323
    276 #: paygine-payment_method.php:674
     324#: paygine-payment_method.php:873
    277325msgid "Missing PC order ID"
    278326msgstr "Отсутствует ID заказа Пц"
    279327
    280 #: paygine-payment_method.php:687
     328#: paygine-payment_method.php:888
    281329msgid "There are no operations in the order"
    282330msgstr "Операции заказа не найдены"
    283331
    284 #: paygine-payment_method.php:719
    285 #: paygine-payment_method.php:735
     332#: paygine-payment_method.php:923
     333#: paygine-payment_method.php:942
    286334msgid "Signature is missing"
    287335msgstr "Отсутствует подпись"
    288336
    289 #: paygine-payment_method.php:723
    290 #: paygine-payment_method.php:739
     337#: paygine-payment_method.php:928
     338#: paygine-payment_method.php:947
    291339msgid "Invalid signature"
    292340msgstr "Неверная подпись"
    293341
    294 #: paygine-payment_method.php:725
    295 #: paygine-payment_method.php:746
     342#: paygine-payment_method.php:931
     343#: paygine-payment_method.php:955
    296344msgid "Unknown operation type"
    297345msgstr "Неизвестный тип операции"
    298346
    299 #: paygine-payment_method.php:727
    300 #: paygine-payment_method.php:748
     347#: paygine-payment_method.php:934
     348#: paygine-payment_method.php:958
    301349msgid "Operation not approved"
    302350msgstr "Операция не одобрена"
    303351
    304 #: paygine-payment_method.php:744
     352#: paygine-payment_method.php:952
    305353msgid "An error occurred during the operation"
    306354msgstr "Во время операции произошла ошибка"
    307355
    308 #: paygine-payment_method.php:750
     356#: paygine-payment_method.php:961
    309357msgid "Unknown payment operation type"
    310358msgstr "Неизвестный тип платежной операции"
    311359
    312 #: paygine-payment_method.php:774
     360#: paygine-payment_method.php:985
    313361msgid "Invalid operation amount"
    314362msgstr "Неверная сумма операции"
    315363
    316 #: paygine-payment_method.php:806
     364#: paygine-payment_method.php:1017
    317365msgid "Funds for the order have been successfully debited"
    318366msgstr "Средства за заказ успешно списаны"
    319367
    320 #: paygine-payment_method.php:807
     368#: paygine-payment_method.php:1018
    321369msgid "Failed to complete payment"
    322370msgstr "Не удалось завершить платеж"
    323371
    324 #: paygine-payment_method.php:810
     372#: paygine-payment_method.php:1021
    325373msgid "Payment refunded successfully"
    326374msgstr "Платеж успешно возвращен"
    327375
    328 #: paygine-payment_method.php:811
     376#: paygine-payment_method.php:1022
    329377msgid "Failed to refund payment"
    330378msgstr "Не удалось вернуть платеж"
    331379
    332 #: paygine-payment_method.php:935
     380#: paygine-payment_method.php:1138
    333381msgid "Server response is empty"
    334382msgstr "Ответ сервера пуст"
    335383
    336 #: paygine-payment_method.php:938
     384#: paygine-payment_method.php:1142
    337385msgid "Invalid XML from response"
    338386msgstr "Неверный XML в ответе"
    339387
    340 #: paygine-payment_method.php:941
     388#: paygine-payment_method.php:1146
    341389msgid "Unable to decode xml"
    342390msgstr "Невозможно декодировать XML"
    343391
    344 #: paygine-payment_method.php:991
     392#: paygine-payment_method.php:1197
    345393msgid "Settings"
    346394msgstr "Настройки"
  • paygine/trunk/languages/paygine-payment_method.pot

    r3011342 r3036869  
    1 # Copyright (C) 2023 Paygine
     1# Copyright (C) 2024 Paygine
    22# This file is distributed under the GPL3.
    33msgid ""
    44msgstr ""
    5 "Project-Id-Version: Paygine payment method (Visa/MasterCard/MIR) 2.1.5\n"
    6 "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/paygine\n"
     5"Project-Id-Version: Paygine payment module 2.2\n"
     6"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/trunk\n"
    77"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
    88"Language-Team: LANGUAGE <[email protected]>\n"
     
    1010"Content-Type: text/plain; charset=UTF-8\n"
    1111"Content-Transfer-Encoding: 8bit\n"
    12 "POT-Creation-Date: 2023-11-20T20:39:42+03:00\n"
     12"POT-Creation-Date: 2024-02-07T15:58:00+03:00\n"
    1313"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
    14 "X-Generator: WP-CLI 2.8.1\n"
     14"X-Generator: WP-CLI 2.9.0\n"
    1515"X-Domain: paygine-payment_method\n"
    1616
    1717#. Plugin Name of the plugin
    18 msgid "Paygine payment method (Visa/MasterCard/MIR)"
     18msgid "Paygine payment module"
    1919msgstr ""
    2020
    2121#. Plugin URI of the plugin
    22 msgid "http://paygine.ru/"
     22msgid "https://paygine.ru/"
    2323msgstr ""
    2424
     
    2828
    2929#. Author of the plugin
    30 #: paygine-payment_method.php:110
    31 #: paygine-payment_method.php:111
    32 #: paygine-payment_method.php:855
     30#: paygine-payment_method.php:117
     31#: paygine-payment_method.php:1063
    3332msgid "Paygine"
    3433msgstr ""
    3534
    36 #: paygine-payment_method.php:112
    37 #: paygine-payment_method.php:856
     35#: paygine-payment_method.php:119
     36msgid "To accept payments through the plugin, you need to apply to connect to Paygine on the website <a href=\"%1$s\" target=\"_blank\">%1$s</a> and enter into an agreement with the company.<br/>Support email: <a href=\"mailto:%2$s\">%2$s</a>"
     37msgstr ""
     38
     39#: paygine-payment_method.php:137
     40#: paygine-payment_method.php:1064
    3841msgid "Payments with bank cards via the <a href=\"%s\" target=\"_blank\">Paygine</a> payment system."
    3942msgstr ""
    4043
    41 #: paygine-payment_method.php:145
     44#: paygine-payment_method.php:166
    4245msgid "Pay for your order in installments"
    4346msgstr ""
    4447
    45 #: paygine-payment_method.php:152
    46 msgid "Pay by QR"
    47 msgstr ""
    48 
    49 #: paygine-payment_method.php:177
     48#: paygine-payment_method.php:221
     49msgid "Remove logo"
     50msgstr ""
     51
     52#: paygine-payment_method.php:241
    5053msgid "Enable/Disable"
    5154msgstr ""
    5255
    53 #: paygine-payment_method.php:179
     56#: paygine-payment_method.php:243
    5457msgid "Enable Paygine checkout method"
    5558msgstr ""
    5659
    57 #: paygine-payment_method.php:184
     60#: paygine-payment_method.php:247
     61msgid "Title"
     62msgstr ""
     63
     64#: paygine-payment_method.php:249
     65msgid "Custom title for payment type"
     66msgstr ""
     67
     68#: paygine-payment_method.php:255
     69msgid "Description"
     70msgstr ""
     71
     72#: paygine-payment_method.php:257
     73msgid "Custom description for payment type"
     74msgstr ""
     75
     76#: paygine-payment_method.php:263
     77msgid "Logo"
     78msgstr ""
     79
     80#: paygine-payment_method.php:265
     81msgid "Custom logo for payment type"
     82msgstr ""
     83
     84#: paygine-payment_method.php:270
    5885msgid "Sector ID"
    5986msgstr ""
    6087
    61 #: paygine-payment_method.php:186
     88#: paygine-payment_method.php:272
    6289msgid "Your shop identifier at Paygine"
    6390msgstr ""
    6491
    65 #: paygine-payment_method.php:192
     92#: paygine-payment_method.php:277
    6693msgid "Password"
    6794msgstr ""
    6895
    69 #: paygine-payment_method.php:194
     96#: paygine-payment_method.php:279
    7097msgid "Password to use for digital signature"
    7198msgstr ""
    7299
    73 #: paygine-payment_method.php:200
     100#: paygine-payment_method.php:284
    74101msgid "Test Mode"
    75102msgstr ""
    76103
    77 #: paygine-payment_method.php:203
     104#: paygine-payment_method.php:287
    78105msgid "Test mode - real payments will not be processed"
    79106msgstr ""
    80107
    81 #: paygine-payment_method.php:204
     108#: paygine-payment_method.php:288
    82109msgid "Production mode - payments will be processed"
    83110msgstr ""
    84111
    85 #: paygine-payment_method.php:206
     112#: paygine-payment_method.php:290
    86113msgid "Select test or live mode"
    87114msgstr ""
    88115
    89 #: paygine-payment_method.php:211
     116#: paygine-payment_method.php:294
    90117msgid "Payment method"
    91118msgstr ""
    92119
    93 #: paygine-payment_method.php:214
     120#: paygine-payment_method.php:297
    94121msgid "Standard acquiring (one-stage payment)"
    95122msgstr ""
    96123
    97 #: paygine-payment_method.php:215
     124#: paygine-payment_method.php:298
    98125msgid "Standard acquiring (two-stage payment)"
    99126msgstr ""
    100127
    101 #: paygine-payment_method.php:216
    102 msgid "Halva Chastyami (one-stage payment)"
    103 msgstr ""
    104 
    105 #: paygine-payment_method.php:217
    106 msgid "Halva Chastyami (two-stage payment)"
    107 msgstr ""
    108 
    109 #: paygine-payment_method.php:218
     128#: paygine-payment_method.php:299
     129msgid "Plait (one-stage payment)"
     130msgstr ""
     131
     132#: paygine-payment_method.php:300
     133msgid "Plait (two-stage payment)"
     134msgstr ""
     135
     136#: paygine-payment_method.php:301
    110137msgid "Fast Payment System"
    111138msgstr ""
    112139
    113 #: paygine-payment_method.php:219
     140#: paygine-payment_method.php:302
    114141msgid "Loan"
    115142msgstr ""
    116143
    117 #: paygine-payment_method.php:221
     144#: paygine-payment_method.php:304
    118145msgid "Payment occurs after confirmation by the manager in the personal account"
    119146msgstr ""
    120147
    121 #: paygine-payment_method.php:226
     148#: paygine-payment_method.php:308
    122149msgid "TAX"
    123150msgstr ""
    124151
    125 #: paygine-payment_method.php:229
     152#: paygine-payment_method.php:311
    126153msgid "VAT rate 20%"
    127154msgstr ""
    128155
    129 #: paygine-payment_method.php:230
     156#: paygine-payment_method.php:312
    130157msgid "VAT rate 10%"
    131158msgstr ""
    132159
    133 #: paygine-payment_method.php:231
     160#: paygine-payment_method.php:313
    134161msgid "VAT rate calc. 20/120"
    135162msgstr ""
    136163
    137 #: paygine-payment_method.php:232
     164#: paygine-payment_method.php:314
    138165msgid "VAT rate calc. 10/110"
    139166msgstr ""
    140167
    141 #: paygine-payment_method.php:233
     168#: paygine-payment_method.php:315
    142169msgid "VAT rate 0%"
    143170msgstr ""
    144171
    145 #: paygine-payment_method.php:234
     172#: paygine-payment_method.php:316
    146173msgid "Not subject to VAT"
    147174msgstr ""
    148175
    149 #: paygine-payment_method.php:240
     176#: paygine-payment_method.php:321
    150177msgid "Notify URL"
    151178msgstr ""
    152179
    153 #: paygine-payment_method.php:242
     180#: paygine-payment_method.php:323
    154181msgid "Report this URL to Paygine technical support to receive payment notifications"
    155182msgstr ""
    156183
    157 #: paygine-payment_method.php:251
     184#: paygine-payment_method.php:331
    158185msgid "Data encryption algorithm"
    159186msgstr ""
    160187
    161 #: paygine-payment_method.php:257
     188#: paygine-payment_method.php:337
    162189msgid "Must match your sector encryption settings in your personal account"
    163190msgstr ""
    164191
    165 #: paygine-payment_method.php:263
     192#: paygine-payment_method.php:342
    166193msgid "Custom statuses for orders"
    167194msgstr ""
    168195
    169 #: paygine-payment_method.php:269
     196#: paygine-payment_method.php:346
    170197msgid "Order registered"
    171198msgstr ""
    172199
    173 #: paygine-payment_method.php:274
     200#: paygine-payment_method.php:351
    174201msgid "Order authorized"
    175202msgstr ""
    176203
    177 #: paygine-payment_method.php:279
     204#: paygine-payment_method.php:356
    178205msgid "Loan agreement approved but not signed"
    179206msgstr ""
    180207
    181 #: paygine-payment_method.php:284
     208#: paygine-payment_method.php:361
    182209msgid "Order successfully paid"
    183210msgstr ""
    184211
    185 #: paygine-payment_method.php:289
     212#: paygine-payment_method.php:366
    186213msgid "Order canceled"
    187214msgstr ""
    188215
    189 #: paygine-payment_method.php:317
     216#: paygine-payment_method.php:371
     217msgid "Issuing an invoice for payment"
     218msgstr ""
     219
     220#: paygine-payment_method.php:373
     221msgid "Enable issuing an invoice for payment by email of the payer"
     222msgstr ""
     223
     224#: paygine-payment_method.php:377
     225msgid "Order agreement"
     226msgstr ""
     227
     228#: paygine-payment_method.php:383
     229msgid "Payment expected"
     230msgstr ""
     231
     232#: paygine-payment_method.php:409
    190233msgid "Order #%s"
    191234msgstr ""
    192235
    193 #: paygine-payment_method.php:333
     236#: paygine-payment_method.php:431
    194237msgid "Failed to register order"
    195238msgstr ""
    196239
    197 #: paygine-payment_method.php:345
     240#: paygine-payment_method.php:444
    198241msgid "Order registered successfully"
    199242msgstr ""
    200243
    201 #: paygine-payment_method.php:378
    202 #: paygine-payment_method.php:545
    203 msgid "Failed to get Best2pay order ID"
    204 msgstr ""
    205 
    206 #: paygine-payment_method.php:381
    207 msgid "Failed to get Best2pay operation ID"
    208 msgstr ""
    209 
    210 #: paygine-payment_method.php:384
    211 #: paygine-payment_method.php:452
    212 #: paygine-payment_method.php:539
     244#: paygine-payment_method.php:520
     245msgid "Order successfully create"
     246msgstr ""
     247
     248#: paygine-payment_method.php:559
     249#: paygine-payment_method.php:741
     250msgid "Failed to get Paygine order ID"
     251msgstr ""
     252
     253#: paygine-payment_method.php:563
     254msgid "Failed to get Paygine operation ID"
     255msgstr ""
     256
     257#: paygine-payment_method.php:567
     258#: paygine-payment_method.php:647
     259#: paygine-payment_method.php:733
    213260msgid "Undefined order ID"
    214261msgstr ""
    215262
    216 #: paygine-payment_method.php:387
    217 #: paygine-payment_method.php:455
    218 #: paygine-payment_method.php:542
     263#: paygine-payment_method.php:571
     264#: paygine-payment_method.php:651
     265#: paygine-payment_method.php:737
    219266msgid "Failed to get order information"
    220267msgstr ""
    221268
    222 #: paygine-payment_method.php:400
     269#: paygine-payment_method.php:575
     270msgid "Request data is not valid"
     271msgstr ""
     272
     273#: paygine-payment_method.php:588
    223274msgid "Could not find operation"
    224275msgstr ""
    225276
    226 #: paygine-payment_method.php:409
     277#: paygine-payment_method.php:599
    227278msgid "Failed to pay for the order"
    228279msgstr ""
    229280
    230 #: paygine-payment_method.php:431
     281#: paygine-payment_method.php:623
    231282msgid "Payment completed successfully"
    232283msgstr ""
    233284
    234 #: paygine-payment_method.php:461
     285#: paygine-payment_method.php:655
    235286msgid "The order has already been %s"
    236287msgstr ""
    237288
    238 #: paygine-payment_method.php:474
     289#: paygine-payment_method.php:667
    239290msgid "Failed to complete request for operation %s from the processing center"
    240291msgstr ""
    241292
    242 #: paygine-payment_method.php:493
     293#: paygine-payment_method.php:687
    243294msgid "Request for operation %s from the processing center was completed successfully"
    244295msgstr ""
    245296
    246 #: paygine-payment_method.php:535
     297#: paygine-payment_method.php:729
    247298msgid "Operation failed. Please refresh the page"
    248299msgstr ""
    249300
    250 #: paygine-payment_method.php:552
     301#: paygine-payment_method.php:747
    251302msgid "Failed to get operation request path"
    252303msgstr ""
    253304
    254 #: paygine-payment_method.php:556
     305#: paygine-payment_method.php:751
    255306msgid "For orders with AUTHORIZED status, only full refunds are available"
    256307msgstr ""
    257308
    258 #: paygine-payment_method.php:577
     309#: paygine-payment_method.php:775
    259310msgid "Operation type and action type are not equal"
    260311msgstr ""
    261312
    262 #: paygine-payment_method.php:616
     313#: paygine-payment_method.php:817
    263314msgid "Complete payment"
    264315msgstr ""
    265316
    266 #: paygine-payment_method.php:674
     317#: paygine-payment_method.php:873
    267318msgid "Missing PC order ID"
    268319msgstr ""
    269320
    270 #: paygine-payment_method.php:687
     321#: paygine-payment_method.php:888
    271322msgid "There are no operations in the order"
    272323msgstr ""
    273324
    274 #: paygine-payment_method.php:719
    275 #: paygine-payment_method.php:735
     325#: paygine-payment_method.php:923
     326#: paygine-payment_method.php:942
    276327msgid "Signature is missing"
    277328msgstr ""
    278329
    279 #: paygine-payment_method.php:723
    280 #: paygine-payment_method.php:739
     330#: paygine-payment_method.php:928
     331#: paygine-payment_method.php:947
    281332msgid "Invalid signature"
    282333msgstr ""
    283334
    284 #: paygine-payment_method.php:725
    285 #: paygine-payment_method.php:746
     335#: paygine-payment_method.php:931
     336#: paygine-payment_method.php:955
    286337msgid "Unknown operation type"
    287338msgstr ""
    288339
    289 #: paygine-payment_method.php:727
    290 #: paygine-payment_method.php:748
     340#: paygine-payment_method.php:934
     341#: paygine-payment_method.php:958
    291342msgid "Operation not approved"
    292343msgstr ""
    293344
    294 #: paygine-payment_method.php:744
     345#: paygine-payment_method.php:952
    295346msgid "An error occurred during the operation"
    296347msgstr ""
    297348
    298 #: paygine-payment_method.php:750
     349#: paygine-payment_method.php:961
    299350msgid "Unknown payment operation type"
    300351msgstr ""
    301352
    302 #: paygine-payment_method.php:774
     353#: paygine-payment_method.php:985
    303354msgid "Invalid operation amount"
    304355msgstr ""
    305356
    306 #: paygine-payment_method.php:806
     357#: paygine-payment_method.php:1017
    307358msgid "Funds for the order have been successfully debited"
    308359msgstr ""
    309360
    310 #: paygine-payment_method.php:807
     361#: paygine-payment_method.php:1018
    311362msgid "Failed to complete payment"
    312363msgstr ""
    313364
    314 #: paygine-payment_method.php:810
     365#: paygine-payment_method.php:1021
    315366msgid "Payment refunded successfully"
    316367msgstr ""
    317368
    318 #: paygine-payment_method.php:811
     369#: paygine-payment_method.php:1022
    319370msgid "Failed to refund payment"
    320371msgstr ""
    321372
    322 #: paygine-payment_method.php:935
     373#: paygine-payment_method.php:1138
    323374msgid "Server response is empty"
    324375msgstr ""
    325376
    326 #: paygine-payment_method.php:938
     377#: paygine-payment_method.php:1142
    327378msgid "Invalid XML from response"
    328379msgstr ""
    329380
    330 #: paygine-payment_method.php:941
     381#: paygine-payment_method.php:1146
    331382msgid "Unable to decode xml"
    332383msgstr ""
    333384
    334 #: paygine-payment_method.php:991
     385#: paygine-payment_method.php:1197
    335386msgid "Settings"
    336387msgstr ""
  • paygine/trunk/paygine-payment_method.php

    r3011342 r3036869  
    11<?php
    22declare(strict_types=1);
    3 
    43
    54/*
     
    1716    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    1817*/
     18
    1919/**
    20  * Plugin Name: Paygine payment method (Visa/MasterCard/MIR)
     20 * Plugin Name: Paygine payment module
    2121 * Plugin URI: https://paygine.ru/
    2222 * Description: Receive payments via Visa/Mastercard/MIR easily with Paygine bank cards processing
    23  * Version: 2.1.5
     23 * Version: 2.2.0
    2424 * Author: Paygine
    25  * Tested up to: 6.3.2
     25 * Tested up to: 6.4.3
    2626 * License: GPL3
    2727 *
     
    3535add_action('plugins_loaded', 'init_woocommerce_paygine', 0);
    3636
    37 function init_woocommerce_paygine()
    38 {
    39     if(!class_exists('WC_Payment_Gateway')){
     37function init_woocommerce_paygine() {
     38    if(!class_exists('WC_Payment_Gateway')) {
    4039        return;
    4140    }
    42    
     41
    4342    load_plugin_textdomain('paygine-payment_method', false, dirname(plugin_basename(__FILE__)) . '/languages');
    44    
    45     class woocommerce_paygine extends WC_Payment_Gateway
    46     {
     43
     44    class woocommerce_paygine extends WC_Payment_Gateway {
    4745        const PLUGIN_SITE = 'https://paygine.ru';
    4846        const SHOP_CART_MAX_LENGTH = 1000;
     
    5553            'loan' => '/webapi/custom/unicheckout/PurchaseWithLoanManager'
    5654        ];
    57        
     55
    5856        const OLD_TO_NEW_PAYMENT_METHODS = [
    5957            'Purchase' => 'acquiring',
     
    6361            'PurchaseSBP' => 'sbp'
    6462        ];
     63
    6564        private const OPERATION_TYPES = [
    6665            'PURCHASE',
     
    7069            'COMPLETE'
    7170        ];
     71
    7272        private const PAID_OPERATION_TYPES = [
    7373            'PURCHASE',
    7474            'PURCHASE_BY_QR',
    75             'AUTHORIZE',
     75            'AUTHORIZE'
    7676        ];
     77
    7778        private const OPERATION_APPROVED = 'APPROVED';
    7879        private const OPERATION_COMPLETE = 'COMPLETE';
     
    9091        protected string $testmode;
    9192        protected string $hash_algo;
     93        protected string $notify_customer_enabled;
    9294        protected string $registered_status;
    9395        protected string $authorized_status;
    9496        protected string $loan_status;
    9597        protected string $completed_status;
     98        protected string $agreement_status;
     99        protected string $payment_expected_status;
    96100        protected string $canceled_status;
    97101        protected string $payment_method;
     
    101105        protected string $fiscal_positions;
    102106        protected array $shop_cart;
     107        protected string $logo_field;
     108        protected string $remove_logo_field;
    103109        /**
    104110         * Init fields, set settings, register hooks
    105111         */
    106         public function __construct()
    107         {
     112        public function __construct() {
    108113            require_once ABSPATH . 'wp-admin/includes/file.php';
     114
    109115            // plugin settings
    110116            $this->id = 'paygine';
     
    115121                '[email protected]'
    116122            );
    117             $this->title = __('Paygine', 'paygine-payment_method');
    118             $this->description = sprintf(
    119                 __('Payments with bank cards via the <a href="%s" target="_blank">Paygine</a> payment system.', 'paygine-payment_method'),
    120                 self::PLUGIN_SITE
    121             );
    122123            $this->icon = plugins_url('assets/img/paygine.png', __FILE__);
    123124            $this->has_fields = true;
    124125            $this->notify_url = add_query_arg('wc-api', 'paygine_notify', home_url('/'));
    125126            $this->callback_url = add_query_arg('wc-api', 'paygine', home_url('/'));
    126            
     127
    127128            // means that the gateway accept refunds
    128129            $this->supports = array('refunds', 'products');
    129            
     130
    130131            $this->init_form_fields();
    131132            $this->init_settings();
    132            
     133
    133134            // variables
     135            $this->title = !empty($this->settings['title']) ? $this->settings['title'] : $this->method_title;
     136            $this->description = !empty($this->settings['description']) ? $this->settings['description'] : sprintf(
     137                __('Payments with bank cards via the <a href="%s" target="_blank">Paygine</a> payment system.', 'paygine-payment_method'),
     138                self::PLUGIN_SITE
     139            );
     140            $this->logo = $this->settings['logo'] ?? '';
    134141            $this->sector = $this->settings['sector'];
    135142            $this->password = $this->settings['password'];
     
    137144            $this->payment_method = $this->settings['payment_method'] ?? '';
    138145            $this->tax = $this->settings['tax'] ?? '6';
    139             $this->hash_algo = $this->settings['hash_algo'] ?? 'md5';
    140            
     146            $this->hash_algo = !empty($this->settings['hash_algo']) ? $this->settings['hash_algo'] : 'md5';
     147            $this->notify_customer_enabled = $this->settings['notify_customer_enabled'] ?? '';
     148
    141149            //statuses
    142150            $this->registered_status = $this->settings['registered_status'] ?? '';
     
    145153            $this->completed_status = $this->settings['completed_status'] ?? '';
    146154            $this->canceled_status = $this->settings['canceled_status'] ?? '';
    147            
     155            $this->agreement_status = $this->settings['agreement_status'] ?? '';
     156            $this->payment_expected_status = $this->settings['payment_expected_status'] ?? '';
     157
    148158            $this->currency = $this->get_currency(get_woocommerce_currency());
    149159            $this->url = $this->paygine_get_url();
    150            
     160            $this->logo_field = $this->plugin_id . $this->id . '_logo';
     161            $this->remove_logo_field = $this->plugin_id . $this->id . '_remove_logo';
     162
    151163            switch($this->payment_method) {
    152164                case 'halva':
    153165                case 'halva_two_steps':
    154                     $this->title = __('Pay for your order in installments', 'paygine-payment_method'); //'Оплатить заказ Частями';
    155                     $this->icon = plugins_url('assets/img/halva.svg', __FILE__);
     166                    $this->title = __('Pay for your order in installments', 'paygine-payment_method');
     167                    $this->icon = plugins_url('assets/img/svkb.svg', __FILE__);
    156168                    $this->description = '<iframe style="width:100%;height:180px;border:none;min-width: 440px;margin-left: -50px;"
    157                         src="' . plugins_url('halva_widget.php', __FILE__) . '?amount='
     169                        src="' . plugins_url('svkb_widget.php', __FILE__) . '?amount='
    158170                        . print_r((isset(WC()->cart->cart_contents_total)) ? WC()->cart->cart_contents_total : '', true) . '"></iframe>';
    159171                    break;
    160                 case 'sbp':
    161                     $this->title = __('Pay by QR', 'paygine-payment_method'); //'Оплатить по QR';
    162                     $this->icon = null;
     172                default:
     173                    if($this->logo)
     174                        $this->icon = wp_get_attachment_url($this->logo);
    163175                    break;
    164176            }
     177
    165178            // actions
    166179            add_action('init', array($this, 'successful_request'));
     
    170183            add_action('woocommerce_update_options_payment_gateways_' . $this->id, array($this, 'process_admin_options'));
    171184            add_action('woocommerce_order_item_add_action_buttons', array($this, 'wc_order_item_add_complete_button'), 10, 1);
    172         }
    173        
     185            add_filter('woocommerce_generate_image_html', 'woocommerce_generate_image_html');
     186            add_action("woocommerce_order_status_changed", array($this, 'wc_paygine_order_payment_change'), 10, 4);
     187        }
     188
     189        public function generate_image_html($key, $data) {
     190            $field_key = $this->get_field_key($key);
     191            $defaults  = array(
     192                'title'             => '',
     193                'disabled'          => false,
     194                'class'             => '',
     195                'css'               => '',
     196                'placeholder'       => '',
     197                'type'              => 'file',
     198                'desc_tip'          => false,
     199                'description'       => '',
     200                'custom_attributes' => array(),
     201            );
     202
     203            $data = wp_parse_args($data, $defaults);
     204
     205            ob_start();?>
     206            <tr valign="top">
     207                <th scope="row" class="titledesc">
     208                    <label for="<?php echo esc_attr($field_key);?>"><?php echo wp_kses_post($data['title']); ?> <?php echo $this->get_tooltip_html($data);?></label>
     209                </th>
     210                <td class="forminp">
     211                    <fieldset>
     212                        <legend class="screen-reader-text"><span><?php echo wp_kses_post($data['title']);?></span></legend>
     213                        <input class="input-text regular-input" type="file" name="<?php echo esc_attr($field_key);?>" id="<?php echo esc_attr($field_key);?>" accept="image/*">
     214                    </fieldset>
     215                    <?php if(!empty($this->logo)) {
     216                        $logo_meta = wp_get_attachment_metadata($this->logo);?>
     217                        <img src="<?php echo wp_get_attachment_url($this->logo) ?>" alt="" width="100" style="margin: 10px">
     218                        <div>(<?php echo $logo_meta['width'] . 'x' . $logo_meta['height'];?>)</div>
     219                        <br>
     220                        <label for="<?php echo esc_attr($this->remove_logo_field);?>">
     221                            <input class="" type="checkbox" name="<?php echo esc_attr($this->remove_logo_field);?>" id="<?php echo esc_attr($this->remove_logo_field);?>" style="" value="1"> <?php echo wp_kses_post(__('Remove logo', 'paygine-payment_method'));?></label>
     222                        <?php
     223                    } else {?>
     224                        <img src="<?php echo plugins_url('assets/img/paygine.png', plugin_basename(__FILE__)); ?>" alt="" width="100" style="margin: 10px">
     225                    <?php } ?>
     226                </td>
     227            </tr>
     228            <?php return ob_get_clean();
     229        }
     230
    174231        /**
    175232         * Initialise Gateway Settings Form Fields
     
    177234         * @return void
    178235         */
    179         public function init_form_fields()
    180         {
     236        public function init_form_fields() {
    181237            $wc_statuses = wc_get_order_statuses();
    182            
    183             //  array to generate admin form
     238
    184239            $this->form_fields = array(
    185240                'enabled' => array(
     
    189244                    'default' => 'yes'
    190245                ),
    191                
     246                'title' => array(
     247                    'title' => __('Title', 'paygine-payment_method'),
     248                    'type' => 'text',
     249                    'description' => __('Custom title for payment type', 'paygine-payment_method'),
     250                    'desc_tip' => true,
     251                    'default' => '',
     252                    'placeholder' => $this->method_title
     253                ),
     254                'description' => array(
     255                    'title' => __('Description', 'paygine-payment_method'),
     256                    'type' => 'textarea',
     257                    'description' => __('Custom description for payment type', 'paygine-payment_method'),
     258                    'desc_tip' => true,
     259                    'default' => '',
     260                    'css' => 'width: 400px;'
     261                ),
     262                'logo' => array(
     263                    'title' => __('Logo', 'paygine-payment_method'),
     264                    'type' => 'image',
     265                    'description' => __('Custom logo for payment type', 'paygine-payment_method'),
     266                    'desc_tip' => true,
     267                    'default' => ''
     268                ),
    192269                'sector' => array(
    193270                    'title' => __('Sector ID', 'paygine-payment_method'),
     
    197274                    'default' => ''
    198275                ),
    199                
    200276                'password' => array(
    201277                    'title' => __('Password', 'paygine-payment_method'),
     
    205281                    'default' => ''
    206282                ),
    207                
    208283                'testmode' => array(
    209284                    'title' => __('Test Mode', 'paygine-payment_method'),
     
    214289                    ),
    215290                    'description' => __('Select test or live mode', 'paygine-payment_method'),
    216                     'desc_tip' => true,
    217                 ),
    218                
     291                    'desc_tip' => true
     292                ),
    219293                'payment_method' => array(
    220294                    'title' => __('Payment method', 'paygine-payment_method'),
     
    223297                        'acquiring' => __('Standard acquiring (one-stage payment)', 'paygine-payment_method'),
    224298                        'acquiring_two_steps' => __('Standard acquiring (two-stage payment)', 'paygine-payment_method') . ' *',
    225                         'halva' => __('Halva Chastyami (one-stage payment)', 'paygine-payment_method'),
    226                         'halva_two_steps' => __('Halva Chastyami (two-stage payment)', 'paygine-payment_method') . ' *',
     299                        'halva' => __('Plait (one-stage payment)', 'paygine-payment_method'),
     300                        'halva_two_steps' => __('Plait (two-stage payment)', 'paygine-payment_method') . ' *',
    227301                        'sbp' => __('Fast Payment System', 'paygine-payment_method'),
    228302                        'loan' => __('Loan', 'paygine-payment_method')
    229303                    ),
    230304                    'description' => '* ' . __('Payment occurs after confirmation by the manager in the personal account', 'paygine-payment_method'),
    231                     'desc_tip' => true,
    232                 ),
    233                
     305                    'desc_tip' => true
     306                ),
    234307                'tax' => array(
    235308                    'title' => __('TAX', 'paygine-payment_method'),
     
    243316                        6 => __('Not subject to VAT', 'paygine-payment_method'),
    244317                    ),
    245                     'default' => '6',
    246                 ),
    247                
     318                    'default' => '6'
     319                ),
    248320                'notify_url' => array(
    249321                    'title' => __('Notify URL', 'paygine-payment_method'),
     
    254326                    'custom_attributes' => array(
    255327                        'readonly' => 'readonly',
    256                     ),
    257                 ),
    258                
     328                    )
     329                ),
    259330                'hash_algo' => array(
    260331                    'title' => __('Data encryption algorithm', 'paygine-payment_method'),
     
    266337                    'description' => __('Must match your sector encryption settings in your personal account', 'paygine-payment_method'),
    267338                    'desc_tip' => true,
    268                     'default' => 'md5',
    269                 ),
    270                
     339                    'default' => 'md5'
     340                ),
    271341                'custom_statuses_header' => array(
    272342                    'title' => __('Custom statuses for orders', 'paygine-payment_method'),
    273                     'type' => 'title',
    274                 ),
    275                
    276                 // custom order statuses
     343                    'type' => 'title'
     344                ),
    277345                'registered_status' => array(
    278346                    'title' => __('Order registered', 'paygine-payment_method'),
    279347                    'type' => 'select',
    280                     'options' => $wc_statuses,
     348                    'options' => $wc_statuses
    281349                ),
    282350                'authorized_status' => array(
    283351                    'title' => __('Order authorized', 'paygine-payment_method'),
    284352                    'type' => 'select',
    285                     'options' => $wc_statuses,
     353                    'options' => $wc_statuses
    286354                ),
    287355                'loan_status' => array(
    288356                    'title' => __('Loan agreement approved but not signed', 'paygine-payment_method'),
    289357                    'type' => 'select',
    290                     'options' => $wc_statuses,
     358                    'options' => $wc_statuses
    291359                ),
    292360                'completed_status' => array(
    293361                    'title' => __('Order successfully paid', 'paygine-payment_method'),
    294362                    'type' => 'select',
    295                     'options' => $wc_statuses,
     363                    'options' => $wc_statuses
    296364                ),
    297365                'canceled_status' => array(
    298366                    'title' => __('Order canceled', 'paygine-payment_method'),
    299367                    'type' => 'select',
     368                    'options' => $wc_statuses
     369                ),
     370                'notify_customer_enabled' => array(
     371                    'title' => __('Issuing an invoice for payment', 'paygine-payment_method'),
     372                    'type' => 'checkbox',
     373                    'label' => __('Enable issuing an invoice for payment by email of the payer', 'paygine-payment_method'),
     374                    'default' => 'no'
     375                ),
     376                'agreement_status' => array(
     377                    'title' => __('Order agreement', 'paygine-payment_method'),
     378                    'type' => 'select',
    300379                    'options' => $wc_statuses,
    301                 ),
    302                
     380                    'default' => 'wc-on-hold'
     381                ),
     382                'payment_expected_status' => array(
     383                    'title' => __('Payment expected', 'paygine-payment_method'),
     384                    'type' => 'select',
     385                    'options' => $wc_statuses,
     386                    'default' => 'wc-pending'
     387                )
    303388            );
    304            
    305         }
    306        
    307         /**
    308          * Overwritten WC function.
    309          * Register order @ Paygine and redirect user to payment form
    310          *
    311          * @param $order_id
    312          * @return string[]
    313          **/
    314         public function process_payment($order_id)
    315         {
    316             $order = wc_get_order($order_id);
     389
     390            wp_enqueue_script('admin-paygine-script', plugins_url('assets/js/admin.js', __FILE__));
     391        }
     392
     393        public function wc_paygine_order_payment_change ($order_id, $status_from, $status_to, $order) {
     394            if($order->payment_method === 'paygine' && ($status_from === 'on-hold' && $status_to === 'pending')) {
     395                $this->process_payment_registration($order);
     396            }
     397        }
     398
     399        public function process_payment_registration($order) {
    317400            $order_amount = $this->centify($order->get_total());
    318            
     401
    319402            $this->calc_fiscal_position_shop_cart($order, $order_amount);
    320            
     403
    321404            $args = array(
    322405                'sector' => $this->sector,
     
    332415                'signature' => $this->generate_sign([$this->sector, $order_amount, $this->currency], true)
    333416            );
    334            
     417
     418            if($this->notify_customer_enabled === 'yes') {
     419                $args = array_merge($args, ['notify_customer' => 1]);
     420            }
     421
    335422            try {
    336423                $response = $this->send_request($this->url . '/webapi/Register', ['body' => $args]);
    337424                if (is_wp_error($response))
    338425                    throw new Exception($response->get_error_message());
     426
    339427                $response = $response['body'] ?? $response;
     428
    340429                $paygine_order_id = (int) $response;
    341430                if ($paygine_order_id == 0)
     
    344433                $this->log($e->getMessage(), ['args' => $args, 'response' => $response]);
    345434                wc_add_notice($e->getMessage(), 'error' );
     435
    346436                return [
    347437                    'result' => 'failure',
     
    349439                ];
    350440            }
    351            
     441
    352442            update_post_meta($order->get_id(), 'paygine_order_id', $paygine_order_id);
    353443            update_post_meta($order->get_id(), 'paygine_order_state', self::ORDER_REGISTERED);
    354444            $order->add_order_note(__('Order registered successfully', 'paygine-payment_method') . " (ID: $paygine_order_id)");
    355            
     445
     446            return $paygine_order_id;
     447        }
     448
     449        public function process_payment_payform($pay_order_id) : string {
    356450            $data = [
    357451                'sector' => $this->sector,
    358                 'id' => $paygine_order_id
     452                'id' => $pay_order_id
    359453            ];
     454
    360455            if(($this->payment_method === 'halva' || $this->payment_method === 'halva_two_steps') && $this->shop_cart) {
    361456                $shop_cart_encoded = base64_encode(json_encode($this->shop_cart, JSON_UNESCAPED_UNICODE));
     457
    362458                if(strlen($shop_cart_encoded) > self::SHOP_CART_MAX_LENGTH)
    363459                    $shop_cart_encoded = '';
     460
    364461                $data['shop_cart'] = $shop_cart_encoded;
    365462            }
     463
    366464            $this->sign_data($data, true);
    367465            $payment_path = self::PAYMENT_PATHS_BY_METHOD[$this->payment_method];
    368             $payment_url = $this->url . $payment_path . '?' . http_build_query($data);
     466
     467            return $this->url . $payment_path . '?' . http_build_query($data);
     468        }
     469
     470        public function process_admin_options() {
     471            if(!empty($_POST[$this->remove_logo_field]) && !empty($this->logo)) {
     472                if(wp_delete_attachment($this->logo))
     473                    $this->update_option('logo');
     474            } else if (!empty($_FILES[$this->logo_field]['name'])) {
     475                require_once( ABSPATH . 'wp-admin/includes/image.php' );
     476                require_once( ABSPATH . 'wp-admin/includes/file.php' );
     477                require_once( ABSPATH . 'wp-admin/includes/media.php' );
     478                if(!file_is_valid_image($_FILES[$this->logo_field]['tmp_name']))
     479                    return false;
     480
     481                $attachment_id = media_handle_upload($this->logo_field, 0 );
     482                if (is_wp_error($attachment_id))
     483                    return $attachment_id->get_error_message();
     484
     485                // remove old attachment
     486                if(!empty($this->logo))
     487                    wp_delete_attachment($this->logo);
     488
     489                $this->update_option('logo', $attachment_id);
     490            }
     491
     492            $this->init_settings();
     493
     494            $post_data = $this->get_post_data();
     495
     496            foreach ( $this->get_form_fields() as $key => $field ) {
     497                if(in_array($this->get_field_type( $field ), ['title', 'image'])) continue;
     498
     499                try {
     500                    $this->settings[ $key ] = $this->get_field_value( $key, $field, $post_data );
     501                } catch ( Exception $e ) {
     502                    $this->add_error( $e->getMessage() );
     503                }
     504            }
     505
     506            return update_option( $this->get_option_key(), apply_filters( 'woocommerce_settings_api_sanitized_fields_' . $this->id, $this->settings ) );
     507        }
     508
     509        /**
     510         * Overwritten WC function.
     511         * Register order @ Paygine and redirect user to payment form
     512         *
     513         * @param $order_id
     514         * @return string[]
     515         **/
     516        public function process_payment($order_id) {
     517            $order = wc_get_order($order_id);
     518
     519            if($this->notify_customer_enabled === 'yes' && $order->get_status() !== $this->agreement_status && !get_post_meta($order_id, 'paygine_order_moderated', true)) {
     520                $order->add_order_note(__('Order successfully create', 'paygine-payment_method'));
     521                $order->update_status($this->agreement_status);
     522
     523                update_post_meta($order->get_id(), 'paygine_order_moderated', 'yes');
     524
     525                WC()->cart->empty_cart();
     526
     527                return array(
     528                    'result'   => 'success',
     529                    'redirect' => $this->get_return_url($order),
     530                );
     531            }
     532
     533            $register_order_id = get_post_meta($order_id, 'paygine_order_id', true);
     534
     535            if($register_order_id) {
     536                $payment_url = $this->process_payment_payform(intval($register_order_id));
     537            } else {
     538                $pay_order_id = intval($this->process_payment_registration($order));
     539                $payment_url = $this->process_payment_payform($pay_order_id);
     540            }
     541
    369542            return array(
    370543                'result' => 'success',
     
    372545            );
    373546        }
    374        
     547
    375548        /**
    376549         * Callback from payment gateway was received
    377550         **/
    378         public function callback_from_gateway()
    379         {
     551        public function callback_from_gateway() {
    380552            $response = '';
    381553            $order = [];
    382554            $checkout_url = apply_filters('woocommerce_get_checkout_url', wc_get_checkout_url());
    383             try{
    384                 // processing center order ID
     555
     556            try {
    385557                $pc_order_id = intval($_REQUEST['id']);
    386558                if(!$pc_order_id)
    387559                    throw new Exception(__('Failed to get Paygine order ID', 'paygine-payment_method'));
     560
    388561                $pc_operation_id = intval($_REQUEST['operation']);
    389562                if(!$pc_operation_id)
    390563                    throw new Exception(__('Failed to get Paygine operation ID', 'paygine-payment_method'));
     564
    391565                $order_id = intval($_REQUEST['reference']);
    392566                if(!$order_id)
    393567                    throw new Exception(__('Undefined order ID', 'paygine-payment_method'));
     568
    394569                $order = wc_get_order($order_id);
    395570                if(!$order)
    396571                    throw new Exception(__('Failed to get order information', 'paygine-payment_method'));
    397572               
    398                 // if order already paid
     573                $db_pc_order_id = (int) get_post_meta($order_id, 'paygine_order_id', true);
     574                if($db_pc_order_id !== $pc_order_id)
     575                    throw new Exception(__('Request data is not valid', 'paygine-payment_method'));
     576               
    399577                $pc_order_state = get_post_meta($order_id, 'paygine_order_state', true);
    400578                if($pc_order_state == self::ORDER_COMPLETED || $pc_order_state == self::ORDER_AUTHORIZED) {
    401579                    wp_redirect($this->get_return_url($order));
     580
    402581                    exit();
    403582                }
    404                
     583
    405584                $pc_order = $this->get_pc_order($pc_order_id);
    406585                $this->pc_order_validation($pc_order);
     
    408587                if(!$operation)
    409588                    throw new Exception(__('Could not find operation', 'paygine-payment_method') . " ( $pc_operation_id )");
     589
    410590                $this->pc_order_operation_validation($operation, true);
    411                
     591
    412592                $pc_order_params = $this->get_pc_order_params($pc_order);
    413593                $is_loan = (!empty($pc_order_params['vda_application_id']) || !empty($pc_order_params['fb_application_id']));
     594
    414595                // There is no valid operation amount in case of LOAN (VsegdaDa\FinBox)
    415596                if(!$is_loan)
     
    418599                $message = __('Failed to pay for the order', 'paygine-payment_method') . ":\n" . $e->getMessage();
    419600                $this->log($message, ['data' => $data ?? '', 'response' => $response]);
     601
    420602                if($order)
    421603                    $order->add_order_note(nl2br($message));
     604
    422605                wc_add_notice(nl2br($message), 'error');
    423606                wp_redirect($checkout_url);
     607
    424608                exit();
    425609            }
     610
    426611            if($pc_order_state !== $pc_order['state']) {
    427                 // updating order status
    428612                $order_status = $this->get_custom_order_status($operation['type'], $is_loan);
    429613                $order->update_status($order_status);
    430                 // updating order metadata
    431614                update_post_meta($order_id, 'paygine_order_state', $pc_order['state']);
    432                
    433                 // updating order real payment method
    434615                $payment_method = get_post_meta($order_id, 'paygine_payment_method', true);
    435                 if(!$payment_method){
     616
     617                if(!$payment_method) {
    436618                    $is_halva = !empty($pc_order_params['buyIdSumAmount']);
    437619                    $payment_method = $this->get_pc_payment_method($operation['type'], $is_halva, $is_loan);
    438620                    update_post_meta($order_id, 'paygine_payment_method', $payment_method);
    439621                }
     622
    440623                $order->add_order_note(__('Payment completed successfully', 'paygine-payment_method'));
    441624            }
     625
    442626            wp_redirect($this->get_return_url($order));
     627
    443628            exit();
    444629        }
    445        
     630
    446631        /**
    447632         * Payment notify from gateway was received
    448633         **/
    449         public function notify_from_gateway()
    450         {
     634        public function notify_from_gateway() {
    451635            global $wp_filesystem;
    452636            $order = [];
    453637            $pc_operation = [];
     638
    454639            if (empty($wp_filesystem))
    455640                WP_Filesystem();
     641
    456642            try {
    457643                $response = $wp_filesystem->get_contents('php://input');
     
    460646                if(!$order_id)
    461647                    throw new Exception(__('Undefined order ID', 'paygine-payment_method'));
     648
    462649                $order = wc_get_order($order_id);
    463650                if(!$order)
    464651                    throw new Exception(__('Failed to get order information', 'paygine-payment_method'));
    465                
    466                 // if order already completed\refunded
     652
    467653                $pc_order_state = get_post_meta($order_id, 'paygine_order_state', true);
    468                
    469654                if ($pc_order_state === self::ORDER_CANCELED || $pc_order_state === self::ORDER_BLOCKED || $pc_order_state === self::ORDER_EXPIRED)
    470655                    throw new Exception(sprintf(__('The order has already been %s', 'paygine-payment_method'), $pc_order_state));
     656
    471657                $this->pc_operation_validation($pc_operation);
    472                
    473658                $pc_order = $this->get_pc_order((int) $pc_operation['order_id']);
    474659                $this->pc_order_validation($pc_order);
    475                
    476660                $pc_order_params = $this->get_pc_order_params($pc_order);
    477661                $is_loan = (!empty($pc_order_params['vda_application_id']) || !empty($pc_order_params['fb_application_id']));
     662
    478663                // There is no valid operation amount in case of LOAN (VsegdaDa\FinBox)
    479664                if(!$is_loan)
    480665                    $this->operation_amount_validation($pc_operation, $this->centify($order->get_total()));
    481                
    482666            } catch(Exception $e) {
    483667                $message = sprintf(__('Failed to complete request for operation %s from the processing center', 'paygine-payment_method'), $pc_operation['type']) . PHP_EOL . $e->getMessage();
    484668                $this->log($message, $pc_operation);
     669
    485670                if($order)
    486671                    $order->add_order_note($message);
     672
    487673                exit($message);
    488674            }
    489             // updating order real payment method
     675
    490676            $payment_method = get_post_meta($order_id, 'paygine_payment_method', true);
    491             if(!$payment_method){
     677
     678            if(!$payment_method) {
    492679                $is_halva = !empty($pc_order_params['buyIdSumAmount']);
    493680                $payment_method = $this->get_pc_payment_method($pc_operation['type'], $is_halva, $is_loan);
    494681                update_post_meta($order_id, 'paygine_payment_method', $payment_method);
    495682            }
    496            
    497             // updating order status
     683
    498684            $order_status = $this->get_custom_order_status($pc_operation['type']);
    499685            $order->update_status($order_status);
    500             // updating order metadata
    501686            update_post_meta($order_id, 'paygine_order_state', $pc_operation['order_state']);
    502687            $message = sprintf(__('Request for operation %s from the processing center was completed successfully', 'paygine-payment_method'), $pc_operation['type']);
    503688            $order->add_order_note($message);
     689
    504690            exit('ok');
    505691        }
    506        
    507         public function complete_payment(){
     692
     693        public function complete_payment() {
    508694            echo $this->payment_action(self::OPERATION_COMPLETE);
     695
    509696            exit();
    510697        }
    511        
     698
    512699        /**
    513700         * Inherited method Process refund.
     
    521708         * @return boolean True or false based on success, or a WP_Error object.
    522709         */
    523         public function process_refund($order_id, $amount = null, $reason = '')
    524         {
     710        public function process_refund($order_id, $amount = null, $reason = '') {
    525711            return $this->payment_action(self::OPERATION_REFUND, $order_id, $amount, $reason);
    526712        }
    527        
     713
    528714        /**
    529715         * Check operation state for hold order and set complete state
     
    531717         * @return string void
    532718         */
    533         public function payment_action($type, $order_id = 0, $amount = null, $reason = '')
    534         {
    535             try{
     719        public function payment_action($type, $order_id = 0, $amount = null, $reason = '') {
     720            try {
    536721                $order = [];
    537722                $operation = [];
    538                
     723
    539724                // get variables from request and checking token for custom 'complete' action
    540725                if($type === self::OPERATION_COMPLETE){
     
    544729                        throw new Exception(__('Operation failed. Please refresh the page', 'paygine-payment_method'));
    545730                }
    546                
     731
    547732                if(!$order_id)
    548733                    throw new Exception(__('Undefined order ID', 'paygine-payment_method'));
     734
    549735                $order = wc_get_order($order_id);
    550736                if(!$order)
    551737                    throw new Exception(__('Failed to get order information', 'paygine-payment_method'));
     738
    552739                $pc_order_id = get_post_meta($order_id, 'paygine_order_id', true);
    553740                if(!$pc_order_id)
    554741                    throw new Exception(__('Failed to get Paygine order ID', 'paygine-payment_method'));
    555                
     742
    556743                $payment_method = get_post_meta($order_id, 'paygine_payment_method', true);
    557                 // converting old method to new
    558744                $payment_method = self::OLD_TO_NEW_PAYMENT_METHODS[$payment_method] ?? $payment_method;
    559745                $request_path = self::get_action_path($type, $payment_method);
    560746                if(!$request_path)
    561747                    throw new Exception(__('Failed to get operation request path', 'paygine-payment_method'));
    562                 // full refund for AUTHORIZED orders only
     748
    563749                $pc_order_state = get_post_meta($order_id, 'paygine_order_state', true);
    564750                if($amount && $amount !== $order->get_total() && $type === self::OPERATION_REFUND && $pc_order_state === self::ORDER_AUTHORIZED){
    565751                    throw new Exception(__('For orders with AUTHORIZED status, only full refunds are available', 'paygine-payment_method'));
    566752                }
     753
    567754                // hardcode loan amount = 0! we use loans only without prepayment! otherwise we need to save and use the prepayment amount!!
    568                 if($payment_method === 'loan')
     755                if($payment_method === 'loan') {
    569756                    $amount = 0;
    570                 elseif($amount)
     757                } elseif($amount) {
    571758                    $amount = $this->centify($amount);
    572                 else
     759                } else {
    573760                    $amount = $this->centify($order->get_total());
    574                
     761                }
     762
    575763                $data = [
    576764                    'sector' => $this->sector,
     
    579767                    'currency' => $this->currency
    580768                ];
     769
    581770                $this->sign_data($data, true);
    582771                $response = $this->send_request($this->url . $request_path, ['body' => $data]);
     
    585774                if($operation['type'] !== $type)
    586775                    throw new Exception(__('Operation type and action type are not equal', 'paygine-payment_method'));
    587                 // for COMPLETED orders the operation amount may not be equal to the order amount(partial refund/complete)
    588776            } catch(Exception $e) {
    589777                $comment = $this->get_action_comment($type)['fail'] . PHP_EOL . $e->getMessage();
     
    591779                if($order)
    592780                    $order->add_order_note($comment);
     781
    593782                return json_encode([
    594783                    'success' => false,
     
    596785                ]);
    597786            }
    598            
     787
    599788            $order_status = $this->get_custom_order_status($operation['type']);
    600789            if($order_status)
    601790                $order->update_status($order_status);
     791
    602792            update_post_meta($order_id, 'paygine_order_state', $operation['order_state']);
     793
    603794            $comment = $this->get_action_comment($type)['success'];
    604             if($reason){
     795            if($reason) {
    605796                $comment .= PHP_EOL . esc_html($reason);
    606797            }
    607            
     798
    608799            $order->add_order_note($comment);
     800
    609801            return json_encode([
    610802                'success' => true,
     
    612804            ]);
    613805        }
    614        
     806
    615807        /**
    616808         * Draw Complete button for authorized orders
     
    618810         * @return void
    619811         */
    620         function wc_order_item_add_complete_button($order)
    621         {
    622             if($order->get_payment_method() == $this->id){
     812        function wc_order_item_add_complete_button($order) {
     813            if($order->get_payment_method() == $this->id) {
    623814                $pc_order_state = get_post_meta($order->get_id(), 'paygine_order_state', true);
    624                 if($pc_order_state === self::ORDER_AUTHORIZED){
     815
     816                if($pc_order_state === self::ORDER_AUTHORIZED) {
    625817                    $label = __('Complete payment', 'paygine-payment_method');
    626                     $nonce_complete = wp_create_nonce('paygine_complete' . $order->get_id());
    627                     ?>
    628                     <script src="<?php echo plugins_url('assets/js/scripts.js', plugin_basename(__FILE__)); ?>"></script>
    629                     <input type="hidden" id="nonce_paygine_complete" value="<?php echo $nonce_complete; ?>">
    630                     <button type="button" id="button_paygine_complete"
    631                                     class="button custom-items"><?php echo $label; ?></button>
    632                     <?php
    633                 }
    634             }
    635         }
    636        
    637         private function calc_fiscal_position_shop_cart($order, $order_amount)
    638         {
     818                    $nonce_complete = wp_create_nonce('paygine_complete' . $order->get_id());?>
     819
     820                    <script src="<?php echo plugins_url('assets/js/scripts.js', plugin_basename(__FILE__));?>"></script>
     821                    <input type="hidden" id="nonce_paygine_complete" value="<?php echo $nonce_complete;?>">
     822                    <button type="button" id="button_paygine_complete" class="button custom-items"><?php echo $label;?></button>
     823                <?php }
     824            }
     825        }
     826
     827        private function calc_fiscal_position_shop_cart($order, $order_amount) {
    639828            $fiscal_positions = '';
    640829            $fiscal_amount = 0;
     
    642831            $shop_cart_key = 0;
    643832            $order_items = $order->get_items();
    644            
     833
    645834            foreach($order_items as $item) {
    646835                $item_data = $item->get_data();
     
    653842                $fiscal_positions .= str_replace([';', '|'], '', $item_data['name']) . '|';
    654843                $fiscal_amount += $item_data['quantity'] * $element_price;
    655                
    656844                $shop_cart[$shop_cart_key]['quantityGoods'] = (int)$item['quantity'];
    657845                $shop_cart[$shop_cart_key]['goodCost'] = $item_price - $item_discount;
     
    659847                $shop_cart_key++;
    660848            }
    661            
     849
    662850            $shipping_amount = $order->get_shipping_total();
    663             if ($shipping_amount){
     851
     852            if ($shipping_amount) {
    664853                $fiscal_positions .= '1;' . $this->centify($shipping_amount) . ';6;Доставка|';
    665854                $fiscal_amount += $this->centify($shipping_amount);
    666                
    667855                $shop_cart[$shop_cart_key]['quantityGoods'] = 1;
    668856                $shop_cart[$shop_cart_key]['goodCost'] = $shipping_amount;
    669857                $shop_cart[$shop_cart_key]['name'] = 'Доставка';
    670858            }
     859
    671860            $fiscalDiff = abs($fiscal_amount - $order_amount);
    672             if ($fiscalDiff){
     861
     862            if ($fiscalDiff) {
    673863                $fiscal_positions .= '1;' . $fiscalDiff . ';6;Скидка;14|';
    674864                $shop_cart = [];
    675865            }
     866
    676867            $this->fiscal_positions = substr($fiscal_positions, 0, -1);
    677868            $this->shop_cart = $shop_cart;
    678869        }
    679        
    680         private function get_pc_order($pc_order_id)
    681         {
     870
     871        private function get_pc_order($pc_order_id) {
    682872            if(!$pc_order_id)
    683873                throw new Exception(__('Missing PC order ID', 'paygine-payment_method'));
     874
    684875            $data = [
    685876                'sector' => $this->sector,
    686877                'id' => $pc_order_id,
    687878            ];
     879
    688880            $this->sign_data($data, true);
    689881            $response = $this->send_request($this->url . '/webapi/Order', ['body' => $data]);
     882
    690883            return $this->parse_xml($response['body']);
    691884        }
    692        
    693         private function get_pc_order_operation($pc_order, $pc_operation_id)
    694         {
     885
     886        private function get_pc_order_operation($pc_order, $pc_operation_id) {
    695887            if(empty($pc_order['operations']['operation']))
    696888                throw new Exception(__('There are no operations in the order', 'paygine-payment_method'));
    697             // "operation" may contain one or few operations (array)
     889
    698890            $operations = isset($pc_order['operations']['operation'][0]) ? $pc_order['operations']['operation'] : [$pc_order['operations']['operation']];
     891
    699892            foreach($operations as $operation) {
    700893                if(empty($operation['id'])) continue;
     
    702895                    return $operation;
    703896            }
     897
    704898            return [];
    705899        }
    706        
    707         private function get_pc_order_params($pc_order)
    708         {
     900
     901        private function get_pc_order_params($pc_order) {
    709902            $params = [];
     903
    710904            if(empty($pc_order['parameters']['parameter'])) return $params;
    711905            foreach($pc_order['parameters']['parameter'] as $param) {
     
    718912                $params[$key] = $param['value'] ?? 'null';
    719913            }
     914
    720915            return $params;
    721916        }
    722        
    723         public function pc_operation_validation($response): void
    724         {
     917
     918        public function pc_operation_validation($response): void {
    725919            if(empty($response['reason_code']) && !empty($response['code']) && !empty($response['description']))
    726920                throw new Exception("$response[description] (error code $response[code])");
     921
    727922            if(empty($response['signature']))
    728923                throw new Exception(__('Signature is missing', 'paygine-payment_method'));
     924
    729925            $xml_string = self::xml_values_to_string($response);
    730926            $signature = $this->generate_sign($xml_string, true);
    731927            if ($signature !== $response['signature'])
    732928                throw new Exception(__('Invalid signature', 'paygine-payment_method'));
     929
    733930            if(!in_array($response['type'], self::OPERATION_TYPES))
    734931                throw new Exception(__('Unknown operation type', 'paygine-payment_method') . ' : ' . $response['type']);
     932
    735933            if($response['state'] !== self::OPERATION_APPROVED)
    736934                throw new Exception(__('Operation not approved', 'paygine-payment_method'));
    737935        }
    738        
    739         public function pc_order_validation($order): void
    740         {
     936
     937        public function pc_order_validation($order): void {
    741938            if(empty($order['reason_code']) && !empty($order['code']) && !empty($order['description']))
    742939                throw new Exception("$order[description] (error code $order[code])");
     940
    743941            if(empty($order['signature']))
    744942                throw new Exception(__('Signature is missing', 'paygine-payment_method'));
     943
    745944            $xml_string = self::xml_values_to_string($order);
    746945            $signature = $this->generate_sign($xml_string, true);
     
    748947                throw new Exception(__('Invalid signature', 'paygine-payment_method'));
    749948        }
    750         public function pc_order_operation_validation($operation, $is_payment = false): void
    751         {
     949
     950        public function pc_order_operation_validation($operation, $is_payment = false): void {
    752951            if(empty($operation['reason_code']) && !empty($operation['code']) && !empty($operation['description']))
    753952                throw new Exception(__('An error occurred during the operation', 'paygine-payment_method') . "($operation[code] : $operation[description])");
     953
    754954            if(!in_array($operation['type'], self::OPERATION_TYPES))
    755955                throw new Exception(__('Unknown operation type', 'paygine-payment_method') . ' : ' . $operation['type']);
     956
    756957            if($operation['state'] !== self::OPERATION_APPROVED)
    757958                throw new Exception(__('Operation not approved', 'paygine-payment_method'));
     959
    758960            if($is_payment && !in_array($operation['type'], self::PAID_OPERATION_TYPES)) {
    759961                throw new Exception(__('Unknown payment operation type', 'paygine-payment_method') . ' : ' . $operation['type']);
    760962            }
    761963        }
    762        
    763         public static function xml_values_to_string($xml_array): string
    764         {
     964
     965        public static function xml_values_to_string($xml_array): string {
    765966            if(!is_array($xml_array)) return '';
     967
    766968            $res = '';
    767969            foreach($xml_array as $key => $value) {
     
    769971                $res .= is_string($value) ? $value : self::xml_values_to_string($value);
    770972            }
     973
    771974            return $res;
    772975        }
    773        
    774         public function get_operation_amount($operation): int
    775         {
     976
     977        public function get_operation_amount($operation): int {
    776978            return !empty($operation['buyIdSumAmount']) ? (int) $operation['buyIdSumAmount'] : (int) $operation['amount'];
    777979        }
    778        
    779         private function operation_amount_validation($operation, $order_amount): void
    780         {
     980
     981        private function operation_amount_validation($operation, $order_amount): void {
    781982            $operation_amount = self::get_operation_amount($operation);
     983
    782984            if (!$operation_amount || $operation_amount !== $order_amount)
    783985                throw new \Exception(__('Invalid operation amount', 'paygine-payment_method'));
    784986        }
    785        
    786         public function get_custom_order_status($operation_type, $is_loan = false)
    787         {
     987
     988        public function get_custom_order_status($operation_type, $is_loan = false) {
    788989            switch($operation_type){
    789990                case 'PURCHASE':
     
    796997                    return $this->canceled_status ?? false;
    797998            }
     999
    7981000            return false;
    7991001        }
    800        
    801         private function get_action_path($action_type, $payment_type)
    802         {
     1002
     1003        private function get_action_path($action_type, $payment_type) {
    8031004            $prefix = ($payment_type == 'halva' || $payment_type == 'halva_two_steps') ? '/webapi/custom/svkb/' : '/webapi/';
     1005
    8041006            switch($action_type) {
    8051007                case self::OPERATION_COMPLETE: return $prefix . 'Complete';
    8061008                case self::OPERATION_REFUND: return $prefix . 'Reverse';
    8071009            }
     1010
    8081011            return false;
    8091012        }
    810        
    811         private function get_action_comment($action)
    812         {
     1013
     1014        private function get_action_comment($action) {
    8131015            switch($action) {
    8141016                case self::OPERATION_COMPLETE: return [
     
    8221024            }
    8231025        }
    824        
    825         private function get_pc_payment_method($operation_type, $is_halva, $is_loan)
    826         {
     1026
     1027        private function get_pc_payment_method($operation_type, $is_halva, $is_loan) {
    8271028            switch($operation_type) {
    8281029                case 'PURCHASE':
     
    8411042            return '';
    8421043        }
    843        
    844         private function send_request($url, $args, $method = 'post', int $repeat = 3)
    845         {
     1044
     1045        private function send_request($url, $args, $method = 'post', int $repeat = 3) {
    8461046            $method = (strtolower($method) === 'get') ? 'get' : 'post';
    8471047            $repeat = !$repeat ? 1 : $repeat;
     
    8531053                sleep(2);
    8541054            }
     1055
    8551056            return $response;
    8561057        }
    857        
     1058
    8581059        /**
    8591060         * Admin Panel Options
    8601061         **/
    861         public function admin_options()
    862         {
    863             ?>
    864             <h3><?php _e('Paygine', 'paygine-payment_method'); ?></h3>
    865             <p><?php echo sprintf(__('Payments with bank cards via the <a href="%s" target="_blank">Paygine</a> payment system.', 'paygine-payment_method'), self::PLUGIN_SITE); ?></p>
     1062        public function admin_options() {?>
     1063            <h3><?php _e('Paygine', 'paygine-payment_method');?></h3>
     1064            <p><?php echo sprintf(__('Payments with bank cards via the <a href="%s" target="_blank">Paygine</a> payment system.', 'paygine-payment_method'), self::PLUGIN_SITE);?></p>
    8661065            <table class="form-table">
    867                 <?php
    868                 // Generate the HTML For the settings form.
    869                 $this->generate_settings_html();
    870                 ?>
    871             </table><!--/.form-table-->
    872             <?php
    873         }
    874        
     1066                <?php $this->generate_settings_html();?>
     1067            </table>
     1068        <?php }
     1069
    8751070        /**
    8761071         * Get current currency code
     
    8781073         * @return string
    8791074         */
    880         public function get_currency($wc_currency): string
    881         {
     1075        public function get_currency($wc_currency): string {
    8821076            switch($wc_currency) {
    8831077                case 'EUR': return '978';
    8841078                case 'USD': return '840';
     1079
    8851080                default: return '643';
    8861081            }
    8871082        }
    888        
     1083
    8891084        /**
    8901085         * @param array $data
     
    8921087         * @return void
    8931088         */
    894         public function sign_data(&$data, $password = false): void
    895         {
     1089        public function sign_data(&$data, $password = false): void {
    8961090            unset($data['signature']);
     1091
    8971092            $sign = implode('', $data);
    8981093            if($password)
    8991094                $sign .= $this->password;
     1095
    9001096            $data['signature'] = base64_encode($this->sign_hash($sign));
    9011097        }
    902        
    903         public function generate_sign($data, $password = false): string
    904         {
     1098
     1099        public function generate_sign($data, $password = false): string {
    9051100            $string = is_array($data) ? implode('', $data) : (string) $data;
    9061101            if($password)
    9071102                $string .= $this->password;
     1103
    9081104            return base64_encode($this->sign_hash($string));
    9091105        }
    910        
    911         private function sign_hash($data)
    912         {
     1106
     1107        private function sign_hash($data) {
    9131108            return hash($this->hash_algo, $data);
    9141109        }
    915        
     1110
    9161111        /**
    9171112         * Changes a currency unit to a derived equivalent currency unit
     
    9201115         * @return int
    9211116         */
    922         public function centify($value): int
    923         {
     1117        public function centify($value): int {
    9241118            return intval(strval($value * 100));
    9251119        }
    926        
    927         private function paygine_get_url(): string
    928         {
     1120
     1121        private function paygine_get_url(): string {
    9291122            $paygine_url = "https://test.paygine.com";
    930             if ($this->testmode == "0"){
     1123
     1124            if ($this->testmode == "0") {
    9311125                $paygine_url = "https://pay.paygine.com";
    9321126            }
     1127
    9331128            return $paygine_url;
    9341129        }
    935        
     1130
    9361131        /**
    9371132         * Parse $xml from PC with removing element with values = '' or null
     
    9391134         * @return false|mixed
    9401135         */
    941         public function parse_xml(string $string)
    942         {
     1136        public function parse_xml(string $string) {
    9431137            if (!$string)
    9441138                throw new Exception(__('Server response is empty', 'paygine-payment_method'));
     1139
    9451140            $xml = simplexml_load_string($string);
    9461141            if (!$xml)
    9471142                throw new Exception(__('Invalid XML from response', 'paygine-payment_method'));
     1143
    9481144            $valid_xml = json_decode(json_encode($xml), true);
    9491145            if (!$valid_xml)
    9501146                throw new Exception(__('Unable to decode xml', 'paygine-payment_method'));
     1147
    9511148            return $valid_xml;
    9521149        }
    953        
     1150
    9541151        /**
    9551152         * Write log-messages in file when it accessible in FS on hosting
     
    9581155         * @param array $data
    9591156         */
    960         public function log(string $message, array $data = [])
    961         {
     1157        public function log(string $message, array $data = []) {
    9621158            $log = "\n[" . date("H:i:s d.m.Y") . '] ' . $message;
    9631159            if($data)
    9641160                $log .= "\n" . var_export($data, true);
     1161
    9651162            file_put_contents(ABSPATH . $this->id . '.log', $log, FILE_APPEND);
    9661163        }
    967        
    968     } // class
     1164    }
     1165
    9691166    /**
    9701167     * Add this gateway to the list of available payment gateways
     
    9731170     * @return mixed
    9741171     */
    975     function add_paygine_gateway($methods)
    976     {
     1172    function add_paygine_gateway($methods) {
    9771173        $methods[] = 'woocommerce_paygine';
     1174
    9781175        return $methods;
    9791176    }
    980    
     1177
    9811178    add_filter('woocommerce_payment_gateways', 'add_paygine_gateway');
    982    
     1179
    9831180    add_filter(
    9841181        'plugin_action_links_' . plugin_basename( __FILE__ ),
     
    9921189            if (!class_exists('woocommerce'))
    9931190                return $links;
    994            
     1191
    9951192            array_unshift(
    9961193                $links,
     
    10011198                )
    10021199            );
    1003            
     1200
    10041201            return $links;
    10051202        }
  • paygine/trunk/readme.txt

    r3011342 r3036869  
    1 === paygine payment method ===
     1=== Модуль оплаты Paygine ===
    22Contributors: paygine
    3 Tags: e-commerce, payments, paygine, платежные системы, sale
    4 Tested up to: 6.3.2
     3Tags: woocommerce, payments, paygine, платежные системы, sale
    54Requires at least: 4.7
     5Tested up to: 6.4.3
    66Requires PHP: 7.4
    7 Stable tag: 2.0.1
     7Stable tag: 2.2.0
     8WC requires at least: 6.0
     9WC tested up to: 8.5.1
    810License: GPLv3
    911License URI: https://www.gnu.org/licenses/gpl-3.0.html
    1012
    11 == Плагин «Paygine» — платежное решение для сайтов на Wordpress ==
    12     • 3 встроенных способа приема платежей.
    13     • Для юридических лиц и ИП.
    14     • Быстрое поступление денег на счет компании.
    15     • Полное соответствие 54-ФЗ.
    16     • Бесплатное подключение.
    17 == Настройка плагина ==
    18 Чтобы принимать платежи через плагин, подайте заявку на подключение к Paygine на сайте paygine.ru. С вами свяжется сотрудник компании и выдаст доступ на подключение.
    19 == Поддержка передачи чека ==
    20     1. Настройте быструю передачу чеков в налоговую из Paygine согласно 54-ФЗ.
    21     2. Передавайте чеки через партнеров (облачные кассы «АТОЛ Онлайн», Orange Data, «Бизнес.ру», Kit online).
    22 == Тарифы ==
    23     • Комиссия за прием платежей — от 1%. Комиссия рассчитывается индивидуально для каждого бизнеса. Для корректной оценки тарифа необходимо предоставить информацию по виду деятельности компании, среднему чеку и оборотам в месяц.  
    24 == После подключения Paygine доступны ==
     13== Description ==
     14
     15= Плагин «Paygine» — платежное решение для сайтов на Wordpress =
     16- 3 встроенных способа приема платежей
     17- Для юридических лиц и ИП
     18- Быстрое поступление денег на счет компании
     19- Полное соответствие 54-ФЗ
     20- Бесплатное подключение
     21
     22= Поддержка передачи чека =
     23
     241. Настройте быструю передачу чеков в налоговую из Paygine согласно 54-ФЗ.
     252. Передавайте чеки через партнеров (облачные кассы «АТОЛ Онлайн», Orange Data, «Бизнес.ру», Kit online).
     26
     27= Тарифы =
     28
     29Комиссия за прием платежей — от 1%. Комиссия рассчитывается индивидуально для каждого бизнеса. Для корректной оценки тарифа необходимо предоставить информацию по виду деятельности компании, среднему чеку и оборотам в месяц.  
     30
     31= После подключения Paygine доступны =
     32
    25333 способа приема платежей:
    26     • Банковские карты (MasterCard/Visa/MIR)
    27     • СБП
    28     • Халва Частями
     34- Банковские карты (MasterCard/Visa/MIR)
     35- СБП
     36- Плайт
    2937
    30 • Личный кабинет, в котором вы сможете видеть все операции, возвращать платежи, выставлять и отправлять счета и обратиться в службу поддержки paygine (служба поддержки paygine работает 24/7).
     38Личный кабинет, в котором вы сможете видеть все операции, возвращать платежи, выставлять и отправлять счета и обратиться в службу поддержки paygine (служба поддержки paygine работает 24/7).
     39
     40== Installation ==
     41
     42Чтобы принимать платежи через плагин, подайте заявку на подключение к Paygine на сайте https://paygine.ru. С вами свяжется сотрудник компании и выдаст доступ на подключение.
    3143
    3244== Screenshots ==
     45
    33461. Страница настроек плагина
Note: See TracChangeset for help on using the changeset viewer.