29 function($className, $id) {
34 $paymentClass = $registry->getPaymentClassName();
36 $r = $paymentClass::getList([
37 'select'=>[
'ORDER_ID'],
41 if($row = $r->fetch())
44 $orderClass = $registry->getOrderClassName();
46 $order = $orderClass::load($row[
'ORDER_ID']);
47 $payment = $order->getPaymentCollection()->getItemById($id);
55 $this->
addError(
new Error(
'payment is not exists', 200640400001));
65 $entity = new \Bitrix\Sale\Rest\Entity\Payment();
66 return [
'PAYMENT'=>$entity->prepareFieldInfos(
73 $builder = $this->getBuilder();
74 $builder->buildEntityPayments($fields);
76 if($builder->getErrorsContainer()->getErrorCollection()->count()>0)
78 $this->
addErrors($builder->getErrorsContainer()->getErrors());
82 $order = $builder->getOrder();
92 return [
'PAYMENTS'=>$this->toArray($order)[
'ORDER'][
'PAYMENTS']];
95 public function addAction(array $fields)
100 $data[
'ORDER'][
'ID'] = $fields[
'ORDER_ID'];
101 $data[
'ORDER'][
'PAYMENTS'] = [$fields];
103 $builder = $this->getBuilder(
105 'deletePaymentIfNotExists' =>
false
109 $builder->buildEntityPayments($data);
111 if($builder->getErrorsContainer()->getErrorCollection()->count()>0)
113 $this->
addErrors($builder->getErrorsContainer()->getErrors());
117 $order=$builder->getOrder();
119 $collection = $order->getPaymentCollection();
121 foreach($collection as $payment)
123 if($payment->getId() <= 0)
125 $idx = $payment->getInternalIndex();
138 $entity = $order->getPaymentCollection()->getItemByIndex($idx);
139 return [
'PAYMENT'=>$this->
get($entity)];
142 public function updateAction(\
Bitrix\
Sale\Payment $payment, array $fields)
146 $fields[
'ID'] = $payment->getId();
147 $fields[
'ORDER_ID'] = $payment->getOrderId();
149 $data[
'ORDER'][
'ID'] = $fields[
'ORDER_ID'];
150 $data[
'ORDER'][
'PAYMENTS'] = [$fields];
152 $builder = $this->getBuilder(
153 new SettingsContainer([
154 'deletePaymentIfNotExists' =>
false
157 $builder->buildEntityPayments($data);
159 if($builder->getErrorsContainer()->getErrorCollection()->count()>0)
161 $this->
addErrors($builder->getErrorsContainer()->getErrors());
165 $order = $builder->getOrder();
173 if($r->hasWarnings())
180 $entity = $order->getPaymentCollection()->getItemById($payment->getId());
181 return [
'PAYMENT'=>$this->
get($entity)];
186 $r = $payment->delete();
187 return $this->save($payment, $r);
192 return [
'PAYMENT'=>$this->
get($payment)];
197 $select = empty($select) ? [
'*'] : $select;
198 $order = empty($order) ? [
'ID'=>
'ASC'] : $order;
201 new \Bitrix\Main\Entity\ReferenceField(
203 '\Bitrix\Sale\Internals\PaySystemActionTable',
204 array(
'=this.PAY_SYSTEM_ID' =>
'ref.ID')
208 $payments = \Bitrix\Sale\Payment::getList(
213 'offset' => $pageNavigation->
getOffset(),
214 'limit' => $pageNavigation->
getLimit(),
215 'runtime' => $runtime
219 return new Page(
'payments', $payments,
function() use ($select, $filter, $runtime)
229 return $payment->getOrderId();
234 return $payment->getPaymentSystemId();
239 return $payment->getPaymentSystemName();
244 return $payment->getPersonTypeId();
249 return $payment->getSum();
254 return $payment->getSumPaid();
259 return $payment->isInner()?
'Y':
'N';
264 return $payment->isMarked()?
'Y':
'N';
269 return $payment->isPaid()?
'Y':
'N';
274 return $payment->isReturn()?
'Y':
'N';
279 $r = $payment->setPaid($value);
282 $this->save($payment, $r);
302 $r = $payment->setReturn($value);
303 return $this->save($payment, $r);
318 if ($errors = $result->getErrors())
339 if ($errors = $result->getErrors())
358 $collection = $payment->getCollection();
359 $r = $collection->getOrder()->save();
366 return $r->isSuccess();
371 $payments = $this->toArray($payment->getCollection()->getOrder(), $fields)[
'ORDER'][
'PAYMENTS'];
372 foreach ($payments as $item)
374 if($item[
'ID']==$payment->getId())
384 return isset($fields[
'PAYMENTS'])?[
'PAYMENT'=>$fields[
'PAYMENTS']]:[];
389 if($name ==
'getorderid'
390 || $name ==
'getpaymentsystemid'
391 || $name ==
'getpaymentsystemname'
392 || $name ==
'getpersontypeid'
394 || $name ==
'getsumpaid'
395 || $name ==
'isinner'
396 || $name ==
'ismarked'
397 || $name ==
'isnarked'
399 || $name ==
'isreturn'
402 $r = $this->checkReadPermissionEntity();
404 elseif($name ==
'setpaid'
405 || $name ==
'setavailablepaysystems'
406 || $name ==
'clearavailablepaysystems'
407 || $name ==
'setreturn')
409 $r = $this->checkModifyPermissionEntity();
413 $r = parent::checkPermissionEntity($name);
getPrimaryAutoWiredParameter()