public static function create(PaymentCollection $collection, PaySystemService $paySystem = null) { $fields = array('PAID' => 'N', 'IS_RETURN' => 'N'); if ($paySystem != null) { $fields["PAY_SYSTEM_ID"] = $paySystem->getId(); $fields["PAY_SYSTEM_NAME"] = $paySystem->getName(); } $payment = new static(); $payment->setFieldsNoDemand($fields); $payment->setCollection($collection); $payment->paySystem = $paySystem; return $payment; }