accountId = $accountId; $this->transactionId = $transactionId; $this->amount = $amount; $this->resultCode = $resultCode; $this->signature = $signature; $this->cms = $cms; } public function getResultCode(): ResultCode { return $this->resultCode; } /** * @param array $attributes `INVENTORY`, `CLIENT`, `CUSTOMER`, `PHONE` — êàê ó Pay URL */ public function toXml(array $attributes = []): CallbackResponse { return CallbackResponse::xml( MntResponseXml::build( $this->accountId, $this->transactionId, $this->resultCode, $this->amount, $this->sign(), $this->cms, $attributes, ), ); } /** * @param array $receipt îáúåêò `receipt` ñõåìû (`client`, `items`); äåíåæíûå * ïîëÿ — ÷åðåç {@see JsonNumber::placeholder()}, ñòðîêè â UTF-8 */ public function toJson(array $receipt): CallbackResponse { $payload = [ 'id' => $this->accountId, 'transactionId' => $this->transactionId, ]; if ($this->amount !== null) { $payload['amount'] = JsonNumber::placeholder($this->amount); } $payload += [ 'signature' => $this->sign(), 'resultCode' => (string) $this->resultCode->getValue(), 'description' => $this->resultCode->description(), 'cms' => $this->cms, 'receipt' => $receipt, ]; return CallbackResponse::json(JsonNumber::encode($payload)); } private function sign(): string { return $this->signature->forResponse($this->resultCode, $this->accountId, $this->transactionId); } }