PageSourceSearch

https://sgc-opeca.ru/pay/js/pay.js?17750513077146

js sgc-opeca.ru collected 2026-09-25 20:18:29 UTC 7,146 bytes, 208 lines download raw bytes

1// для смены селектов с пансионатами и без
2$(document).on('change', '#payment_form [name=TYPE]', function (e) {
3     if ($(this).val() == 118) {
4          $('[name=NUM_DOGOVOR]').closest('.form-group').addClass('hide');
5      } else {
6          $('[name=NUM_DOGOVOR]').closest('.form-group.hide').removeClass('hide');
7      }
8});
9
10// стили для эппла
11if ($(window).width() > 767) {
12  var isiPad = navigator.userAgent.match(/iPad/i) != null;
13
14  var ua = navigator.userAgent;
15  var isiPad = /iPad/i.test(ua) || /iPhone OS 3_1_2/i.test(ua) || /iPhone OS 3_2_2/i.test(ua);
16  if (!isiPad) {
17      $('.styler').styler();
18  }
19}
20
21// вычисляем конечную сумму для оплаты
22function calc() {
23  var $sum_total = $('#payment_form [name=SUM_TOTAL]');
24
25  val = $sum_total.val();
26  val = val.replace(',', '.');
27
28  val = parseFloat(val);
29  $sum_total.val(val);
30
31  $sum_total.val(isNaN(val) ? '' : val);
32  $('#summ').text(isNaN(val) ? 0 : val);
33  summ_comission = Math.round((val * 1.022) * 100, 2) / 100;
34  $('#summ_comission').text(isNaN(summ_comission) ? '' : summ_comission);
35}
36
37// выставляем конечную сумму для оплаты
38var tID = 0;
39$(document).on('keyup', '#payment_form [name=SUM_TOTAL]', function () {
40  clearTimeout(tID);
41  tID = setTimeout(calc, 1000);
42})
43
44// Сохранение данных при изменении поля ввода и восстановление при загрузке страницы
45$("input").on("input", function () {
46if ($(this).attr("type") === "submit") return;
47
48var inputName = $(this).attr("name");
49var inputValue = $(this).val();
50localStorage.setItem(inputName, inputValue);
51});
52
53// Функция для очистки всех полей формы и соответствующих данных в localStorage
54function clearFormAndLocalStorage(form) {
55$(form)
56  .find("input")
57  .each(function () {
58    if ($(this).attr("type") !== "submit") {
59      var inputName = $(this).attr("name");
60      localStorage.removeItem(inputName);
61      $(this).val("");
62    }
63  });
64}
65
66$(document).ready(function () {
67$("input").each(function () {
68  if ($(this).attr("type") === "submit") return;
69
70  var inputName = $(this).attr("name");
71  var savedValue = localStorage.getItem(inputName);
72
73  if (savedValue) {
74    if ($(this).val() == '') $(this).val(savedValue);
75  }
76});
77calc()
78});
79$("#payment_clear").click(function(e) {
80e.preventDefault();
81clearFormAndLocalStorage("#payment_form");
82});
83
84
85// функция для работы виджетом Клаудпейментс
86function payCloudPayments(data) {
87  var widget = new cp.CloudPayments();
88
89  //console.log('data = ')
90  //console.log(data)
91
92  var receipt = {
93          "Items": [
94              {
95                  "label": data.label,
96                  "price": Number(data.amount),
97                  "quantity": 1.00,
98                  "amount": Number(data.amount),
99                  "vat": 0, // ставка НДС
100                  "method": 1, // 1 - Предоплата 100%
101                  "object": 4, // 4 - услуга
102              }
103          ],
104          "calculationPlace": data.domen, // место осуществления расчёта, по умолчанию берется значение из кассы
105          "taxationSystem": 0, // система налогообложения; необязательный, если у вас одна система налогообложения
106          "email": data.email,
107          "phone": data.phone,
108          "customerInfo": data.firstName,
109          "isBso": false, // чек является бланком строгой отчётности
110          "AgentSign": null, // признак агента, тег ОФД 1057
111          "amounts":
112          {
113              "electronic": Number(data.amount),
114              "advancePayment": 0.00,
115              "credit": 0.00,
116              "provision": 0.00
117          }
118      };
119
120  widget.pay('charge',
121      {
122          publicId: data.publicId,
123          description: 'Оплата услуг в sgc-opeca.ru ' + ' - номер заказа ' + data['orderId'],
124          amount: Number(data.amount),
125          currency: 'RUB',
126          invoiceId: data.orderId,
127          email: data.email,
128          skin: "mini",
129          autoClose: 3,
130          payer: {
131              firstName: data.firstName,
132              lastName: data.lastName,
133              phone: data.phone,
134          },
135          data: {
136              cloudPayments: {
137                  "CustomerReceipt": receipt, // онлайн-чек
138              }
139          },
140      },
141      {
142          onSuccess: function (options) { // success
143              //действие при успешной оплате
144              //console.log('options = ');
145              //console.log(options);
146              dataLayer.push({
147                event: "GAevent",
148                eventCategory: "pay",
149                eventAction: "success",
150              });
151
152            },
153            onFail: function (reason, options) { // fail
154              //действие при неуспешной оплате
155              //console.log('reason = ');
156              //console.log(reason);
157              // window.location.replace(data.url);
158            },
159            onComplete: function (paymentResult, options) {
160              //console.log('Вызывается как только виджет получает от api.cloudpayments ответ с результатом транзакции.');
161              //console.log('paymentResult = ');
162              console.log(paymentResult);
163              // window.location.replace(data.url);
164
165              // тут мы получаем результаты оплаты, и нужно вписать в аналитику инфу об этом
166          }
167      }
168  )
169}
170
171
172// валидация и обработка формы
173$(document).on('submit', '#payment_form', function (e) {
174  e.preventDefault();
175
176  var $form = $(this);
177  $form.find('.alert').remove();
178  $sum = $form.find('[name=SUM_TOTAL]');
179  $sum.val($sum.val().replace(/[^0-9\.]+/g, ""));
180
181  $.ajax({
182      url: $form.attr('action'),
183      type: 'post',
184      data: $form.serialize(),
185      success: function (response) {
186        console.log(response);
187          eval(('response=' + response));
188          console.log(response);
189          if (response.status == 'ERROR') {
190              $form.prepend('<div class="alert alert-error">' + response.text + '</div>');
191              eval('response=' + response);
192          } else {
193              if (typeof response.redirect !== 'undifined' || response.redirect !== '') {
194                  // console.log('вызываем виджет для Клаудпейментс');
195                  payCloudPayments(response.data);
196                  // $form.prepend('<div class="alert alert-success">' + response.text + '</div>');
197                  // setTimeout(() => {
198                  //   window.location = response.redirect;
199                  // }, 1000);
200
201              }
202          }
203      }
204  });
205
206  return false;
207});
208

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.