Sha256: b4d03f5dcc2bd59ba1df6242a195e2a8707042bcb9d31de248a2e1672682aa50
Contents?: true
Size: 1.34 KB
Versions: 38
Compression:
Stored size: 1.34 KB
Contents
import { Controller } from "@hotwired/stimulus" // Connects to data-controller="credit-card" export default class extends Controller { static values = { threeDsUrl: String, threeDsCreq: String } // Anytime the controller is connected to the DOM async connect() { if (!this.threeDsUrlValue) return var iframe = document.createElement('iframe') iframe.height = "460px" iframe.width = "500px" iframe.name = "myframe" iframe.id = "myframe" this.element.appendChild(iframe) var idocument = iframe.contentWindow.document var myform = idocument.createElement("form") myform.name = "myform" myform.setAttribute("target", "myframe") myform.setAttribute("method", "post") myform.setAttribute("action", this.threeDsUrlValue) var hiddenField = idocument.createElement("input") hiddenField.setAttribute("type", "hidden") hiddenField.setAttribute("name", "creq") hiddenField.setAttribute("value", this.threeDsCreqValue) myform.appendChild(hiddenField) iframe.appendChild(myform) var submit_form = document.getElementById("checkout_confirm_button") submit_form.setAttribute("class", "hidden") myform.submit() window.addEventListener("message", (e) => { if (e.data.status === "COMPLETE") { document.getElementById("checkout_form_confirm").submit(); } }) } }
Version data entries
38 entries across 38 versions & 2 rubygems