<p class="card-text">Enlace de pago: <br /><a id="goTo" href="#" target="_blank"></a></p>
                  <button id="btn" class="btn sipay-button btn-block" enabled>
                                      Crear enlace
                  </button>

@import url("https://fonts.googleapis.com/css?family=Montserrat:400,400i,700");

* {
  color: #3F3F3F;
  font-family: Montserrat, sans-serif;
}

.vertical-center {
   display: flex;
   align-items: center;
   min-height: 50vh;
}

.sipay-button {
  background-color: #C34112;
  color: white;
}

#example {
  border: 1px solid black;
  padding: 25px;
}
// var img = document.querySelector("#photo");
var btn = document.querySelector("#btn");
var goto = document.querySelector("#goTo");
var pre = document.querySelector("#json");

btn.addEventListener("click", function() {
  btn.disabled = true;
  goto.innerHTML = '';
  btn.innerHTML = `<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>`
  var xhr = new XMLHttpRequest();
  xhr.onreadystatechange = function() {
    if(xhr.readyState == 4 && xhr.status == 200) {
      var url = JSON.parse(xhr.responseText);
      goto.href = url.payload.url;
      goto.innerHTML = url.payload.url;
      btn.disabled = false;
  btn.innerHTML = `Crear enlace`

      
      // pre.innerHTML = JSON.stringify(url, null, 4);
    }
  }
  xhr.open("POST", "https://eog6w34siej30da.m.pipedream.net/", true);
  xhr.setRequestHeader('Content-type', 'application/json');
  xhr.send("{}");
});


External CSS

  1. https://cdn.jsdelivr.net/npm/bootstrap@4.2.1/dist/css/bootstrap.min.css

External JavaScript

  1. https://code.jquery.com/jquery-3.3.1.slim.min.js
  2. https://cdn.jsdelivr.net/npm/popper.js@1.14.6/dist/umd/popper.min.js
  3. https://cdn.jsdelivr.net/npm/bootstrap@4.2.1/dist/js/bootstrap.min.js