Pessoal estou quebrando a cabeça pra fazer um loop pelo foreach O consultarpagamento ele pega o link xml com a data 12/08/2019 com o token quando eu clico pra consultar ele executa o consultarpagamento.php
e assim ele me devolve os valores
80079598 : 27951
80079409 : 27951
80079399 : 27951
80079005 : 27951
80078970 : 27951
So que o CODE ele pega certo so o ID que ele deveria pegar so pega 1 e não pega o resto
Codigo completo do XML
xml
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<result>
<success>true</success>
<data>
<charges>
<charge>
<code>80079409</code>
<dueDate>16/08/2019</dueDate>
<checkoutUrl>
https://sandbox.boletobancario.com/boletofacil/checkout/5E4426FF099E1A1C88E388EEB03571610B43523DFB8C8356
</checkoutUrl>
<link>
https://sandbox.boletobancario.com/boletofacil/charge/boleto.pdf?token=539231:m:bb5b865782ceec0633b43500fe3a2633d51b43303e1c7674a80e0e12383df30b
</link>
<payNumber>BOLETO PAGO</payNumber>
<billetDetails>
<bankAccount>0655/46480-8</bankAccount>
<ourNumber>176/80079409-2</ourNumber>
<barcodeNumber>34191798300000021001768007940920655464808000</barcodeNumber>
<portfolio>176</portfolio>
</billetDetails>
<payments>
<payment>
<id>27942</id>
<amount>21.00</amount>
<date>12/08/2019</date>
<fee>3.90</fee>
<type>BOLETO</type>
<status>CONFIRMED</status>
<creditCardId/>
</payment>
</payments>
</charge>
<charge>
<code>80079399</code>
<dueDate>16/08/2019</dueDate>
<checkoutUrl>
https://sandbox.boletobancario.com/boletofacil/checkout/4E6E654050A7F01250197376A4F2DDC5E16C6B297FDA03F2
</checkoutUrl>
<link>
https://sandbox.boletobancario.com/boletofacil/charge/boleto.pdf?token=539221:m:2dedab41ca47e7c16c80b1da059be0bb83f2ef860b68302729671a18f18da845
</link>
<payNumber>BOLETO PAGO</payNumber>
<billetDetails>
<bankAccount>0655/46480-8</bankAccount>
<ourNumber>176/80079399-5</ourNumber>
<barcodeNumber>34191798300000032001768007939950655464808000</barcodeNumber>
<portfolio>176</portfolio>
</billetDetails>
<payments>
<payment>
<id>27941</id>
<amount>32.00</amount>
<date>12/08/2019</date>
<fee>3.90</fee>
<type>BOLETO</type>
<status>CONFIRMED</status>
<creditCardId/>
</payment>
</payments>
</charge>
<charge>
<code>80079005</code>
<dueDate>15/08/2019</dueDate>
<checkoutUrl>
https://sandbox.boletobancario.com/boletofacil/checkout/E383FCFDBB5E4A06E435BEE8DAC6B00D2B10E80D4A014538
</checkoutUrl>
<link>
https://sandbox.boletobancario.com/boletofacil/charge/boleto.pdf?token=538884:m:d53c8ed0e470656c103c8133b6346234049cf2c253eed0e1b1c7ce1918645c27
</link>
<payNumber>BOLETO PAGO</payNumber>
<billetDetails>
<bankAccount>0655/46480-8</bankAccount>
<ourNumber>176/80079005-8</ourNumber>
<barcodeNumber>34194798200000032001768007900580655464808000</barcodeNumber>
<portfolio>176</portfolio>
</billetDetails>
<payments>
<payment>
<id>27943</id>
<amount>32.00</amount>
<date>12/08/2019</date>
<fee>3.90</fee>
<type>BOLETO</type>
<status>CONFIRMED</status>
<creditCardId/>
</payment>
</payments>
</charge>
<charge>
<code>80078970</code>
<dueDate>15/08/2019</dueDate>
<checkoutUrl>
https://sandbox.boletobancario.com/boletofacil/checkout/57D3C0650A743272077CD024E456D1B58735E97B51DB6D13
</checkoutUrl>
<link>
https://sandbox.boletobancario.com/boletofacil/charge/boleto.pdf?token=538849:m:6e2680e3a5620076f0f97524c4270b72bf423f873d549973e89c05965f9409e7
</link>
<payNumber>BOLETO PAGO</payNumber>
<billetDetails>
<bankAccount>0655/46480-8</bankAccount>
<ourNumber>176/80078970-4</ourNumber>
<barcodeNumber>34195798200000032001768007897040655464808000</barcodeNumber>
<portfolio>176</portfolio>
</billetDetails>
<payments>
<payment>
<id>27944</id>
<amount>32.00</amount>
<date>12/08/2019</date>
<fee>3.90</fee>
<type>BOLETO</type>
<status>CONFIRMED</status>
<creditCardId/>
</payment>
</payments>
</charge>
</charges>
</data>
</result>
consultarPagamentov.php
<?php
include("../../conexao.php");
if(!isset($_SESSION)){
session_start();
}
$query4 = "select * from funcionalidades where id = '1'";
$result4 = mysqli_query($conexao, $query4);
$dados4 = mysqli_fetch_array($result4);
if(mysqli_num_rows ($result4) > 0) {
}
if($dados4['status'] == 1) {
if (isset($_POST['data'])){
$data = $_POST['data'];
$token = "3C9D99D90FF1F6F9AF2353D708CA2C59BFC6828CBDFF4ED2254F9CE4D3EBA416";
function gerar($token,$data){
$url = "https://sandbox.boletobancario.com/boletofacil/integration/api/v1/list-charges?";
$url .= "token=".$token."&";
$url .= "beginPaymentDate=".$data."&";
$url .= "responseType=XML";
return $url;
}
$xml = gerar($token,$data);
$boleto = simplexml_load_file($xml);
$capeta = $boleto->data->charges->charge;
foreach($capeta as $dados){
echo $dados->code;
echo "<br>";
echo $dados->payNumber;
echo "<br>";
}
}
}else{
echo "Função desabilitada contate um administrador para fazer a liberação!";
}
?>
Ele pega as informações correta já no exemplo de baixo ele não pega todos ID do payments->payment do xml
consultarPagamentov.php
<?php
include("../../conexao.php");
if(!isset($_SESSION)){
session_start();
}
$query4 = "select * from funcionalidades where id = '1'";
$result4 = mysqli_query($conexao, $query4);
$dados4 = mysqli_fetch_array($result4);
if(mysqli_num_rows ($result4) > 0) {
}
if($dados4['status'] == 1) {
if (isset($_POST['data'])){
$data = $_POST['data'];
$token = "3C9D99D90FF1F6F9AF2353D708CA2C59BFC6828CBDFF4ED2254F9CE4D3EBA416";
function gerar($token,$data){
$url = "https://sandbox.boletobancario.com/boletofacil/integration/api/v1/list-charges?";
$url .= "token=".$token."&";
$url .= "beginPaymentDate=".$data."&";
$url .= "responseType=XML";
return $url;
}
$xml = gerar($token,$data);
$boleto = simplexml_load_file($xml);
$capeta = $boleto->data->charges->charge->payments->payment;
foreach($capeta as $dados){
echo $dados->id;
echo "";
echo $dados->amount;
}
}
}else{
echo "Função desabilitada contate um administrador para fazer a liberação!";
}
?>
consultar.php
<form action="consultarPagamentov" method="POST">
<div class="form-group">
<label for="exampleInputEmail1">Data</label>
<input type="text" required class="form-control" name="data" id="data" placeholder="Data">
</div>
<button type="submit" class="btn btn-primary">Consultar</button>
</form>