1
The getInstallments Pagseguro serves to return the amount of installments and the value of each installment, when informing a card and the value of the sale.
The return I get is this:
In this return each item represents an amount of installments and their value, what I’m not getting is to use the foreach somehow in this return and fill a Select options.
I’d like to fill in the select with the amount of parcel and the value.
To return the values I am using:
PagSeguroDirectPayment.getInstallments({
    amount: <?php echo $total_compra?>,
    brand: $("#bandeira").val(),
    maxInstallmentNoInterest: 2,
    success: function(response) {
        //console.log(response);
        bandeira = $("#bandeira").val();
        $("#parcelas_div").show(200);
        var options = "";
        var retorno_bandeira = response.installments.visa;
        for (var i = 0; i < retorno_bandeira.length; i++) {
            var quantidade = retorno_bandeira[i].quantity;
            var parcela = retorno_bandeira[i].installmentAmount;
            var valorTotal = retorno_bandeira[i].totalAmount;
            options += '<option value="' + quantidade + '" data-valor="' + parcela + '">' + quantidade + 'x de ' + parcela + ' = R$ ' + valorTotal + '</option>';
        }
        $("#parcelas").html(options);
    },
    error: function(response) {
        console.log(response);
    },
    complete: function(response) {
        console.log(response);
    }
});
The problem that is occurring is the following:
I put myself on the line var retorno_bandeira = response.installments+"."+bandeira; return of all data comes Undefined, but, if I add the flag name directly on the line like this response.installments.visa; everything comes normal, I believe the problem is in the form of concatenating the name of the flag to return.

Put your attempts in there so we can take a look.
– Renato Vieira Dantas