/** * @param string|SimpleXMLElement $content * * @return \Realejo\Ofx\Banking\Statement */ public static function parse($content) { // Verifica se é um string if (is_string($content)) { $content = \Realejo\Ofx\Parser::makeXML($content); } $Statement = new Statement(); // Verifica se exite a seção do Signon $request = $content->xpath('//SIGNONMSGSRSV1/SONRQ'); $SONRS = $content->xpath('//SIGNONMSGSRSV1/SONRS'); if (count($SONRS) == 1) { $SONRS = $SONRS[0]; $response = new StatementResponse(); $response->statusCode = (int) $SONRS->STATUS->CODE; $response->statusSeverity = $SONRS->STATUS->SEVERITY; $response->date = \Realejo\Ofx\Parser::parseDate($SONRS->DTSERVER); $response->language = $SONRS->LANGUAGE; $response->fiOrganization = \Realejo\Ofx\Parser::parseDate($SONRS->FI->ORG); $response->fiUniqueId = \Realejo\Ofx\Parser::parseDate($SONRS->FI->FID); $Statement->setResponse($response); } return $Statement; }
/** * * @param string|SimpleXMLElement $content * * @throws \Exception * * @return \Realejo\Ofx\Banking\Statement */ public static function parseCreditcardMessage($content) { // Verifica se é um string if (is_string($content)) { $content = \Realejo\Ofx\Parser::makeXML($content); } // Verifica se existe o bloco de Banking $CREDITCARDMSGSRSV1 = $content->xpath('//CREDITCARDMSGSRSV1'); if (count($CREDITCARDMSGSRSV1) == 1) { $Statement = new Statement(); // Verifica se exite a seção do request $STMTTRNRQ = $content->xpath('//CREDITCARDMSGSRSV1/CCSTMTTRNRQ'); if (count($STMTTRNRQ) == 1) { throw new \Exception('Creditcard Request Statment not implemented'); } // Verifica se exite a seção do response $STMTTRNRS = $content->xpath('//CREDITCARDMSGSRSV1/CCSTMTTRNRS'); if (count($STMTTRNRS) == 1) { $STMTTRNRS = $STMTTRNRS[0]; $response = new StatementResponse(); // Currency $CURDEF = $STMTTRNRS->xpath('//CURDEF'); if (count($CURDEF) == 1) { $response->currency = $CURDEF[0]; } // Verifica se tem conta do banco $BANKACCTFROM = $STMTTRNRS->xpath('//CCACCTFROM'); if (count($BANKACCTFROM) == 1) { $response->setCredicardccount(self::parseCreditcardAccount($STMTTRNRS)); } // Verifica as transações $BANKTRANLIST = $STMTTRNRS->xpath('//BANKTRANLIST'); if (count($BANKTRANLIST) == 1) { $response->setTransactionList(self::parseTransactions($STMTTRNRS)); } // Verifica Ledger Balance $LEDGERBAL = $STMTTRNRS->xpath('//LEDGERBAL'); if (count($LEDGERBAL) > 0) { $response->setLedgerBalance(self::parseLedgerBalance($STMTTRNRS)); } // Verifica Available Balance $AVAILBAL = $STMTTRNRS->xpath('//AVAILBAL'); if (count($AVAILBAL) > 0) { $response->setAvailableBalance(self::parseAvailableBalance($STMTTRNRS)); } // Grava o response $Statement->setResponse($response); } // end if (count($STMTTRNRS) == 1); } // end if (count($BANKMSGSRSV1) == 1) return $Statement; }