card.on('brand', function (event) {
document.getElementById('card-errors').innerHTML = "";
//when card brand changes
actualBrand = cardStatus.brand;
//totalAmount & currency of the purchase
dlocal.createInstallmentsPlan(card, totalAmount, currency)
var installmentsSelect = document.getElementById('installments');
buildInstallments(installmentsSelect, result.installments);
function buildInstallments(installmentsInput, installmentsPlan) {
const installmentsOptions = installmentsPlan.installments.reduce(function (options, plan) {
options += "<option value=" + plan.id + ">" + plan.installments + " of " + currency + " " + plan.installment_amount + " (Total : " + currency + " " + plan.total_amount + ")</option>";
installmentsInput.disabled = false;
installmentsInput.innerHTML = installmentsOptions;