function processARUDD($uri) { $request = new Am_HttpRequest($uri, Am_HttpRequest::METHOD_POST); $request->setAuth($this->getConfig('login'), $this->getConfig('passwd')); $response = $request->send(); $origXml = simplexml_load_string($response->getBody()); $xml = simplexml_load_string(base64_decode((string) $origXml->file)); // $log = $this->logRequest($request, 'ARUDD'); // $log->add($response); // $log->add($origXml->asXML()); // $log->add($xml->asXML()); foreach ($xml->Data->ARUDD->Advice->OriginatingAccountRecords->OriginatingAccountRecord->ReturnedDebitItem as $ARUDD) { $ref = (string) $ARUDD['ref']; /* @var $invoice Invoice */ $invoice = $this->getDi()->invoiceTable->findFirstByPublicId(substr($ref, strlen(self::REF_PREFIX))); if ($invoice) { $payments = $invoice->getPaymentRecords(); $p = array_pop($payments); $tr = new Am_Paysystem_Transaction_Manual($this); $tr->setInvoice($invoice); $tr->setReceiptId(sprintf('%s-%s', (string) $ARUDD['transCode'], (string) $ARUDD['returnCode'])); $invoice->addVoid($tr, $p->receipt_id); } } }