Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
paymentmarker.php
1<?php
2
4
6
8{
9 private Service $service;
10 private Sale\Payment $payment;
11 private Sale\Order $order;
12
17 public function __construct(Service $service, Sale\Payment $payment)
18 {
19 $this->service = $service;
20 $this->payment = $payment;
21
22 $this->order = $payment->getOrder();
23 }
24
31 public function mark(ServiceResult $result): PaymentMarker
32 {
33 if ($result->isSuccess())
34 {
35 return $this;
36 }
37
38 $markerResult = new Sale\Result();
39 $markerResult->addWarnings($result->getErrors());
40
41 $this->addMarker($markerResult);
42
43 $this->payment->setField('MARKED', 'Y');
44
45 return $this;
46 }
47
53 public function save(): Sale\Result
54 {
55 return $this->order->save();
56 }
57
58 private function addMarker(Sale\Result $markerResult): void
59 {
61 $markerClassName = $this->getEntityMarkerClassName();
62 $markerClassName::addMarker($this->order, $this->payment, $markerResult);
63 }
64
65 private function getEntityMarkerClassName()
66 {
67 $registry = Sale\Registry::getInstance($this->service->getField('ENTITY_REGISTRY_TYPE'));
68 return $registry->getEntityMarkerClassName();
69 }
70}
__construct(Service $service, Sale\Payment $payment)