/** * Returns detailed information on the current status and payment details. * * Please bear in mind that the transaction is initiated not when the * user is redirected to the payment page, but later – once his payment * details are confirmed, i.e. you may well see no transaction, which * you believe should have been started already. * * Returns `null` if invoice is not found and `Payment::isThrowExceptions()` is `false`. * * @param null|int $invoiceId Invoice ID. * * @return Invoice|null * @throws InvoiceNotFoundException If invoice is not found. */ public function getInvoice($invoiceId = null) { $signature = $this->auth->getSignatureHash('{ml}:{ii}:{vp}', ['ml' => $this->auth->getMerchantLogin(), 'ii' => $invoiceId, 'vp' => $this->auth->getValidationPassword()]); $response = $this->sendRequest($this->serviceBaseUrl . 'OpState', ['MerchantLogin' => $this->auth->getMerchantLogin(), 'InvoiceID' => $invoiceId, 'Signature' => $signature], $this->requestMethod); $sxe = simplexml_load_string($response); $this->parseError($sxe); return ['InvoiceId' => (int) $invoiceId, 'StateCode' => (int) $sxe->State->Code, 'RequestDate' => new \DateTime((string) $sxe->State->RequestDate), 'StateDate' => new \DateTime((string) $sxe->State->StateDate), 'PaymentMethod' => (string) $sxe->Info->IncCurrLabel, 'ClientSum' => (double) $sxe->Info->IncSum, 'ClientAccount' => (string) $sxe->Info->IncAccount, 'PaymentMethodCode' => (string) $sxe->Info->PaymentMethod->Code, 'PaymentMethodDescription' => (string) $sxe->Info->PaymentMethod->Description, 'Currency' => (string) $sxe->Info->OutCurrLabel, 'ShopSum' => (double) $sxe->Info->OutSum]; }
/** * @param array $data * @param bool $strict * @param string $passwordType * * @return bool */ private function validate(array $data, $strict, $passwordType) { if (!isset($data['InvId'], $data['OutSum'], $data['SignatureValue'])) { return false; } $this->set($data); $this->setId($data['InvId']); $this->valid = $data['SignatureValue'] === $this->auth->getSignatureHash('{os}:{ii}:{pp}{:cp}', ['os' => $data['OutSum'], 'ii' => $data['InvId'], 'pp' => $this->auth->{'get' . $passwordType . 'Password'}(), 'cp' => $this->getCustomParamsString()]); if ($this->valid && $strict) { try { $this->fetch(); $this->valid = $data['OutSum'] == $this->shopSum && Payment::STATE_COMPLETED === $this->stateCode; } catch (InvoiceNotFoundException $e) { $this->valid = false; } } return $this->valid; }